
Vitest
A JavaScript and TypeScript test runner that reuses your Vite setup.
- Stars
- 17.3k
- Forks
- 2.1k
- Licence
- MIT
- Language
- TypeScript
- Last update
- 4 days ago
- Type
- Library
What it is
Vitest is a testing tool for JavaScript and TypeScript code. You write tests with a familiar style, and it runs them using the same configuration your Vite-based app already uses. It also includes watch mode that reruns tests as you change files, and built-in code coverage reporting.
- Write unit tests for functions and components in a Vite project
- Run component tests in a real browser using Browser Mode
- Measure code coverage with v8 or istanbul
- Test DOM code using JSDOM or happy-dom
- Run benchmarks with Tinybench
Great for
- JavaScript or TypeScript developers already using Vite
- Teams testing front-end components in Vue, React, or Svelte
- Developers who want Jest-style tests with faster watch mode
- Projects that need code coverage and snapshot tests
Not ideal for
- Non-developers, since it requires writing code tests (reason: it is a developer tool)
- Projects that do not use JavaScript or TypeScript (reason: the README describes only that ecosystem)
- Projects requiring Node below v22.12.0 or Vite below v6.4.0 (reason: the README lists these minimums)
How to get it
- 1
Install with a package manager
You'll need: Node.js 22.12.0 or newer · Vite 6.4.0 or newer
Run Vitest with npx
npx vitest - 2
Run it
- Install Node.js 22.12.0 or newer and Vite 6.4.0 or newer
- Write a test file using describe, it, and expect imported from 'vitest'
- Run npx vitest in your project folder
- Watch the results and rerun as you edit files
- 3
Get the most out of it
- Use Browser Mode to test Vue, React, Svelte, or Lit components in a real browser
- Enable coverage with the v8 or istanbul providers
- Use Projects support to run different test configurations in one workspace
- Use sharding to split tests across machines
- Add Jest-style snapshot tests with toMatchSnapshot
Downloads
Strengths
- Reuses Vite configuration, plugins, and transforms so test setup matches the app
- Supports Jest-compatible APIs, which eases migration from Jest
- Includes watch mode, coverage, snapshots, mocking, and TypeScript support out of the box
Trade-offs
- Requires recent versions: Node 22.12.0 or newer and Vite 6.4.0 or newer
- Less useful if your project does not use Vite
- README is truncated, so some details are unverified here
How it compares
| Project | Stars | Type | Level | Updated | Best for |
|---|---|---|---|---|---|
| vitest (this) | 17.3k | Library | intermediate | 4 days ago | JavaScript or TypeScript developers already using Vite |
| jest | 45.5k | Library | beginner | 4 days ago | JavaScript or TypeScript developers who want a testing setup that works with little configuration |
| mocha | 22.9k | Library | intermediate | 5 days ago | JavaScript and Node.js developers who want automated tests for their code |
| ava | 20.8k | Dev tool | beginner | 5 days ago | Node.js developers who want a small, straightforward test runner |
| enzyme | 19.8k | Library | intermediate | 1.0 years ago | Developers maintaining React codebases that already have component tests |
| ui | 127k | Library | intermediate | 4 days ago | Developers building React or Next.js interfaces who want full control over component code |
Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.