Skip to content
Home / Migrations / JestVitest

Jest Vitest

easy

Vitest is Jest-compatible but runs on Vite. Same expect/describe/it API, 10x faster with Vite's transform pipeline.

Estimated: 1-3h · 5 steps
Progress0%
Step 1: Install Vitest
npm install -D vitest && npm uninstall jest ts-jest @types/jest babel-jest
Step 2: Create vitest.config.ts

Minimal config — Vitest auto-detects test files.

import { defineConfig } from 'vitest/config'
export default defineConfig({ test: { globals: true, environment: 'jsdom' } })
Step 3: Update imports

If using globals: true, no imports needed. Otherwise: import { describe, it, expect } from 'vitest'.

Step 4: Replace jest.fn() with vi.fn()

Search and replace jest.fn/jest.mock/jest.spyOn with vi.fn/vi.mock/vi.spyOn.

find src -name '*.test.*' -exec sed -i 's/jest\./vi./g' {} +
Step 5: Update scripts

package.json: test → vitest, test:watch → vitest --watch.

All tests pass with vitest

What this migration involves

Moving from Jest to Vitest is rated easy and takes about 1-3h on a typical project. The guide breaks it into 5 steps, 3 of which ship with runnable commands and 1 with a verification check. On pricing, Jest is open-source and Vitest is open-source with a free plan to test the move.

FAQ

How long does migrating from Jest to Vitest take?

Around 1-3h for a typical project — 5 steps, difficulty rated easy, 3 of them with copy-paste commands.

Is moving from Jest to Vitest reversible?

No reverse guide is tracked yet, so treat this as a one-way move and keep a full export of your Jest data before you start.

What does Vitest cost compared to Jest?

Jest: open-source from $0/mo, free plan available. Vitest: open-source from $0/mo, free plan available.