Skip to content

Conversation

@CarlosGamero
Copy link
Collaborator

@CarlosGamero CarlosGamero commented Jan 12, 2026

Summary by CodeRabbit

  • Chores
    • Updated test tooling to a newer major release across the repo.
    • Standardized mock lifecycle to reset between tests for more consistent runs.
    • Adjusted several test coverage thresholds downward.
    • Restricted test parallelism/workers in some packages to reduce flakiness and resource contention.

✏️ Tip: You can customize this high-level summary in your review settings.

@CarlosGamero CarlosGamero self-assigned this Jan 12, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 12, 2026

📝 Walkthrough

Walkthrough

Upgrade Vitest to 4.0.15 across many packages, replace restoreMocks: true with mockReset: true, replace single-thread pool options with maxWorkers: 1 in configs, and adjust various coverage thresholds.

Changes

Cohort / File(s) Summary
Vitest Version Bumps
examples/sns-sqs/package.json, packages/amqp/package.json, packages/core/package.json, packages/gcp-pubsub/package.json, packages/gcs-payload-store/package.json, packages/kafka/package.json, packages/metrics/package.json, packages/outbox-core/package.json, packages/redis-message-deduplication-store/package.json, packages/s3-payload-store/package.json, packages/schemas/package.json, packages/sns/package.json, packages/sqs/package.json
Bumped devDependencies vitest and @vitest/coverage-v8 to ^4.0.15.
Mock Configuration Updates
packages/amqp/vitest.config.ts, packages/core/vitest.config.ts, packages/gcp-pubsub/vitest.config.ts, packages/gcs-payload-store/vitest.config.ts, packages/kafka/vitest.config.ts, packages/metrics/vitest.config.ts, packages/outbox-core/vitest.config.ts, packages/redis-message-deduplication-store/vitest.config.mts, packages/s3-payload-store/vitest.config.ts, packages/schemas/vitest.config.ts, packages/sns/vitest.config.ts, packages/sqs/vitest.config.ts, examples/sns-sqs/vitest.config.ts
Replaced test.restoreMocks: true with test.mockReset: true (Vitest v4 API change).
Worker / Pool Changes
packages/gcp-pubsub/vitest.config.ts, packages/gcs-payload-store/vitest.config.ts, packages/kafka/vitest.config.ts, packages/sns/vitest.config.ts, packages/sqs/vitest.config.ts, examples/sns-sqs/vitest.config.ts
Removed poolOptions / threads.singleThread and added maxWorkers: 1 or set pool: 'threads' where applicable to control workers.
Coverage Threshold Adjustments
packages/core/vitest.config.ts, packages/gcp-pubsub/vitest.config.ts, packages/gcs-payload-store/vitest.config.ts, packages/kafka/vitest.config.ts, packages/outbox-core/vitest.config.ts, packages/s3-payload-store/vitest.config.ts, packages/schemas/vitest.config.ts, packages/sns/vitest.config.ts, packages/sqs/vitest.config.ts
Lowered or otherwise adjusted coverage thresholds (functions, branches, lines, statements) in multiple package Vitest configs.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested reviewers

  • kibertoad
  • kjamrog

Poem

🐰 Vitest hopped up, shiny and spry,
Mocks reset now — watch tests fly,
One worker hops where threads once ran,
Coverage trimmed to fit the plan,
A tiny rabbit cheers: "Tests, go try!"

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore: Vitest 4' accurately reflects the main changes in the pull request—a comprehensive upgrade of Vitest from version 3 to version 4 across all package configurations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f8fbdc4 and 64b1d80.

📒 Files selected for processing (1)
  • examples/sns-sqs/vitest.config.ts
⏰ 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)
  • GitHub Check: general (22.x, @message-queue-toolkit/gcp-pubsub) / build
  • GitHub Check: general (24.x, @message-queue-toolkit/gcs-payload-store) / build
  • GitHub Check: general (20.x, @message-queue-toolkit/amqp) / build
  • GitHub Check: general (22.x, @message-queue-toolkit/s3-payload-store) / build
  • GitHub Check: general (24.x, @message-queue-toolkit/sqs) / build
  • GitHub Check: general (22.x, @message-queue-toolkit/schemas) / build
  • GitHub Check: general (22.x, @message-queue-toolkit/core) / build
  • GitHub Check: general (22.x, @message-queue-toolkit/amqp) / build
  • GitHub Check: general (22.x, @message-queue-toolkit/sqs) / build
  • GitHub Check: general (20.x, @message-queue-toolkit/gcp-pubsub) / build
  • GitHub Check: general (22.x, @message-queue-toolkit/gcs-payload-store) / build
  • GitHub Check: general (24.x, @message-queue-toolkit/gcp-pubsub) / build
  • GitHub Check: general (20.x, @message-queue-toolkit/sqs) / build
  • GitHub Check: general (24.x, @message-queue-toolkit/amqp) / build
  • GitHub Check: general (24.x, @message-queue-toolkit/redis-message-deduplication-store) / build
  • GitHub Check: general (24.x, @message-queue-toolkit/sns) / build
  • GitHub Check: general (20.x, @message-queue-toolkit/sns) / build
  • GitHub Check: general (22.x, @message-queue-toolkit/sns) / build
  • GitHub Check: kafka (24.x) / build
  • GitHub Check: kafka (22.x) / build
🔇 Additional comments (2)
examples/sns-sqs/vitest.config.ts (2)

10-10: LGTM!

Using maxWorkers: 1 is an appropriate replacement for the legacy poolOptions: { threads: { singleThread: true } } configuration to enforce sequential test execution.


8-8: Confirm the intended behavior change from restoreMocks to mockReset.

The semantic difference identified is real: mockReset (clears call history and replaces mocks with empty functions) and restoreMocks (clears call history and restores original implementations for vi.spyOn spies) serve different purposes in Vitest 4. In Vitest 4, restoreMocks no longer affects automocks and only restores spies created with vi.spyOn.

Verify that replacing restoreMocks: true with only mockReset: true is intentional. If tests use vi.spyOn() to spy on real implementations, this change could break test isolation since mockReset will not restore original implementations.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@CarlosGamero CarlosGamero marked this pull request as ready for review January 12, 2026 16:39
Copy link

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 8cf41e0 and f8fbdc4.

📒 Files selected for processing (24)
  • examples/sns-sqs/package.json
  • packages/amqp/vitest.config.ts
  • packages/core/package.json
  • packages/core/vitest.config.ts
  • packages/gcp-pubsub/package.json
  • packages/gcp-pubsub/vitest.config.ts
  • packages/gcs-payload-store/package.json
  • packages/gcs-payload-store/vitest.config.ts
  • packages/kafka/package.json
  • packages/kafka/vitest.config.ts
  • packages/metrics/package.json
  • packages/metrics/vitest.config.ts
  • packages/outbox-core/package.json
  • packages/outbox-core/vitest.config.ts
  • packages/redis-message-deduplication-store/package.json
  • packages/redis-message-deduplication-store/vitest.config.mts
  • packages/s3-payload-store/package.json
  • packages/s3-payload-store/vitest.config.ts
  • packages/schemas/package.json
  • packages/schemas/vitest.config.ts
  • packages/sns/package.json
  • packages/sns/vitest.config.ts
  • packages/sqs/package.json
  • packages/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 vitest and @vitest/coverage-v8 is complete. The vitest.config.ts has been correctly updated with v4 configuration patterns: mockReset: true and pool: 'threads' are in place, with no deprecated v3 settings remaining.

packages/redis-message-deduplication-store/vitest.config.mts (1)

8-8: The characterization of mockReset and restoreMocks in the original comment is reversed.

mockReset calls vi.resetAllMocks() which clears call history and resets mock implementations to empty functions, whereas restoreMocks calls vi.restoreAllMocks() which restores spies created with vi.spyOn() back to their original implementations.

This is a behavioral change worth verifying during testing. Additionally, note that in Vitest 4, restoreMocks no longer affects automocked modules—it only restores spies created explicitly with vi.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 vitest and @vitest/coverage-v8 are upgraded to matching ^4.0.15 versions, 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 vitest and @vitest/coverage-v8 are correctly aligned at ^4.0.15. The vitest.config.ts has been appropriately updated for Vitest 4.0 compatibility: it uses maxWorkers: 1 (replacing the deprecated singleThread from 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 vitest and @vitest/coverage-v8 maintains 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 to mockReset in Vitest 4.

In Vitest 4, restoreMocks behavior changed to only restore vi.spyOn spies. The migration to mockReset: true is the documented approach if tests previously relied on restoreMocks to reset automocked functions and vi.fn() implementations between tests. Note that Vitest 4's mockReset restores the original mock implementation (not an empty function), so ensure tests don't depend on mocks returning undefined after 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 mockReset option 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 poolOptions configuration is gone in Vitest 4, and options are now set at the top level. maxThreads and maxForks have been consolidated into maxWorkers. The singleThread option is removed; the new way is maxWorkers: 1.

The switch from restoreMocks to mockReset is appropriate since vi.restoreAllMocks no longer resets the state of spies and only restores spies created manually with vi.spyOn, automocks are no longer affected by this function (this also affects the config option restoreMocks).

packages/metrics/vitest.config.ts (1)

8-8: LGTM!

The switch from restoreMocks to mockReset is the correct migration path for Vitest 4.

packages/gcp-pubsub/vitest.config.ts (1)

8-10: LGTM!

The mockReset and maxWorkers: 1 changes 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 mockReset configuration is correct for Vitest 4.


17-17: Significant coverage threshold reduction warrants verification.

The branches threshold 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 mockReset change 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 mockReset configuration is correct for Vitest 4.


16-16: Verify the functions coverage threshold reduction.

The functions threshold dropped from 60 to 40. While less drastic than the outbox-core change, 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 of mockReset vs restoreMocks is 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 state

The change from restoreMocks to mockReset is 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 mockReset and maxWorkers: 1 changes are consistent with the other packages. Same note applies regarding the mockReset vs restoreMocks behavioral 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 vitest and @vitest/coverage-v8 are correctly updated to the same version ^4.0.15, ensuring compatibility. The necessary configuration settings (mockReset: true, maxWorkers: 1) are correctly applied in packages/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-v8 in sync is correct practice. The packages/schemas/vitest.config.ts has already been properly updated for Vitest 4 compatibility — no deprecated pool options (singleThread/singleFork) are present, and mockReset: true reflects the Vitest 4 configuration pattern.

@CarlosGamero CarlosGamero merged commit c309316 into main Jan 13, 2026
38 checks passed
@CarlosGamero CarlosGamero deleted the chore/vitest_4 branch January 13, 2026 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants