What changes in mocks, timers and build setup when we move the suite?
Keep a working Jest setup when its fixtures, transforms and CI reporting serve the team and migration offers little measured benefit. Trial Vitest when closer alignment with a Vite project or its developer workflow has value. Similar assertion APIs reduce editing effort on some tests, but do not establish equivalent behaviour.
Move deliberately awkward tests first
Choose a module with a mocked dependency, one debounced save using fake timers and one DOM test requiring project aliases. Record Jest’s expected observations before moving them. In Vitest check mock factories, restoration behaviour, globals and setup-file execution. A port that avoids the assertion or leaves a timer pending has improved the pass rate without preserving the test.
| Probe | What to preserve in Jest | What to verify in Vitest |
|---|---|---|
| Module dependency mock | The import, replacement and observed call | Factory exports and mock reset behaviour |
| Debounced save | When the timer fires and which payload is saved | Timer advancement and pending asynchronous work |
| DOM fixture | Environment, aliases and setup order | Equivalent DOM implementation and configuration |
| Coverage in CI | Files, excluded paths and enabled provider | Same effective scope before comparing percentages |
Measure equivalent jobs, including setup
Use the same Node version, machine, worker limits and coverage configuration. Separate a cold CI job from an incremental local watch run. Compare assertion counts, intended failures and coverage inclusion before quoting duration. Keep the old command available until another engineer can reproduce the migrated failures.