Testing
Automated tests for pure logic, Nitro routes, Vue components, and critical browser flows. Tests live under tests/ at the repo root.
Stack
- Vitest — unit, API, and component tests (
vitest.config.ts) - @vue/test-utils — component mounting with Nuxt child stubs
- Playwright — e2e smoke against production build (
playwright.config.ts)
Test layers
| Layer | Location | Examples |
|---|---|---|
| Unit | tests/unit/** | utils/seo, slugify, formatYoutubeUrl |
| API (Nitro) | tests/api/** | health.get, robots.txt |
| Component | tests/components/** | FilterPills props and emits |
| E2E | tests/e2e/** | Home, beats, docs, health, robots smoke |
Commands
npm test # All Vitest
npm run test:watch # Vitest watch mode
npx vitest run tests/unit/utils/seo.test.ts # Single file
npm run test:e2e # Playwright (runs build:e2e first)
npm run test:all # Vitest + Playwright
npm run build:e2e # NITRO_PRESET=node-server nuxt buildHelpers
tests/helpers/nitro.ts—buildGetEvent,stubNitroGlobals,callHandler
Conventions
- Mirror source paths under
tests/(e.g.utils/seo.ts→tests/unit/utils/seo.test.ts) - Use
// @vitest-environment nodefor pure TS and Nitro handler tests - Component tests use
happy-dom; stubIcon,NuxtLink, etc. - Do not hit production DB or live external APIs in unit/component tests
- Gitignore:
playwright-report/,test-results/
Deferred coverage
- Express API handlers in
api/(futureapi/tests/) - Heavy composables (
useAuth,useSocket,useGlobalAudio) - Howler / waveform player components
Cursor agent
Use the testing agent skill (.cursor/skills/testing-agent/SKILL.md) and rule (.cursor/rules/testing-agent.mdc) when adding coverage or fixing flaky tests.