Demystifying Nuxt Test Utils
summary
Explains how @nuxt/test-utils boots a real Nuxt environment in Vitest so compiler macros like definePageMeta, auto-imports and Nuxt modules run in tests, and plugins and middleware execute the same lifecycle as the app. Shows using mountSuspended, renderSuspended and mockNuxtImport to mount pages with middleware, register Nitro endpoints via registerEndpoint, run SSR tests that return prerendered HTML, and run Playwright-backed browser tests with hydration checks.
AI-written summary · about
chapters (14)
- 0:00Introduction to talk
- 1:12Nuxt test experience survey
- 3:00Challenges in testing Nuxt apps
- 7:40Introducing Nuxt Test Utils
- 10:11How Nuxt modules run in tests
- 13:04Why plugins work in tests
- 15:34Basic usage of Nuxt Test Utils
- 19:10Mocking Nuxt imports and components
- 20:36Server-side rendering testing
- 22:48Browser testing with Playwright
- 24:38Environment separation tips
- 26:43Test-specific configurations
- 27:06Avoiding implementation-dependent tests
- 28:39Summary and closing
