Skip to content

chore: migrate test runner from jest to vitest - #3

Merged
guimard merged 2 commits into
masterfrom
chore/migrate-jest-to-vitest
Jun 20, 2026
Merged

guimard merged 2 commits into
masterfrom
chore/migrate-jest-to-vitest

Conversation

@guimard

@guimard guimard commented Jun 20, 2026

Copy link
Copy Markdown
Member

Why

The Dependabot vulnerabilities all came from the test toolchain — the transitive chain:

babel-jestbabel-plugin-istanbul@istanbuljs/load-nyc-config → old js-yaml

Migrating to vitest removes the entire babel/istanbul/jest chain. Vitest runs TypeScript/ESM natively, so no babel transform is needed.

Result

  • npm audit: 0 vulnerabilities (was 19 moderate before)
  • All 36 tests pass on Node 22 and 24
  • tsc --noEmit and eslint remain clean
  • Faster (~0.3s vs ~1.6s)

Changes

  • Remove jest, ts-jest, @types/jest; add vitest 4 + @vitest/coverage-v8
  • Delete jest.config.js, add vitest.config.ts (globals, node env, v8 coverage)
  • package.json scripts: testvitest run; add test:watch and test:coverage
  • test/tsconfig.json: replace jest globals with vitest/globals + node types
  • Test files unchanged — only standard describe/it/test/expect/beforeAll/afterAll are used (no jest.fn/mock/spyOn).

Node support

Vitest 4 is rolldown-based and needs Node 20.12+/22+ (it pulls no esbuild/vite, which is why npm audit stays at 0 — vitest 3 would reintroduce a low-severity esbuild advisory). Per project policy only Node 22/24 are needed, so:

  • CI test matrix: [22, 24] (was [18, 20, 22])
  • engines.node: >=22.0.0 (was >=18.0.0)
  • Prebuilds built on Node 22; Dockerfile.arm64node:22-bookworm

No changes to the published runtime (dependencies unchanged; only devDeps + engines).

guimard added 2 commits June 20, 2026 13:25
Replaces jest/ts-jest/@types/jest with vitest + @vitest/coverage-v8.

This removes the entire babel-jest -> babel-plugin-istanbul ->
@istanbuljs/load-nyc-config -> js-yaml transitive chain that was the
source of the dependency vulnerabilities (npm audit: 0 vulnerabilities
after the change, vs 19 before). Vitest handles TypeScript/ESM natively
via esbuild, so no babel toolchain is needed.

- Remove jest.config.js, add vitest.config.ts (globals, node env, v8 coverage)
- Scripts: test -> 'vitest run', add test:watch and test:coverage
- test/tsconfig.json: use vitest/globals + node types
- Test files unchanged: only standard describe/it/test/expect/beforeAll/
  afterAll are used (no jest.fn/mock/spyOn), so they run as-is.

All 36 tests pass; tsc --noEmit and eslint remain clean.
Per project support policy, only Node 22 and 24 are required, so:
- CI test matrix: [22, 24] (was [18, 20, 22])
- engines.node: >=22.0.0 (was >=18.0.0)
- build prebuilds on Node 22; Dockerfile.arm64 on node:22-bookworm

Dropping Node <22 lets us use vitest 4 (rolldown-based), which needs Node
20.12+/22+ but pulls no esbuild/vite, keeping 'npm audit' at 0 vulnerabilities.
All 36 tests pass; tsc and eslint clean.
@guimard
guimard merged commit 232e774 into master Jun 20, 2026
5 checks passed
@guimard
guimard deleted the chore/migrate-jest-to-vitest branch June 20, 2026 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant