Migrate Jest to Vitest With 3 Parallel Agents, One Directory Each
Book: TypeScript Essentials Also by me: The TypeScript Library — the 5-book collection My project: Hermes IDE | GitHub — an IDE for developers who ship with Claude Code and other AI coding tools Me: xgabriel.com | GitHub Nobody on your team wants the Jest-to-Vitest ticket. It is days of jest.fn to vi.fn , a pile of mock factories that need rewriting, and a dozen done callbacks. It is also the…
This article provides a step-by-step guide on migrating Jest tests to Vitest using three parallel agents, each handling one directory. The first step involves configuring the shared layer for Vitest 5, which requires Node.js 22.12 or later and Vite 6.4 or later. The shared files, such as the config, setup file, package.json, and test helpers, should be placed on the main branch before starting the migration process.
The second step is to create a `vitest.config.ts` file that mimics the Jest suite, ensuring that tests point out real differences between the two runners. This includes setting `globals` to `true`, specifying the environment as `node`, and providing setup files. The `clearMocks` option should be set to `false` to avoid unexpected behavior.
The third step involves copying the Jest setup files into the `vitest.setup.ts` file and rewriting them for Vitest. After that, all references to Jest outside the three directories being migrated (billing, accounts, and search) should be searched using `git grep -n jest . -- :!src/billing :!src/accounts :!src/search`. Shared files, like helpers and custom matchers, should be migrated by hand in a separate commit.
The fourth step is to write a brief for each of the three agents, assigning them to migrate the tests within their respective folders (billing, accounts, and search). The agents should only edit files within their assigned directories, leaving other files unchanged. The test migration should be successful when `npx vitest run src/billing/` passes and `grep -rn jest . src/billing/` prints no results.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.