Jest to Vitest API Map in Vitest
From the Vitest cheat sheet · Migrating from Jest · verified Nov 2026
Jest to Vitest API Map
Swap jest.* calls for vi.* and fix module factories, types, and callbacks
typescript
// jest.fn() -> vi.fn()
// jest.spyOn() -> vi.spyOn()
// jest.mock() -> vi.mock()
// jest.requireActual() -> await vi.importActual()
// jest.useFakeTimers() -> vi.useFakeTimers()
// jest.setTimeout(5000) -> vi.setConfig({ testTimeout: 5000 })
// jest.Mock<T> -> import type { Mock } from 'vitest'
import { describe, expect, test, vi } from 'vitest'🟢 Most tests run unchanged after swapping jest.* for vi.*
📌 Matchers mirror Jest; see the Jest sheet for the shared basics
⚡ Set globals: true to skip adding imports during the migration
💡 ts-jest and babel-jest go away; Vite transforms TS and JSX
jestmigration
Continue with Vitest
Save the full cheat sheet or work through every related task.