d48cda4081
CI / Test (ubuntu-latest, Node 18.x, bun) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, npm) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, pnpm) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, yarn) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 20.x, bun) (push) Failing after 17m13s
CI / Test (ubuntu-latest, Node 20.x, npm) (push) Failing after 18m42s
CI / Test (ubuntu-latest, Node 20.x, pnpm) (push) Failing after 15m0s
CI / Test (ubuntu-latest, Node 20.x, yarn) (push) Failing after 49m44s
CI / Test (ubuntu-latest, Node 22.x, bun) (push) Failing after 51m55s
CI / Test (ubuntu-latest, Node 22.x, pnpm) (push) Failing after 21m57s
CI / Test (ubuntu-latest, Node 22.x, npm) (push) Failing after 37m39s
CI / Test (ubuntu-latest, Node 22.x, yarn) (push) Failing after 34m7s
CI / Validate Components (push) Failing after 37m15s
CI / Python Tests (push) Failing after 10m1s
CI / Security Scan (push) Failing after 10m1s
CI / Lint (push) Failing after 17m12s
CI / Coverage (push) Failing after 20m19s
CI / Test (macos-latest, Node 18.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, yarn) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, yarn) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, yarn) (push) Has been cancelled
2.3 KiB
2.3 KiB
paths
| paths | |||||
|---|---|---|---|---|---|
|
Nuxt Testing
This file extends common/testing.md with Nuxt specific content.
Package: @nuxt/test-utils. Vitest-first for unit and component tests, with built-in Playwright browser E2E support. nuxt-vitest and vitest-environment-nuxt are superseded and folded into it.
Setup
- Install dev deps:
@nuxt/test-utils vitest @vue/test-utils happy-dom playwright-core. - Config:
defineVitestConfig({ test: { environment: 'nuxt' } })from@nuxt/test-utils/config. UsedefineVitestProjectfor multi-project (separate unit / nuxt / e2e environments). - Add
@nuxt/test-utils/moduletonuxt.config. Per-file opt-in via// @vitest-environment nuxt.
Runtime helpers
Import from @nuxt/test-utils/runtime.
mountSuspended(component, opts)mounts in the Nuxt env with async setup + plugin injection (accepts@vue/test-utilsmount options +route).renderSuspended(component, opts)is the Testing Library variant (needs@testing-library/vue).mockNuxtImport(name, factory)mocks auto-imports (e.g.useState). Once per import per file, usevi.hoisted().mockComponent(name, factory)mocks by PascalCase name or path.registerEndpoint(path, handler|opts)mocks a Nitro endpoint to test server routes or stub the backend. Supports method +once.
E2E helpers
Import from @nuxt/test-utils/e2e.
await setup({ rootDir, server, browser, ... })inside the describe block (manages beforeAll/afterAll).- Then
$fetch(url)(rendered HTML),fetch(url)(response object),url(path)(full URL with port),createPage(url)(Playwright). - Playwright integration: import
expect/testfrom@nuxt/test-utils/playwright.
What to test how
- Composables: mock auto-imports with
mockNuxtImport, mount a host component viamountSuspendedto exerciseuseState/useFetchin the Nuxt runtime. - Server routes:
registerEndpointto stub, or e2e$fetch/fetchagainst the real Nitro server.
Reference
- ECC skills:
nuxt4-patterns,e2e-testing,vite-patterns. - Nuxt testing docs
- @nuxt/test-utils npm