Vitest 2 brings browser-native testing, multi-project workspaces, and deep Vite integration to modern JavaScript test suites. Test your knowledge of its advanced capabilities.
0 / 5 completed
1 / 5
What does Vitest 2's browser mode enable that the default Node.js mode cannot provide?
Vitest browser mode runs your tests in a real browser (via Playwright or WebdriverIO) rather than a simulated DOM like jsdom. This means browser APIs like ResizeObserver, CSS layout, and Web Workers behave exactly as they do in production, catching bugs that simulated environments miss.
2 / 5
In Vitest, what does a workspace configuration allow you to do?
Vitest workspaces (via vitest.workspace.ts) let you define multiple test projects, each with its own config — for example, one project using jsdom for component tests and another using Node environment for unit tests. All projects run in a single vitest invocation with a unified report.
3 / 5
What does the test.concurrent modifier do in Vitest?
test.concurrent marks individual tests to run in parallel with other concurrent-marked tests in the same suite. By default, Vitest runs tests within a file sequentially. Marking multiple async tests as concurrent reduces total file execution time — useful for independent async operations like HTTP requests to test servers.
4 / 5
What is a snapshot serialiser in Vitest and when would you add a custom one?
Snapshot serialisers control how Vitest converts a value to its stored string snapshot. The default serialiser handles plain objects and arrays, but you'd add a custom one (via expect.addSnapshotSerializer()) to produce readable snapshots for custom objects — for example, rendering a React component tree in a specific format.
5 / 5
How does Vitest achieve fast test re-runs in watch mode compared to Jest?
Vitest shares Vite's module transformation pipeline and dependency graph. In watch mode, when a source file changes, Vitest uses Vite's HMR module graph to identify exactly which test files import that module, and re-runs only those. This avoids cold-starting a new process or re-bundling unrelated tests — making feedback near-instant.