-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
Summary
Migrate the test framework from Jest to Vitest for better performance, native ESM/TypeScript support, and tighter alignment with the Vite ecosystem.
Motivation
- Performance: Vitest runs significantly faster thanks to native ESM and built-in TypeScript/JSX transformation — no
ts-jestor Babel needed. - Configuration: Vitest reuses
vite.config.tsconventions, reducing config surface (no separatejest.config.ts,jest.setup.ts, path alias duplication). - ESM-first: Jest's ESM support is still experimental and requires workarounds (
jest.resetModules(), dynamic imports). Vitest handles ESM natively. - Watch mode: Vitest's watch mode is instant and uses the same HMR pipeline as Vite dev, making TDD faster.
- API compatibility: Vitest is largely API-compatible with Jest (
describe,it,expect,vi.fn(),vi.mock()), so migration is mostly mechanical.
Scope
Files to update/remove
jest.config.ts→ remove, replace with vitest config (can live invite.config.tsorvitest.config.ts)jest.setup.ts→ migrate to Vitest setup filepackage.jsonscripts:test,test:debug,test:watch- All 41 test suites in
__tests__/andsrc/**/— update imports from@jest/globalstovitest
Key changes per test file
- Replace
import { describe, it, expect, jest, ... } from '@jest/globals'withimport { describe, it, expect, vi, ... } from 'vitest' - Replace
jest.fn()→vi.fn(),jest.mock()→vi.mock(),jest.spyOn()→vi.spyOn(), etc. - Remove
/** @jest-environment node */directives (Vitest usesenvironmentin config or per-file// @vitest-environment node) - Remove
jest.resetModules()/ dynamicimport()patterns where they were workarounds for Jest's module caching
Dependencies
- Remove:
jest,ts-jest,@jest/globals,jest-environment-jsdom(if present),@types/jest - Add:
vitest,@vitest/coverage-v8(optional)
Acceptance criteria
- All 41 test suites pass under Vitest
-
pnpm run test,pnpm run test:watch,pnpm run test:debugwork - No Jest dependencies remain in
package.json - CI (if applicable) uses Vitest
-
pnpm run checkpasses cleanly
Reactions are currently unavailable