## TL;DR

Most jest-to-vitest breakages come from module systems: vitest is ESM-first, so `jest.mock` hoisting, `require` usage, and CJS interop behave differently. The usual fix list: replace `jest.*` APIs with `vi.*` (or the compat layer), rewrite `jest.mock` calls to `vi.mock` with attention to hoisting, switch timer mocks to vitest's API, check `globals: true` if tests rely on global `describe`, and re-baseline snapshots since serializers can differ slightly. Migrate one directory at a time with both runners configured.

## The query

```text
jest to vitest migration: common breakages
```

## Use this when

- Planning a jest to vitest migration.
- Debugging failures after switching runners.

## Not for

- Choosing a test runner for a new project.
- Migrating from vitest back to jest.

## Steps

1. Get both runners working side by side on the repo first. Expected output: jest green as before, vitest configured.
2. Migrate one directory; replace `jest.mock` with `vi.mock` and `jest.fn` with `vi.fn`. Expected output: the migrated directory passes under vitest.
3. Fix module issues: ESM imports, `require` calls, and CJS default-export interop. Expected output: no more module-not-found or undefined-default errors.
4. Fix timers and fake-date usage with vitest's timer API. Expected output: time-dependent tests pass deterministically.
5. Re-baseline snapshots and diff them carefully before accepting. Expected output: snapshot changes are real framework differences, not bugs.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_6iXINWNE3JVlhhvpB3qSHA
