Vitest
What is Vitest
Vitest is a testing framework powered by Vite. It is MIT licensed and currently at version 4.x. With ~34.4M weekly npm downloads and ~16.2k GitHub stars, it is the recommended testing framework for Vite-based projects, offering a Jest-compatible API with dramatically faster execution.
Why we recommend it
- Vite-native — shares your
vite.config.ts, so TypeScript, JSX, CSS modules, and path aliases work instantly with zero duplicate configuration. - Jest-compatible API —
describe,it,expect, mocking, and snapshots all work the same way. Migration from Jest is straightforward. - Smart watch mode — only re-runs tests affected by changed files. Combined with Vite's transform pipeline, the feedback loop is near-instant.
- Built-in coverage and UI —
--coveragewith V8 or Istanbul, plus a browser-based test UI for exploring results. No extra packages needed. - Browser mode — run tests in real browser environments when jsdom isn't enough, without switching to a separate E2E tool.
When to use
- Unit and integration tests in any Vite-based project
- Projects using React + TypeScript — component testing with React Testing Library works out of the box
- Migrating away from Jest in a Vite project — the API compatibility makes it near drop-in
- In-source testing during rapid prototyping (tests co-located in production files, stripped at build time)
When NOT to use
- End-to-end testing — use Playwright or Cypress for full browser automation, user flows, and cross-browser checks
- Non-Vite projects with deep webpack integration — Jest may still be the path of least resistance
note
Vitest is for unit and integration tests only. For end-to-end testing (user flows, cross-browser compatibility), pair it with Playwright or Cypress.
Resources
- Official Vitest docs
- GitHub repository
- Vite — the build tool Vitest runs on