Migrate Jest to vitest#1745
Conversation
Vitest is ESM-native and transforms TypeScript itself, removing the need for ts-jest and the --experimental-vm-modules workaround. Spec files now import the test API explicitly. A new test:coverage script runs coverage with the thresholds carried over from the Jest config; CI uses it instead of "npm test --coverage", which never actually forwarded the flag to Jest.
The v8 provider counts branches that Jest's istanbul instrumentation did not (and the old CI invocation never enforced the thresholds). Add a test for Insights responses without an anonymizer record, and mark two defensive branches unreachable from the public API with v8 ignore hints.
Each suite gets a minimal local Vitest config; without one, Vitest resolves the root config and its src-only include pattern. Jest globals are no longer referenced anywhere, so they leave the ESLint config.
ts-jest ran in transpile-only mode, so spec files were never fully type-checked, and the root tsconfig excludes them. Repurpose tsconfig.test.json (previously only used by ts-jest) for a dedicated tsc pass in the lint script. This surfaced a reference to the DOM-only RequestInfo type, now derived from fetch itself.
The assertions were weakened because Jest's --experimental-vm-modules created errors in a different realm, breaking instanceof. Vitest runs native ESM without VM sandboxing, so the workaround is no longer needed.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe repository’s test tooling is migrated from Jest to Vitest, including root and end-to-end configurations, scripts, CI workflows, TypeScript settings, ESLint globals, test imports, coverage directives, and web client test assertions. ChangesVitest migration
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The Vitest docs recommend this form so the hints survive transforms that strip comments. The current Oxc-based transform keeps them either way, but the documented behavior is comment stripping, so a future toolchain change could silently invalidate plain hints.
migrates jest to vitest
Summary by CodeRabbit