recommend · verified 2026-09-08
test stack for a Next.js app, unit and end to end
pick Vitest 5.0.0
Vitest 5.0.0 for functions and components, Playwright 1.63.0 for the flows that make you money. Vitest reuses your Vite config so path aliases and TypeScript work without a second build, and Playwright drives real Chromium, Firefox, and WebKit with traces you can open after a CI failure. Skip a unit test for a server component that only awaits a query and reads props; test the query and the page instead.
traps for Vitest (3)
| severity | versions | symptom and fix |
|---|---|---|
| major | >=5.0.0 | Vitest 5 refuses to start on Node 20, or on a project pinned to Vite 6.3 or older. Vitest 5 requires Node.js 22 and Vite 6.4 as a minimum. Upgrade both before the runner, and note that `@vitest/runner` is now inlined and no longer published, so remove any direct dependency on it. evidence |
| major | >=5.0.0 | A test that relied on mock call history from a previous test starts failing after upgrading to 5. Vitest 5 clears mocks by default before each test. Set up the mock inside the test or a `beforeEach` rather than once at module scope, or set `clearMocks: false` if you truly want the old behaviour. evidence |
| minor | >=5.0.0 | A test run in a monorepo package picks up no config and behaves as if options were ignored. Vitest 5 no longer looks up a config file from ancestor directories. Give each package its own config, or pass `--config` explicitly from the workspace script. evidence |
what your agent receives
VERDICT test stack for a Next.js app, unit and end to end PICK Vitest 5.0.0: Vitest 5.0.0 for functions and components, Playwright 1.63.0 for the flows that make you money. Vitest reuses your Vite config so path aliases and TypeScript work without a second build, and Playwright drives real Chromium, Firefox, and WebKit with traces you can open after a CI failure. Skip a unit test for a server component that only awaits a query and reads props; test the query and the page instead. TRAPS (3) [e15de1d3] major: Vitest 5 refuses to start on Node 20, or on a project pinned to Vite 6.3 or older. [71e524a6] major: A test that relied on mock call history from a previous test starts failing after upgrading to 5. [619a3d53] minor: A test run in a monorepo package picks up no config and behaves as if options were ignored. VERIFIED 2026-09-08 by wellworn reviewer · recheck 2027-01-06 · sources 3