Vitest vs Jest comes down to your build tool and your Node version. If you build with Vite and run Node 22.12 or newer, switch to Vitest 5 in a branch. On Vite with Node 20, take Vitest 4. Not on Vite, stay on Jest 30. Your count of jest.mock factories sets how big the migration is.
Vitest vs Jest: what actually differs
The differences that decide a migration are the runtime floor, the config model and how mocks behave. Vitest has a Jest-compatible API, designed to make migration from Jest simple, according to its Migrating from Jest page.
| Difference | Vitest | Jest |
|---|---|---|
| Current major | Vitest 5 (5.1.1) | Jest 30 (30.5.2) |
| Node floor | 22.12.0 or newer | Drops Node 14, 16, 19, 21 |
| Vite floor | 6.4.0 or newer | Not used |
| Config | Reads your vite.config | Own config file |
| Globals | Off by default | On by default |
| Module mock factory | Must return every export explicitly | Return value becomes the default export |
Don't decide on speed. Each project publishes gains only against its own previous version.
Jest 30's release post reports 37% faster test runs and 77% lower memory in the server tests of one large TypeScript app. Vitest 5's post reports a deps-heavy vmThreads run dropping 53% against Vitest 4.1. Runs using forks with jsdom and isolation stayed within 3% of Vitest 4.1. Neither compares the two runners, and any "10-20x" you've seen has no primary source behind it.
To get a number you can use, copy a slice of your suite, run jest and vitest on the same machine, cold and warm, and compare. That takes under an hour. Vitest 5 also ships vitest doctor, which recommends faster options for your setup.
Which should you pick?
Pick by toolchain first. Vite apps should move, and everything else should stay put until there's a reason.
Stay on Jest 30
This one is for teams on webpack, Babel or React Native, with a large green suite or a Node version pinned below 22.12. Moving gets them nothing that offsets the churn.
The catch is the upgrade to 30 itself. It needs TypeScript 5.4 or newer, and its jsdom jump from 21 to 26 can break tests that mock window.location. Some expect aliases were removed, and eslint-plugin-jest has an autofixer for them.
Move to Vitest 5
This one is for Vite apps that want one config for the build and the tests. Your aliases and plugins apply in tests too.
The catch is the floors in the table, plus a mock model that's stricter than Jest's. Globals are off, factories must be explicit, and 5.0 changed the mock-clearing default and made misplaced hoisted calls throw. Steps 3, 5 and 6 below cover each.
Switch later: Vite on Node 20
This one is for Vite apps pinned to Node 20. Take Vitest 4 now and plan the Node upgrade separately. Vitest 5 landed in September 2026, so there's no rush to be early. Move up when your Node baseline reaches 22.12.
How to migrate from Jest to Vitest
Do it in a branch, one config and one test file at a time.
1. Check your Node and Vite floor
Check your CI image and deploy target against the Node and Vite floors in the table. If you're below, upgrade, or take Vitest 4, which needs Node 20 and Vite 6.0.0 or newer.
2. Add a test block to your vite.config
Install vitest, then add a test block to your existing vite.config and map the Jest keys across: testEnvironment becomes test.environment, setupFilesAfterEnv becomes test.setupFiles, and moduleNameMapper becomes resolve.alias, which a Vite app usually has already. Check the exact names against Vitest's config reference.
The transform entry for ts-jest or Babel usually goes away, because Vitest runs files through your Vite setup. Don't create a separate vitest.config.ts unless you merge your vite.config into it: Vitest would then ignore every option in vite.config.
3. Decide on globals
Jest gives you describe, it and expect everywhere. Vitest doesn't. Set globals: true to keep your files untouched, or import them from vitest and keep the config clean. The first is faster to land, and the second is better long term.
4. Rename the APIs
Swap jest.fn for vi.fn, jest.mock for vi.mock and jest.requireActual for vi.importActual. A find-and-replace gets most of it. Two things have no equivalent: Vitest doesn't support the done callback style of declaring tests, and it doesn't support Jest's legacy timers.
5. Fix your module mock factories
This is where a mock-heavy suite spends its time. Return an object of named exports from every factory, as the worked example below shows. A root __mocks__ folder also isn't loaded unless the test calls vi.mock().
6. Fix what Vitest 5 changed
Three changes bite existing suites. clearMocks now defaults to true, so call counts reset between tests, and clearMocks: false is the escape hatch that restores the old behaviour. resolves, rejects and toMatchFileSnapshot now fail if you don't await them. And vi.mock, vi.unmock and vi.hoisted throw when called outside the top level of a file.
7. Regenerate snapshots and run both runners for a week
Regenerate snapshots, then run Jest and Vitest as two test jobs in CI and compare failures. Delete Jest once a week goes by with no disagreement. When you set up those parallel jobs, our GitHub Actions vs CircleCI comparison covers the two big options for where they run.
Worked example: one mock-heavy test file
A React and TypeScript app on Node 24 with Vite and one jest.config.js migrates in three edits: the config, the mock factory and one test that depended on Jest's reset behaviour.
The config. The transform block disappears, and the test block goes into the vite.config you already have.
// jest.config.js (before)
module.exports = {
testEnvironment: 'jsdom',
setupFilesAfterEnv: ['./setup.ts'],
moduleNameMapper: { '^@/(.*)$': '<rootDir>/src/$1' },
transform: { '^.+\\.tsx?$': 'ts-jest' },
}// vite.config.ts (after)
/// <reference types="vitest/config" />
import { defineConfig } from 'vite'
export default defineConfig({
// keep your existing plugins and resolve.alias as they are
test: {
environment: 'jsdom',
setupFiles: ['./setup.ts'],
globals: true,
},
})The mock factory. Jest treats the returned function as the default export. Vitest wants the export spelled out. To keep the module's other exports real, spread vi.importActual (Jest's requireActual) into the factory and override only the default.
// Jest
jest.mock('./api', () => jest.fn(() => 'x'))
// Vitest
vi.mock('./api', async () => ({
...(await vi.importActual('./api')),
default: vi.fn(() => 'x'),
}))The reset change. With jest.fn() in place of vi.fn(), this pair passes on Jest, because the mock counts calls across both tests. On Vitest 5 the second assertion fails with one call, not two.
const send = vi.fn()
it('sends the first message', () => {
send('a')
expect(send).toHaveBeenCalledTimes(1)
})
it('sends the second message', () => {
send('b')
expect(send).toHaveBeenCalledTimes(2)
})The better fix is to assert one call in each test, since tests that share state are fragile anyway. If you have hundreds of these, use the step 6 escape hatch during the migration and clean them up later.
What this means for your test suite
Start with the build tool, because it settles most of this. If you're on Vite and Node 22.12 or newer, schedule the Vitest 5 branch this sprint. Count your jest.mock factories first: that count tells you how big the migration is. Then run both runners in CI until they agree.
If you're on any other build tool and nothing hurts, leave the Jest suite alone and put the time elsewhere.
Whatever you choose, measure on your own suite before telling anyone it's faster. For the rest of your toolchain decisions, see more stack comparisons.
FAQ
Why use Vitest instead of Jest?
Mostly because it reads your Vite config. You don't maintain a second set of aliases and plugins for tests, and the API is Jest-compatible. The cost is a higher Node floor and stricter mocks.
How much faster is Vitest than Jest?
No primary source publishes a fair head-to-head. Jest 30 reports gains against Jest 29, and Vitest 5 reports gains against Vitest 4. To get your own figure, run both on a copy of your suite on one machine, cold and warm.
What is Vitest used for?
It's a test runner for JavaScript and TypeScript projects that reads your Vite config. Most teams use it where they'd use Jest, for unit and component tests, and its Jest-compatible API is meant to make that move simple.
How do I migrate from Jest to Vitest?
Check your Node and Vite floor, add a test block to your vite.config, decide on globals, rename the jest.* calls to vi.*, make mock factories explicit, then fix the Vitest 5 changes and run both runners in CI for a week. The steps above cover each one.
