JavaScript & TypeScript / Scenario
Boss Fight: The 800-Test Migration
Jest out, Vitest in, one sprint, no coverage dips allowed. Globals, factories, requireActual, aliases, and the order of operations that decides whether this lands or burns.
- Difficulty
- Boss
- Format
- Scenario
- Points
- 300
- Estimate
- 20 min
// MISSION BRIEF
Your Mission
Leadership approved the Jest-to-Vitest migration you have been advocating for a year: 800 tests, 14 packages, one sprint, and a hard rule that main stays green throughout.
The first mechanical attempt (rename jest to vi, swap the config) produced a wall of distinct failures. Each one is a category, not a one-off. Read the artifacts, decode each failure class, and sequence the migration like someone who has done this before.
This is a boss fight: five weighted decisions, partial credit where reasoning is partially right.
// FIRST CONTACT
Battle teaser
First artifact
jest.config.js (being replaced)
Failure [1], 'jest is not defined' even with globals: true enabled. The correct understanding:
- AAdd a globalThis.jest = vi shim in setup and keep the old spelling forever, cost-free
- Bglobals: true injects describe/it/expect/vi, but the jest NAMESPACE never exists in Vitest; every jest.fn/jest.spyOn/jest.mock call must become vi.* (a mechanical, codemod-friendly rename)
- CThe tests must stop using mocks to be Vitest-compatible
- Dglobals: true is broken; import jest from 'vitest' instead
// SKILL TAGS