Commit 224deec
Fix RSC test infrastructure: Convert jest.setup.js to ESM and re-enable tests (#2124)
## Summary
Fixes #2122
- Convert `jest.setup.js` from CommonJS `require()` to ESM imports for
compatibility with ESM mode
- Re-enable RSC tests with automatic React version detection
- Remove unnecessary `script/convert` override since `package.json` now
handles version checking automatically
## Changes
### `packages/react-on-rails-pro/tests/jest.setup.js`
Moved `require()` statements to top-level ESM imports:
- `import { TextEncoder, TextDecoder } from 'util'`
- `import { Readable } from 'stream'`
- `import { ReadableStream, ReadableStreamDefaultReader } from
'stream/web'`
- `import { jest } from '@jest/globals'`
### `packages/react-on-rails-pro/package.json`
Re-enabled `test:rsc` script with React version detection:
- Tests run normally on React 19+ where RSC features are available
- Tests skip gracefully on React 18 with informative message: `RSC tests
skipped (requires React 19+, found 18.0.0)`
### `script/convert`
Removed the override that disabled RSC tests since the version check is
now built into `package.json`.
## Test plan
- [x] Run `yarn test` in `packages/react-on-rails-pro` - passes with
React 18 (RSC tests skipped)
- [x] Verify RSC tests will run on React 19 in CI
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
## Release Notes
* **Chores**
* Updated RSC test infrastructure to conditionally run based on React
version; tests now execute for React 19+ and skip for earlier versions.
* Modernized Jest setup configuration to use ES module imports instead
of dynamic requires, improving compatibility with modern JavaScript
standards.
<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent d1e9779 commit 224deec
File tree
5 files changed
+30
-14
lines changed- packages/react-on-rails-pro
- scripts
- tests
- script
5 files changed
+30
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
1 | 4 | | |
2 | 5 | | |
3 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
1 | 6 | | |
2 | 7 | | |
3 | 8 | | |
| |||
11 | 16 | | |
12 | 17 | | |
13 | 18 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | 19 | | |
22 | 20 | | |
23 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
| 69 | + | |
| 70 | + | |
75 | 71 | | |
76 | 72 | | |
77 | 73 | | |
| |||
0 commit comments