software · Q875
Vitest
Vite-powered open-source JavaScript and TypeScript testing framework with Node environments, Browser Mode, mocking and coverage.
Overview
Vitest is an open-source testing framework powered by Vite. It runs JavaScript and TypeScript tests, integrates with Vite configuration and offers a Jest-like testing API. Node-based environments and real-browser testing are separate execution choices. It can help verify AI-generated application code, but the value of a passing suite still depends on which behavior the tests assert.[2][3]
Project integration
Vitest normally reads the project's Vite configuration, allowing test code to share its transformation setup. A dedicated test configuration is also possible. The inspected guide requires Vite 6.4 or newer and Node.js 22.12 or newer; these are current-guide requirements, not a claim about every historic release. Interactive watch execution and a single-run CI invocation are separate modes. Bun users are warned that invoking Bun's own test command selects a different runner.[2]
Choosing what the test actually runs
The default environment is Node.js. jsdom and happy-dom supply browser-like APIs inside Node; they do not become real browser engines, and happy-dom lacks some APIs. Browser Mode is a distinct configuration, suitable for tests that need actual browser behavior. This distinction matters when generated frontend tests pass despite relying on layout, events or platform details that an emulator does not reproduce.[3]
Real-browser tests and limitations
Browser Mode can use Playwright or WebdriverIO, with a provider required for headless operation. Framework-specific Vite configuration may still be needed. Native ESM module namespaces are sealed, so spying directly on an imported module object is not the same as in Node-based tests; the documented mock spy option supplies an alternative. Blocking dialogs are mocked to prevent the test page from hanging. Real-browser execution therefore still has an explicit harness and limitations.[5]
Moving a Jest suite
Vitest's Jest-like surface does not make an unchanged suite equivalent. Globals are disabled by default, mockReset restores the original mock implementation rather than always producing an empty function, and module factories use an explicit export object. Existing automatic DOM-cleanup assumptions also need attention when globals stay disabled. A migration should verify assertions and isolation behavior rather than only count how many tests run successfully.[4]
Interpreting coverage
Optional V8 and Istanbul providers measure execution coverage. V8 coverage depends on a compatible runtime and exposed profiling facilities; it is not usable in every browser or edge environment. More importantly, the default report shows files imported during the test run. Explicit source include patterns are needed to reveal untouched files. A high percentage on the default subset is therefore not evidence that the whole application has been tested.[6]
Static tests are a separate check
Type-test files are analyzed through tsc or vue-tsc rather than executed. They can protect a public type interface, but do not exercise a runtime branch merely because a test-shaped expression appears in the file. The documentation treats overlapping runtime and type-test selections as separate results. Both kinds of checks can be useful for generated TypeScript, with neither automatically replacing the other.[7]
License and substitution
Vitest is MIT-licensed. It is a candidate replacement for Jest when its Vite integration and supported environments match the project. Migration still requires review of mock semantics and configuration, and no universal speed improvement is claimed here. No installation or hands-on suite migration was performed.[1][4][8]
Capabilities & limitations
Vite configuration integration
supportedReads Vite configuration by default, with a separate test configuration available.[2]
Automated JavaScript and TypeScript application tests · Node.js, Browser Mode with configured providers · Version, build and integration requirements apply
1 source · check evidence
Requirements, Vite configuration and one-shot execution
vendor · checked 2026-10-07Real-browser execution
supportedBrowser Mode uses a configured provider; headless operation requires Playwright or WebdriverIO.[5]
Automated JavaScript and TypeScript application tests · Node.js, Browser Mode with configured providers · Version, build and integration requirements apply
1 source · check evidence
Providers, headless operation and sealed ESM namespace limitation
vendor · checked 2026-10-07Jest suite migration
limitedSimilar APIs retain differences in globals, mock factories and reset semantics.[4]
Automated JavaScript and TypeScript application tests · Node.js, Browser Mode with configured providers · Version, build and integration requirements apply
1 source · check evidence
Globals, mockReset and module factory differences
vendor · checked 2026-10-07Coverage of unimported files by default
unsupportedThe default report includes imported files; source include patterns are needed to expose untouched files.[6]
Automated JavaScript and TypeScript application tests · Node.js, Browser Mode with configured providers · Version, build and integration requirements apply
1 source · check evidence
V8/Istanbul providers and imported-files default
vendor · checked 2026-10-07Static type tests
supportedType-test files are compiler analyzed, not executed as runtime tests.[7]
Automated JavaScript and TypeScript application tests · Node.js, Browser Mode with configured providers · Version, build and integration requirements apply
1 source · check evidence
Compiler-only files versus runtime execution
vendor · checked 2026-10-07Can substitute for
These are products or services this entry can replace. Check the task and limitations for each comparison.
Jest for Automated JavaScript and TypeScript application tests
limitedCan replace Jest for many JavaScript/TypeScript suites, particularly with Vite, after adapting mocks, configuration and cleanup assumptions. Jest-compatible API does not mean identical execution behavior.[2][4][8]
Node.js, Browser Mode with configured providers · Version, build and integration requirements apply
References
- Vitest license
MIT terms
vendor · retrieved 2026-10-07 - Vitest getting started
Requirements, Vite configuration and one-shot execution
vendor · retrieved 2026-10-07 - Vitest environments
Node default; DOM emulation distinct from Browser Mode
vendor · retrieved 2026-10-07 - Migrating from Jest
Globals, mockReset and module factory differences
vendor · retrieved 2026-10-07 - Vitest Browser Mode
Providers, headless operation and sealed ESM namespace limitation
vendor · retrieved 2026-10-07 - Vitest coverage
V8/Istanbul providers and imported-files default
vendor · retrieved 2026-10-07 - Vitest type tests
Compiler-only files versus runtime execution
vendor · retrieved 2026-10-07 - Jest getting started
Vite integration and TypeScript transformation boundaries
vendor · retrieved 2026-10-07
Discussion & disputes
Ask about unclear claims or explain a concern with supporting sources. If you have a specific fix, suggest a correction.
No discussion yet.
Revision history
Open a revision to read an earlier version of this article.
| Revision | Timestamp | Edit summary |
|---|---|---|
| 923 | 2026-10-13 13:25:12 | /* wbeditentity-create-item:0| */ sf:f8a81e2a-aaf7-4a8d-95e4-738461ad553e:v1 | Adds Vitest with Jest migration differences, actual-browser versus DOM emulation, coverage inclusion and distinct static type tests. | attribution: /proposals/f8a81e2a-aaf7-4a8d-95e4-738461ad553e |