How it works
Vitest reuses a project's Vite configuration, so TypeScript, JSX, ES modules and path aliases work in tests exactly as they do in the app, with no separate Babel setup. Its describe, it, expect and vi.fn() APIs mirror Jest's, which makes moving an existing suite mostly a matter of changing imports. Watch mode reruns only the tests affected by a change, almost instantly.
It covers unit and component tests with jsdom or happy-dom, snapshots, code coverage through V8 or Istanbul, and type tests. Browser Mode runs tests in a real browser through Playwright or WebdriverIO, for components that depend on real browser behaviour. It also works outside Vite projects, such as plain Node.js libraries, and is maintained by the same community as Vite.
Vitest pros and cons
Pros
- Fast start-up and near-instant watch mode
- TypeScript and ES modules work with no extra setup
- Jest-compatible API, so switching is straightforward
- Browser Mode for tests in a real browser
Cons
- Younger than Jest, with fewer long-standing guides and plugins
- Some Jest-specific plugins and mocks need reworking
When to use Vitest
Pick it when
- Projects built with Vite, including React, Vue, Svelte and Astro apps
- TypeScript codebases that want tests without transpiler setup
- New projects choosing a test runner from scratch
Skip it when
- A large, stable Jest suite where migrating brings little benefit
- React Native projects, where Jest is the standard
Vitest pricing
Vitest vs the alternatives
Related terms
More in Testing and quality
Test runners