Migrate Jest to vitest#1921
Conversation
Replace jest, ts-jest, and @types/jest with vitest and @vitest/coverage-v8. Specs now import test APIs explicitly from 'vitest' instead of relying on injected globals. The v8 coverage provider surfaced gaps the previous setup missed (CI never passed --coverage through npm). Add tests for the legacy numeric timeout argument, non-Error fetch rejections, orders without a referrer URI, and transaction reports with no identifier fields. Annotate two defensive email-normalization branches that validation makes unreachable.
Spec files were excluded from tsc and ts-jest ran in transpile-only mode, so they were never type-checked. Run tsc against tsconfig.test.json in the lint script and fix the errors it surfaced: the specs referenced RequestInfo, which @types/node does not declare globally.
npm swallowed the --coverage flag in 'npm test --coverage', so the coverage thresholds were never checked in CI. Use the test:coverage script, which runs Vitest with coverage enabled.
Both e2e packages now use Vitest, which handles TypeScript directly, so the ts package drops ts-jest and @types/jest. Each package gets a local vitest.config to anchor its test root; otherwise Vitest walks up and uses the repository config. The CI steps no longer need the experimental-vm-modules flag, and the Jest globals carve-out is removed from the ESLint config.
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.
|
Warning Review limit reached
Next review available in: 59 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe project’s test tooling, CI workflow, documentation, end-to-end tests, and source specs migrate from Jest to Vitest. Coverage configuration is added, and several constructor and WebServiceClient behaviors receive additional test coverage. ChangesVitest migration
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/request/email.ts`:
- Around line 385-387: Update both V8 ignore sites in the email validation logic
around localPart to use the exact directive form `/* v8 ignore else -- `@preserve`
*/`, preserving the existing branch exclusions through esbuild.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: dbe23dda-26ad-4163-9c6c-8eeffc51d528
⛔ Files ignored due to path filters (3)
e2e/js/package-lock.jsonis excluded by!**/package-lock.jsone2e/ts/package-lock.jsonis excluded by!**/package-lock.jsonpackage-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (34)
.github/workflows/test.ymlCLAUDE.mde2e/js/index.spec.jse2e/js/package.jsone2e/js/vitest.config.jse2e/ts/index.spec.tse2e/ts/jest.config.jse2e/ts/package.jsone2e/ts/tsconfig.jsone2e/ts/vitest.config.tseslint.config.mjsjest.config.jspackage.jsonsrc/errors.spec.tssrc/request/account.spec.tssrc/request/billing.spec.tssrc/request/credit-card.spec.tssrc/request/custom-input.spec.tssrc/request/device.spec.tssrc/request/email.spec.tssrc/request/email.tssrc/request/event.spec.tssrc/request/location.spec.tssrc/request/order.spec.tssrc/request/payment.spec.tssrc/request/shipping.spec.tssrc/request/shopping-cart-item.spec.tssrc/request/transaction-report.spec.tssrc/request/transaction.spec.tssrc/response/models/insights.spec.tssrc/utils.spec.tssrc/webServiceClient.spec.tstsconfig.test.jsonvitest.config.ts
💤 Files with no reviewable changes (2)
- jest.config.js
- e2e/ts/jest.config.js
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