test: enable clearMocks for shared Jest config#2591
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdded Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
Greptile SummaryThis PR adds
Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
Base["jest.config.base.js\n(clearMocks: true ✅ NEW)"]
ROR["packages/react-on-rails\njest.config.js\n(...rootConfig)"]
RORPRO["packages/react-on-rails-pro\njest.config.js\n(...rootConfig)"]
CRORA["packages/create-react-on-rails-app\njest.config.js\n(standalone — not affected)"]
Base -->|inherits| ROR
Base -->|inherits| RORPRO
CRORA -.->|already has clearMocks + resetMocks| CRORA
Last reviewed commit: ffe094c |
|
Good, low-risk improvement for test isolation. One thing to flag. Inaccurate comment / PR description The inline comment (line 42) and the PR description both say
Is Yes -- Consistency note
Summary The change itself is correct and beneficial. The only fix needed is the comment text so it accurately reflects what |
Review: Enable
|
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Overall: LGTM with one minor suggestion. The change is clean, well-scoped, and low-risk. Adding clearMocks: true to the shared base config is the right conservative choice — it clears call history between tests without resetting mock implementations, so existing tests relying on persistent mockReturnValue or mockImplementation setups should not break. The comment accurately distinguishes clearMocks from resetMocks (a common source of confusion), and adding a regression test is a nice touch. One minor gap: the test only verifies that call history is cleared, but does not confirm that mock implementations are preserved — the key semantic difference between clearMocks and resetMocks. A third test asserting that a mockReturnValue set in one test still works in the next would make this a more complete spec. Not blocking — see inline comment for the specific suggestion. |
size-limit report 📦
|
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Overall: Good, focused change. Enabling clearMocks:true in the shared config prevents call-count and instance leakage between tests without risking breaks for tests that rely on mock return values. Concern: clearMocks vs resetMocks
The PR is intentionally conservative by stopping at If the existing test suites pass with Minor nit on the test The third test ("preserves mock implementations across tests") intentionally relies on Nothing blocking - the change is safe, well-documented, and the test clearly verifies the intended behaviour. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Config change (jest.config.base.js): Adding clearMocks: true to the shared base config is a solid improvement. The inline comment correctly documents the distinction from resetMocks. This belongs in the shared base so all packages inherit it automatically. Test file (clearMocksConfig.test.ts): Two issues worth addressing.
Suggestion: If keeping the test file, rewrite test 3 to set up its own implementation (a local mockReturnValue call or a beforeEach) so all three tests pass regardless of execution order. Alternatively, drop the test file and rely on the config comment plus Jest documentation. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Overall: Clean, low-risk improvement. Enabling clearMocks: true is a well-established Jest best practice for test isolation and the implementation is correct. What is good
Minor observations
No blocking issues. Safe to merge. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Overall: Clean, well-scoped change. Adding clearMocks: true to jest.config.base.js is the right call for improving test isolation. This is consistent with create-react-on-rails-app/jest.config.js, which already independently sets clearMocks: true (and resetMocks: true). Positive aspects:
Observations:
No security or performance implications. No issues found with existing tests. |
ReviewThe change is clean and well-scoped. A few observations: jest.config.base.js Scope of impact Test file (clearMocksConfig.test.ts) Overall this is a good, low-risk improvement to test isolation. LGTM. |
Code ReviewThis is a clean, well-scoped PR that improves test isolation across the monorepo. Adds clearMocks: true to the shared jest.config.base.js (resetting mock call history between tests without touching implementations) and a focused regression test to verify the semantics. Config change: Minimal, well-commented, and correctly distinguishes clearMocks from resetMocks. Standard Jest best practice for a shared monorepo config. Test file: The three-test sequence correctly validates: (1) calls are recorded, (2) call history is cleared between tests, (3) implementations persist. Module-level comment explaining the intentional shared state is a nice touch. Potential downstream impact: clearMocks: true could surface previously hidden cross-test mock state dependencies in packages inheriting this config, which the PR description correctly frames as the intended benefit. Overall a straightforward, low-risk improvement. LGTM. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Overall: A clean, low-risk improvement to test isolation. The config change is correct and the new test file effectively validates the behavior. jest.config.base.js The addition of
clearMocksConfig.test.ts Two inline comments posted — a robustness note about the intentional order-dependency and a suggestion to document the |
Review: Enable
|
…k cleanup (#2596) ## Summary - Added missing changelog entries for PRs #2439, #2477, #2554 - Stamped version header for 16.4.0.rc.9 (collapsed rc.8 into rc.9) - **Fixed rake task bug**: `collapse_prerelease_sections` removed section headers but left behind orphaned compare links at the bottom of CHANGELOG.md. Added `cleanup_collapsed_prerelease_links` to remove these links and update `[unreleased]` to compare from the last stable version. ## Changes 1. **CHANGELOG.md**: New entries + rc.9 stamp + removed orphaned `[16.4.0.rc.8]` link 2. **update_changelog.rake**: Added `cleanup_collapsed_prerelease_links` function, called from `prepare_changelog_for_auto_version` 3. **update_changelog_rake_helpers_spec.rb**: 3 new tests covering link cleanup (multi-prerelease chain, single prerelease, no prereleases) ## Skipped PRs (not user-visible) - #2593 — test only (lock instrumentation) - #2591 — test only (Jest clearMocks) - #2588 — internal refactoring (Thor shell output) - #2584 — docs restructuring - #2587 — internal tooling (release script) - #2589 — docs fix (JWT claim name) - #2586 — docs/CI (dead link removal) ## Test plan - [x] All 13 rake helper tests pass (3 new) - [ ] CI passes - [ ] After merge, run `rake release` to publish 16.4.0.rc.9 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Fixed bin/setup failing in pnpm workspace member directories. * **New Features** * Added host configuration option for the Node Renderer Fastify worker. * **Improvements / Changed** * Automatic installation of react_on_rails_pro enabled for --rsc/--pro flags. * Clarified Pro-installation signaling related to immediate hydration warnings. * Updated changelog to include RC9 entries and ensure Unreleased links point to the correct base. * **Documentation** * Added startup warning and remediation guidance for unsafe compression middleware callbacks. * **Tests** * Added tests covering changelog prerelease-link cleanup behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 4.6 <[email protected]>
…k cleanup (#2596) ## Summary - Added missing changelog entries for PRs #2439, #2477, #2554 - Stamped version header for 16.4.0.rc.9 (collapsed rc.8 into rc.9) - **Fixed rake task bug**: `collapse_prerelease_sections` removed section headers but left behind orphaned compare links at the bottom of CHANGELOG.md. Added `cleanup_collapsed_prerelease_links` to remove these links and update `[unreleased]` to compare from the last stable version. ## Changes 1. **CHANGELOG.md**: New entries + rc.9 stamp + removed orphaned `[16.4.0.rc.8]` link 2. **update_changelog.rake**: Added `cleanup_collapsed_prerelease_links` function, called from `prepare_changelog_for_auto_version` 3. **update_changelog_rake_helpers_spec.rb**: 3 new tests covering link cleanup (multi-prerelease chain, single prerelease, no prereleases) ## Skipped PRs (not user-visible) - #2593 — test only (lock instrumentation) - #2591 — test only (Jest clearMocks) - #2588 — internal refactoring (Thor shell output) - #2584 — docs restructuring - #2587 — internal tooling (release script) - #2589 — docs fix (JWT claim name) - #2586 — docs/CI (dead link removal) ## Test plan - [x] All 13 rake helper tests pass (3 new) - [ ] CI passes - [ ] After merge, run `rake release` to publish 16.4.0.rc.9 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Fixed bin/setup failing in pnpm workspace member directories. * **New Features** * Added host configuration option for the Node Renderer Fastify worker. * **Improvements / Changed** * Automatic installation of react_on_rails_pro enabled for --rsc/--pro flags. * Clarified Pro-installation signaling related to immediate hydration warnings. * Updated changelog to include RC9 entries and ensure Unreleased links point to the correct base. * **Documentation** * Added startup warning and remediation guidance for unsafe compression middleware callbacks. * **Tests** * Added tests covering changelog prerelease-link cleanup behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 4.6 <[email protected]>
…k cleanup (#2596) ## Summary - Added missing changelog entries for PRs #2439, #2477, #2554 - Stamped version header for 16.4.0.rc.9 (collapsed rc.8 into rc.9) - **Fixed rake task bug**: `collapse_prerelease_sections` removed section headers but left behind orphaned compare links at the bottom of CHANGELOG.md. Added `cleanup_collapsed_prerelease_links` to remove these links and update `[unreleased]` to compare from the last stable version. ## Changes 1. **CHANGELOG.md**: New entries + rc.9 stamp + removed orphaned `[16.4.0.rc.8]` link 2. **update_changelog.rake**: Added `cleanup_collapsed_prerelease_links` function, called from `prepare_changelog_for_auto_version` 3. **update_changelog_rake_helpers_spec.rb**: 3 new tests covering link cleanup (multi-prerelease chain, single prerelease, no prereleases) ## Skipped PRs (not user-visible) - #2593 — test only (lock instrumentation) - #2591 — test only (Jest clearMocks) - #2588 — internal refactoring (Thor shell output) - #2584 — docs restructuring - #2587 — internal tooling (release script) - #2589 — docs fix (JWT claim name) - #2586 — docs/CI (dead link removal) ## Test plan - [x] All 13 rake helper tests pass (3 new) - [ ] CI passes - [ ] After merge, run `rake release` to publish 16.4.0.rc.9 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Fixed bin/setup failing in pnpm workspace member directories. * **New Features** * Added host configuration option for the Node Renderer Fastify worker. * **Improvements / Changed** * Automatic installation of react_on_rails_pro enabled for --rsc/--pro flags. * Clarified Pro-installation signaling related to immediate hydration warnings. * Updated changelog to include RC9 entries and ensure Unreleased links point to the correct base. * **Documentation** * Added startup warning and remediation guidance for unsafe compression middleware callbacks. * **Tests** * Added tests covering changelog prerelease-link cleanup behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 4.6 <[email protected]>
Summary
clearMocks: trueinjest.config.base.jsFixes #2500
Test Plan
pnpm run eslint jest.config.base.jspnpm --filter react-on-rails test -- --runInBandpnpm --filter react-on-rails-pro test:non-rsc -- --runInBandNote
Low Risk
Low risk configuration change that only affects Jest test isolation by resetting mocks between tests; it may surface previously hidden test interdependencies.
Overview
Enables Jest
clearMocks: trueinjest.config.base.js, so packages inheriting the shared config automatically clear mock call history and implementations between tests for more consistent test isolation.Written by Cursor Bugbot for commit ffe094c. Configure here.
Summary by CodeRabbit