Skip to content

Test: keep React 19 coverage out of the React 18 lane - #4635

Merged
justin808 merged 1 commit into
mainfrom
fix/4565-react18-jest-selection
Jul 13, 2026
Merged

Test: keep React 19 coverage out of the React 18 lane#4635
justin808 merged 1 commit into
mainfrom
fix/4565-react18-jest-selection

Conversation

@justin808

@justin808 justin808 commented Jul 13, 2026

Copy link
Copy Markdown
Member

Why

The post-merge audit of #4622 reproduced one React 18 regression in the repaired Jest suite selection. registerServerComponent.client.test.jsx requires React.use, but the file had been moved into test:non-rsc, which is the package's React-18-compatible lane. With React 18.3.1 it failed during module loading before the test's Node guard could run.

This is a bounded closeout correction for #4622 and #4565.

What changed

  • Keep registerServerComponent.client.test.jsx out of test:non-rsc.
  • Run it in the existing React-19-gated client/streaming suite.
  • Extend the suite-selection checker so a declared React-19-only client test cannot drift back into test:non-rsc while still passing the ordinary orphan check.

Verification

  • Reproduced against a real React 18.3.1 + React DOM 18.3.1 install: of the five tests newly selected by Restore complete Pro Jest suite selection #4622, four passed and registerServerComponent.client.test.jsx failed at module load with React.use is not defined.
  • After the fix, React 18 test:non-rsc --listTests excludes that file and test:streaming exits through the React-19 version guard.
  • Full Pro package test command: 48/48 files selected; 35 non-RSC suites (454 tests), 6 client/streaming suites (140 tests), and 7 server-RSC suites (23 tests) passed.
  • Suite-selection unit tests: 3/3 passed.
  • TypeScript type-check, ESLint, Prettier, diff checks, and all 854 Pro license headers passed.
  • Independent bounded review: clean; 48 unique selections with no missing or duplicate-routed target.

No changelog entry: this only corrects maintainer test routing and does not change shipped runtime behavior.

Summary by CodeRabbit

  • Tests
    • Updated test suite selection so React 19-only client tests run with the streaming suite and are excluded from the non-RSC suite.
    • Added validation to detect incorrect test-suite assignments and prevent uncovered tests.

@justin808

Copy link
Copy Markdown
Member Author

+ci-status

@justin808

Copy link
Copy Markdown
Member Author

+ci-run-hosted

@github-actions

Copy link
Copy Markdown
Contributor

CI Status

Head SHA: c4cbb9aff888
Changed files: 3
Docs-only heuristic (matches ci-changes-detector metadata paths): no
ready-for-hosted-ci label: absent
force-full-hosted-ci label: absent
Current hosted-CI waiver: not present for this SHA

Only the required gate is active unless hosted CI is requested.

@github-actions github-actions Bot added the ready-for-hosted-ci Run optimized hosted GitHub CI for this PR label Jul 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hosted CI Requested

Triggered 9 workflow(s) for c4cbb9aff888.
Mode: optimized hosted CI (path-selected by script/ci-changes-detector).
Added ready-for-hosted-ci, so future commits will keep running optimized hosted CI until +ci-stop-hosted is used.

View progress in the Actions tab.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0d044af2-68cd-4527-b3fb-863762b1d3fe

📥 Commits

Reviewing files that changed from the base of the PR and between 670e1b3 and c4cbb9a.

📒 Files selected for processing (3)
  • packages/react-on-rails-pro/package.json
  • packages/react-on-rails-pro/scripts/check-jest-suite-selection.mjs
  • packages/react-on-rails-pro/scripts/check-jest-suite-selection.test.mjs

Walkthrough

The Jest scripts now route the React 19-only client test through the streaming suite instead of the non-RSC suite. Suite-selection validation separately tracks both suites and tests that invalid React 19 test selection raises an error.

Changes

Jest suite selection

Layer / File(s) Summary
Update Jest suite wiring
packages/react-on-rails-pro/package.json
The non-RSC Jest command excludes registerServerComponent tests, while the streaming command includes the React 19-only client test.
Validate React 19 test placement
packages/react-on-rails-pro/scripts/check-jest-suite-selection.mjs, packages/react-on-rails-pro/scripts/check-jest-suite-selection.test.mjs
Suite outputs are collected separately, React 19-only tests are rejected from test:non-rsc, and the rejection is covered by a test.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: keeping React 19-only test coverage out of the React 18 test lane.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/4565-react18-jest-selection

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.

@greptile-apps

greptile-apps Bot commented Jul 13, 2026

Copy link
Copy Markdown

Greptile Summary

This PR updates the Pro Jest suite routing for a React 19-only client test. The main changes are:

  • Excludes registerServerComponent tests from test:non-rsc.
  • Adds registerServerComponent.client.test.jsx to test:streaming.
  • Adds a suite-selection check for React 19-only client tests in the React 18 lane.
  • Adds unit coverage for the new suite-selection guard.

Confidence Score: 4/5

The changed test routing needs a fix for the client test environment before merging.

  • The new streaming selection can run a DOM-dependent client test in a Node-default lane.
  • The suite-selection guard is useful, but exact path matching leaves a small routing gap on canonicalized paths.

packages/react-on-rails-pro/package.json; packages/react-on-rails-pro/scripts/check-jest-suite-selection.mjs

Important Files Changed

Filename Overview
packages/react-on-rails-pro/package.json Moves a React 19-only client test out of test:non-rsc and into test:streaming, but the selected lane may not provide the DOM environment that test uses.
packages/react-on-rails-pro/scripts/check-jest-suite-selection.mjs Adds a guard against React 19-only client tests in test:non-rsc, with an exact path comparison that can miss canonicalization differences.
packages/react-on-rails-pro/scripts/check-jest-suite-selection.test.mjs Adds unit coverage for the new React 19-only client test guard.

Reviews (1): Last reviewed commit: "Keep React 19 tests out of the React 18 ..." | Re-trigger Greptile

Comment thread packages/react-on-rails-pro/package.json
Comment thread packages/react-on-rails-pro/scripts/check-jest-suite-selection.mjs
@claude

claude Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review

Overview: This is a bounded, well-targeted follow-up to #4622. It moves registerServerComponent.client.test.jsx from the React-18-compatible test:non-rsc Jest lane into the React-19-gated test:streaming lane, and adds a regression check in check-jest-suite-selection.mjs so a declared React-19-only client test can't silently drift back into test:non-rsc.

Correctness

  • Root cause tracked down correctly: the test file's describe/it blocks are guarded by getNodeVersion() >= 18, but the failure under React 18.3.1 happens at module import time (React.use is not defined), before that guard ever runs — so the Node-version guard inside the test can't prevent it. Routing the file through test:streaming, which is protected by check-react-version.cjs exiting early (process.exit(0)) before jest ever loads the file under React < 19, is the right fix.
  • The added test:non-rsc regex exclusion (|registerServerComponent) is a substring match rather than an exact filename match, consistent with the existing exclusions in that same regex (e.g. streamServerRenderedReactComponent). I checked — there's currently only one file matching *registerServerComponent* in tests/, so no unintended exclusions today, but worth keeping in mind if a registerServerComponent.server.test.jsx-style file is ever added later, since it would silently be swept into the same exclusion.
  • The new misplacedReact19Tests check in check-jest-suite-selection.mjs only executes when the checker itself runs under React 19 (the function returns early for React < 19, per the existing top-of-function guard). That's fine given this is a static lane-membership check based on --listTests output (which doesn't depend on the installed React version for pattern matching), but it's worth being explicit that this guard doesn't protect a hypothetical CI lane that runs the suite-selection checker under React 18 — it relies on the checker consistently running under React 19 in CI.

Test coverage: The new unit test (check-jest-suite-selection.test.mjs) correctly exercises the new throw path by mocking runPnpm so test:non-rsc's listed tests include the React-19-only file, verifying the thrown error message. Good, focused test.

Style/maintenance: react19OnlyClientTests is a manually maintained array with a single hardcoded entry. That's reasonable for now given there's only one such file, but as a maintenance note, this list will need to be updated by hand if more React-19-only client tests are added to tests/streaming-style suites in the future — nothing to change here, just flagging for awareness.

Risk: Low. Scope is limited to test routing/tooling, no runtime/shipped code is touched, and the "no changelog entry" call is correct per this repo's changelog guidelines (test-only changes are excluded).

No blocking issues found.

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react-on-rails/client bundled (gzip) 63.51 KB (0%)
react-on-rails/client bundled (gzip) (time) 63.51 KB (0%)
react-on-rails/client bundled (brotli) 54.46 KB (0%)
react-on-rails/client bundled (brotli) (time) 54.46 KB (0%)
react-on-rails-pro/client bundled (gzip) 64.87 KB (0%)
react-on-rails-pro/client bundled (gzip) (time) 64.87 KB (0%)
react-on-rails-pro/client bundled (brotli) 55.81 KB (0%)
react-on-rails-pro/client bundled (brotli) (time) 55.81 KB (0%)
registerServerComponent/client bundled (gzip) 135.37 KB (0%)
registerServerComponent/client bundled (gzip) (time) 135.37 KB (0%)
registerServerComponent/client bundled (brotli) 81.66 KB (0%)
registerServerComponent/client bundled (brotli) (time) 81.66 KB (0%)
wrapServerComponentRenderer/client bundled (gzip) 127.84 KB (0%)
wrapServerComponentRenderer/client bundled (gzip) (time) 127.84 KB (0%)
wrapServerComponentRenderer/client bundled (brotli) 74.96 KB (0%)
wrapServerComponentRenderer/client bundled (brotli) (time) 74.96 KB (0%)

@justin808

Copy link
Copy Markdown
Member Author

Review disposition — head c4cbb9aff888

  • Must-fix: none.
  • Discuss: none.
  • False positives resolved: 2 Greptile threads.
    • The client/streaming lane inherits jsdom; the exact lane passed 6 suites / 140 tests including the DOM-dependent test.
    • All suite paths come from the same Jest package root/config; the checker observed 48 total and 48 unique selections, with the React-19-only target only in the gated lane.
  • Clean reviews: Claude and CodeRabbit.
  • Candidate changes after review: none.

Current-head validation remains: full Pro Jest 48 files / 617 tests plus 3 suite-selection tests, real React 18.3.1 routing replay, type-check, ESLint, Prettier, diff checks, and 854 Pro headers.

@justin808
justin808 added this pull request to the merge queue Jul 13, 2026
Merged via the queue into main with commit a8cd53f Jul 13, 2026
80 checks passed
@justin808
justin808 deleted the fix/4565-react18-jest-selection branch July 13, 2026 11:01
@justin808

Copy link
Copy Markdown
Member Author

Completed-batch post-merge audit — PASS

No follow-up remains.

justin808 added a commit that referenced this pull request Jul 13, 2026
…rk-audit-gaps

* origin/main:
  Test: keep React 19 coverage out of the React 18 lane (#4635)
justin808 added a commit that referenced this pull request Jul 16, 2026
…t-policy

* origin/main: (33 commits)
  Release: add auditable accelerated RC async gates (#4669)
  Release: handle optional required-check metadata (#4685)
  Release: forward-port post-pull prerelease guard (#4680)
  Forward-port stable RSC 19.2.1 to main (#4672)
  Forward-port Pro license metadata to main (#4668)
  Docs: clarify local benchmark workflow (#4665)
  Fix Hacker News demo-fleet smoke path (#4664)
  Release: reuse verified ShakaPerf pre-run evidence (#4662)
  Release: require strict HEAD evidence before retry guidance (#4661)
  Fix: support React 18 non-RSC streaming (#4658)
  Docs: compare Next.js with Rails async-props streaming (#4651)
  Docs: add reusable demo fleet RC update prompt (#4649)
  CI: run Pro compatibility smokes in hosted tests (#4656)
  Fix ambiguous prerelease retries (#4654)
  Test: add packaged Pro smokes for React 16 and 17 (#4652)
  docs: clarify release version ownership and RSC promotion (#4650)
  [Pro] Keep react-on-rails-rsc out of non-RSC entry graphs (fixes React 18 builds on rc.9) (#4641)
  ci: make benchmark proof gates replayable (#4626)
  Test: keep React 19 coverage out of the React 18 lane (#4635)
  Redact prerender secrets and harden service checks (#4624)
  ...

# Conflicts:
#	internal/contributor-info/release-train-runbook.md
justin808 added a commit that referenced this pull request Jul 16, 2026
…taller

* origin/main: (33 commits)
  Release: add auditable accelerated RC async gates (#4669)
  Release: handle optional required-check metadata (#4685)
  Release: forward-port post-pull prerelease guard (#4680)
  Forward-port stable RSC 19.2.1 to main (#4672)
  Forward-port Pro license metadata to main (#4668)
  Docs: clarify local benchmark workflow (#4665)
  Fix Hacker News demo-fleet smoke path (#4664)
  Release: reuse verified ShakaPerf pre-run evidence (#4662)
  Release: require strict HEAD evidence before retry guidance (#4661)
  Fix: support React 18 non-RSC streaming (#4658)
  Docs: compare Next.js with Rails async-props streaming (#4651)
  Docs: add reusable demo fleet RC update prompt (#4649)
  CI: run Pro compatibility smokes in hosted tests (#4656)
  Fix ambiguous prerelease retries (#4654)
  Test: add packaged Pro smokes for React 16 and 17 (#4652)
  docs: clarify release version ownership and RSC promotion (#4650)
  [Pro] Keep react-on-rails-rsc out of non-RSC entry graphs (fixes React 18 builds on rc.9) (#4641)
  ci: make benchmark proof gates replayable (#4626)
  Test: keep React 19 coverage out of the React 18 lane (#4635)
  Redact prerender secrets and harden service checks (#4624)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-hosted-ci Run optimized hosted GitHub CI for this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant