jest → vitest
@omnimod/plugin-jest-to-vitest migrates Jest test files to Vitest. The two share most of their surface, so the change is mostly the jest global becoming vi plus the import source.
bash
omnimod run jest-to-vitest "**/*.{test,spec}.{ts,tsx,js,jsx}" --writeThe target project needs vitest installed.
Example
ts
// before
const fn = jest.fn();
jest.spyOn(obj, "m");
// after
import { vi } from "vitest";
const fn = vi.fn();
vi.spyOn(obj, "m");Automated
jest.*→vi.*(fn,mock,spyOn,useFakeTimers,clearAllMocks, …).- Prepends
import { vi } from "vitest"whenviis used and not yet imported. - Rewrites
@jest/globalsimports tovitest.
Flagged for follow-up
- Test globals (
describe/it/test/expect) are left as-is with aninfodiagnostic — enabletest: { globals: true }in your Vitest config or import them fromvitest. - Complex module mocks, setup files, and
jest.requireActualneed manual review.
