--- name: nuxt-testing description: Nuxt testing with @nuxt/test-utils — unit tests with Nuxt runtime environment, component testing with mountSuspended, mocking auto-imports, and e2e testing with Playwright. Use when writing tests for Nuxt apps, components, composables, or pages. metadata: author: Phil version: "2026.4.10" source: Generated from https://nuxt.com/docs/4.x/getting-started/testing --- Testing Nuxt applications using `@nuxt/test-utils` with Vitest. Covers unit testing in a Nuxt runtime environment, component testing with `mountSuspended`, mocking Nuxt auto-imports and components, and end-to-end testing with Playwright. > Based on Nuxt 4.x / @nuxt/test-utils documentation, generated at 2026-04-10. ## Setup | Topic | Description | Reference | |-------|-------------|-----------| | Installation & Config | Dependencies, vitest.config.ts with projects, test directory structure | [setup-config](references/setup-config.md) | ## Unit Testing | Topic | Description | Reference | |-------|-------------|-----------| | Nuxt Environment | Running tests in the Nuxt runtime environment, environment options, organizing test directories | [unit-nuxt-environment](references/unit-nuxt-environment.md) | | Helpers | mountSuspended, renderSuspended, mockNuxtImport, mockComponent, registerEndpoint | [unit-helpers](references/unit-helpers.md) | | Built-In Mocks | IntersectionObserver and IndexedDB mocks in the Nuxt test environment | [unit-mocks](references/unit-mocks.md) | ## End-to-End Testing | Topic | Description | Reference | |-------|-------------|-----------| | E2E with Vitest | Setup function, $fetch, fetch, url helpers, browser testing with createPage | [e2e-vitest](references/e2e-vitest.md) | | E2E with Playwright | Playwright test runner integration, goto helper, configuration | [e2e-playwright](references/e2e-playwright.md) |