-
Notifications
You must be signed in to change notification settings - Fork 7
chore: Vitest 4 #394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Vitest 4 #394
Conversation
📝 WalkthroughWalkthroughUpgrade Vitest to 4.0.15 across many packages, replace Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
🔇 Additional comments (2)
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In @examples/sns-sqs/package.json:
- Around line 34-36: vitest.config.ts uses Vitest 3 options that break under
Vitest 4: replace restoreMocks with mockReset, remove the nested poolOptions
structure and instead set pool: 'threads' and singleThread: true at the
top-level test config, and ensure the test block matches the updated shape
(globals, watch, mockReset, pool, singleThread, coverage with provider 'v8' and
the provided include/exclude/thresholds). Update the configuration keys in
vitest.config.ts accordingly and remove any poolOptions usage so the file is
compatible with vitest ^4.0.15.
In @packages/gcp-pubsub/package.json:
- Line 48: The package bump to Vitest 4.0 requires updating the Vitest config
and test helpers: replace any removed poolOptions usage with the new maxWorkers
and isolate settings (e.g., set maxWorkers: 1 and isolate: false where
singleThread was intended), update any restoreMocks expectations and calls
(adjust usages of restoreMocks and calls to vi.restoreAllMocks since automock
reset behavior changed), review and adapt the v8 coverage configuration to the
new AST-based remapping (check coverage.v8 settings and thresholds), and verify
reporter/browser mode keys match Vitest 4 naming; locate these changes in your
vitest.config.* and any test setup files referenced by package.json scripts and
update config keys and test helper behavior per the Vitest migration guide.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (24)
examples/sns-sqs/package.jsonpackages/amqp/vitest.config.tspackages/core/package.jsonpackages/core/vitest.config.tspackages/gcp-pubsub/package.jsonpackages/gcp-pubsub/vitest.config.tspackages/gcs-payload-store/package.jsonpackages/gcs-payload-store/vitest.config.tspackages/kafka/package.jsonpackages/kafka/vitest.config.tspackages/metrics/package.jsonpackages/metrics/vitest.config.tspackages/outbox-core/package.jsonpackages/outbox-core/vitest.config.tspackages/redis-message-deduplication-store/package.jsonpackages/redis-message-deduplication-store/vitest.config.mtspackages/s3-payload-store/package.jsonpackages/s3-payload-store/vitest.config.tspackages/schemas/package.jsonpackages/schemas/vitest.config.tspackages/sns/package.jsonpackages/sns/vitest.config.tspackages/sqs/package.jsonpackages/sqs/vitest.config.ts
🔇 Additional comments (27)
packages/s3-payload-store/package.json (1)
45-48: Vitest 4.x upgrade is properly configured.The upgrade from ^3.2.4 to ^4.0.15 for both
vitestand@vitest/coverage-v8is complete. Thevitest.config.tshas been correctly updated with v4 configuration patterns:mockReset: trueandpool: 'threads'are in place, with no deprecated v3 settings remaining.packages/redis-message-deduplication-store/vitest.config.mts (1)
8-8: The characterization ofmockResetandrestoreMocksin the original comment is reversed.
mockResetcallsvi.resetAllMocks()which clears call history and resets mock implementations to empty functions, whereasrestoreMockscallsvi.restoreAllMocks()which restores spies created withvi.spyOn()back to their original implementations.This is a behavioral change worth verifying during testing. Additionally, note that in Vitest 4,
restoreMocksno longer affects automocked modules—it only restores spies created explicitly withvi.spyOn().Likely an incorrect or invalid review comment.
packages/redis-message-deduplication-store/package.json (1)
44-47: LGTM! Vitest 4 devDependency upgrades look correct.Both
vitestand@vitest/coverage-v8are upgraded to matching^4.0.15versions, which is good practice for ensuring compatibility between the test runner and coverage tooling.packages/gcs-payload-store/package.json (1)
41-44: Vitest 4.x upgrade is properly configured.Both
vitestand@vitest/coverage-v8are correctly aligned at ^4.0.15. The vitest.config.ts has been appropriately updated for Vitest 4.0 compatibility: it usesmaxWorkers: 1(replacing the deprecatedsingleThreadfrom v3),mockReset: true, and contains no deprecated configuration options. The upgrade is complete and correct.packages/metrics/package.json (1)
41-44: Vitest major version upgrade is consistent and versions are valid.The bump to 4.0.15 for both
vitestand@vitest/coverage-v8maintains ecosystem compatibility (important for the coverage plugin). Both versions exist on npm.Note: The caret range (^4.0.15) allows patch and minor updates. Latest versions are 4.0.17; consider whether pinning to the latest release is preferred.
packages/outbox-core/package.json (1)
44-47: LGTM!The Vitest tooling upgrade to ^4.0.15 is consistent with the other packages in this PR.
packages/core/vitest.config.ts (2)
20-21: Significant reduction in coverage thresholds.The coverage thresholds have been substantially lowered:
functions: 80% → 51% (-29%)branches: 85% → 48% (-37%)Was this intentional due to Vitest 4 coverage calculation differences, or is there an underlying coverage gap that should be addressed separately?
8-8: Verify test expectations after switching tomockResetin Vitest 4.In Vitest 4,
restoreMocksbehavior changed to only restorevi.spyOnspies. The migration tomockReset: trueis the documented approach if tests previously relied onrestoreMocksto reset automocked functions andvi.fn()implementations between tests. Note that Vitest 4'smockResetrestores the original mock implementation (not an empty function), so ensure tests don't depend on mocks returningundefinedafter reset.packages/core/package.json (1)
46-51: LGTM!The Vitest tooling upgrade to ^4.0.15 is consistent with the coordinated upgrade across all packages.
packages/sqs/package.json (1)
50-56: LGTM!The Vitest tooling upgrade to ^4.0.15 aligns with the monorepo-wide upgrade.
packages/amqp/vitest.config.ts (1)
8-8: Consistent with the Vitest 4 migration.The
mockResetoption is applied consistently with other packages in this PR. Note that this package maintains its existing high coverage thresholds, which is good.packages/sns/vitest.config.ts (1)
8-10: LGTM! Configuration changes align with Vitest 4 migration.The
poolOptionsconfiguration is gone in Vitest 4, and options are now set at the top level.maxThreadsandmaxForkshave been consolidated intomaxWorkers. ThesingleThreadoption is removed; the new way ismaxWorkers: 1.The switch from
restoreMockstomockResetis appropriate sincevi.restoreAllMocksno longer resets the state of spies and only restores spies created manually withvi.spyOn, automocks are no longer affected by this function (this also affects the config optionrestoreMocks).packages/metrics/vitest.config.ts (1)
8-8: LGTM!The switch from
restoreMockstomockResetis the correct migration path for Vitest 4.packages/gcp-pubsub/vitest.config.ts (1)
8-10: LGTM!The
mockResetandmaxWorkers: 1changes correctly follow the Vitest 4 migration pattern.packages/sns/package.json (1)
55-55: LGTM!The Vitest and coverage package versions are aligned at
^4.0.15.Also applies to: 61-61
packages/outbox-core/vitest.config.ts (2)
8-8: LGTM!The
mockResetconfiguration is correct for Vitest 4.
17-17: Significant coverage threshold reduction warrants verification.The
branchesthreshold dropped from 91 to 50, a 41 percentage point reduction. This is substantially larger than the minor adjustments in other packages (e.g., sns: 90→87, gcp-pubsub: 92→88).Please verify this is intentional and not masking reduced test coverage. If Vitest 4's coverage calculation changed significantly for this package, consider adding a comment explaining the discrepancy.
packages/s3-payload-store/vitest.config.ts (1)
8-8: LGTM!The
mockResetchange and minor branches threshold adjustment (91→90) are appropriate for the Vitest 4 migration.Also applies to: 17-17
packages/schemas/vitest.config.ts (2)
8-8: LGTM!The
mockResetconfiguration is correct for Vitest 4.
16-16: Verify the functions coverage threshold reduction.The
functionsthreshold dropped from 60 to 40. While less drastic than theoutbox-corechange, this is still a notable 20 percentage point reduction. Please confirm this aligns with actual coverage and isn't masking a gap.packages/kafka/vitest.config.ts (2)
15-20: Coverage thresholds lowered.The coverage thresholds have been reduced (functions: 97→91, branches: 93→85). If this is due to Vitest 4's changed coverage calculation, this is acceptable. Otherwise, consider addressing any coverage gaps before merging.
8-10: Review comment characterization ofmockResetvsrestoreMocksis technically incorrect.In Vitest 4, the actual behaviors differ from what was stated:
mockReset: true(vi.resetAllMocks) clears call history AND resets mock implementations to blank functions (returns undefined)restoreMocks: true(vi.restoreAllMocks) only restores original implementations for vi.spyOn spies and does NOT clear call history or reset call stateThe change from
restoreMockstomockResetis therefore more aggressive: it will now clear call history and reset all mock implementations to blank functions, rather than selectively restoring vi.spyOn spies. If tests relied on call history persisting between test cases or on vi.spyOn spies being restored to original implementations, they may behave differently. Verify this change is intentional for the Vitest 4 migration.Likely an incorrect or invalid review comment.
packages/gcs-payload-store/vitest.config.ts (2)
8-10: Configuration changes align with Vitest 4 migration.The
mockResetandmaxWorkers: 1changes are consistent with the other packages. Same note applies regarding themockResetvsrestoreMocksbehavioral difference.
15-20: This is a newly created vitest.config.ts file, not a modification of existing configuration.The git history shows this file was created fresh in the "coverage fix" commit (f8fbdc4), indicated by "new file mode 100644". There is no prior threshold value to compare against—the 71% branches threshold is the initial configuration for this package's test coverage, not a regression. The concern about a drop from 90% is invalid since no previous configuration existed.
Likely an incorrect or invalid review comment.
packages/sqs/vitest.config.ts (1)
4-23: LGTM!The configuration changes are consistent with the Vitest 4 migration pattern across other packages. The coverage threshold adjustments are minimal (-1% for lines, functions, and statements), which is reasonable for a major version upgrade.
packages/kafka/package.json (1)
70-75: Vitest major version upgrade is properly configured.Both
vitestand@vitest/coverage-v8are correctly updated to the same version^4.0.15, ensuring compatibility. The necessary configuration settings (mockReset: true,maxWorkers: 1) are correctly applied inpackages/kafka/vitest.config.ts. No breaking changes are present in Vitest 4.0.15.packages/schemas/package.json (1)
36-39: LGTM! Vitest 4 upgrade with config already migrated.Vitest 4.0.15 is a valid version, and keeping
@vitest/coverage-v8in sync is correct practice. Thepackages/schemas/vitest.config.tshas already been properly updated for Vitest 4 compatibility — no deprecated pool options (singleThread/singleFork) are present, andmockReset: truereflects the Vitest 4 configuration pattern.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.