chore: migrate test runner from jest to vitest - #3
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The Dependabot vulnerabilities all came from the test toolchain — the transitive chain:
babel-jest→babel-plugin-istanbul→@istanbuljs/load-nyc-config→ oldjs-yamlMigrating 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)tsc --noEmitandeslintremain cleanChanges
jest,ts-jest,@types/jest; addvitest4 +@vitest/coverage-v8jest.config.js, addvitest.config.ts(globals, node env, v8 coverage)package.jsonscripts:test→vitest run; addtest:watchandtest:coveragetest/tsconfig.json: replace jest globals withvitest/globals+nodetypesdescribe/it/test/expect/beforeAll/afterAllare used (nojest.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 auditstays at 0 — vitest 3 would reintroduce a low-severity esbuild advisory). Per project policy only Node 22/24 are needed, so:[22, 24](was[18, 20, 22])engines.node:>=22.0.0(was>=18.0.0)Dockerfile.arm64→node:22-bookwormNo changes to the published runtime (
dependenciesunchanged; only devDeps + engines).