Skip to content

Commit cdfecc8

Browse files
Make RSCClientRoot tests run with react 18
1 parent 611d3b9 commit cdfecc8

File tree

5 files changed

+46
-19
lines changed

5 files changed

+46
-19
lines changed

.github/workflows/package-js-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@ jobs:
4343
sudo yarn global add yalc
4444
- name: Run JS unit tests for Renderer package
4545
run: yarn test
46+
# TODO: Remove this once we made these tests compatible with React 19
47+
- name: Run JS unit tests for Renderer package with React 18 (for tests not compatible with React 19)
48+
run: yarn test:react-18

jest.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,12 @@ module.exports = {
22
preset: 'ts-jest/presets/js-with-ts',
33
testEnvironment: 'jsdom',
44
setupFiles: ['<rootDir>/node_package/tests/jest.setup.js'],
5+
// TODO: Remove this once we made RSCClientRoot compatible with React 19
6+
moduleNameMapper: process.env.USE_REACT_18 ? {
7+
'^react$': '<rootDir>/node_modules/react-18',
8+
'^react/(.*)$': '<rootDir>/node_modules/react-18/$1',
9+
'^react-dom$': '<rootDir>/node_modules/react-dom-18',
10+
'^react-dom/(.*)$': '<rootDir>/node_modules/react-dom-18/$1',
11+
}
12+
: {},
513
};

node_package/tests/RSCClientRoot.test.jsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
* @jest-environment jsdom
55
*/
66

7+
// TODO: Remove this once we made these tests compatible with React 19
8+
if (process.env.USE_REACT_18 !== 'true') {
9+
test.skip('Skipping RSC tests when not using React 18', () => {});
10+
return;
11+
}
12+
713
// Mock webpack require system for RSC
814
window.__webpack_require__ = jest.fn();
915
window.__webpack_chunk_load__ = jest.fn();
@@ -16,9 +22,6 @@ import path from 'path';
1622
import fs from 'fs';
1723
import { createNodeReadableStream } from './testUtils';
1824

19-
// const __filename = fileURLToPath(import.meta.url);
20-
// const __dirname = path.dirname(__filename);
21-
2225
import RSCClientRoot, { resetRenderCache } from '../src/RSCClientRoot';
2326

2427
enableFetchMocks();

package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
"devDependencies": {
1818
"@babel/core": "^7.20.12",
1919
"@babel/preset-env": "^7.20.2",
20+
"@testing-library/dom": "^10.4.0",
21+
"@testing-library/jest-dom": "^6.6.3",
22+
"@testing-library/react": "^16.2.0",
2023
"@types/jest": "^29.5.14",
2124
"@types/node": "^20.17.16",
2225
"@types/react": "^18.3.18",
2326
"@types/react-dom": "^18.3.5",
24-
"@testing-library/dom": "^10.4.0",
25-
"@testing-library/jest-dom": "^6.6.3",
26-
"@testing-library/react": "^16.2.0",
2727
"@types/turbolinks": "^5.2.2",
2828
"@typescript-eslint/eslint-plugin": "^6.18.1",
2929
"@typescript-eslint/parser": "^6.18.1",
@@ -46,14 +46,15 @@
4646
"prettier": "^2.8.8",
4747
"prop-types": "^15.8.1",
4848
"react": "^19.0.0",
49+
"react-18": "npm:[email protected]",
4950
"react-dom": "^19.0.0",
50-
"react-server-dom-webpack": "^19.0.0",
51+
"react-dom-18": "npm:[email protected]",
52+
"react-server-dom-webpack": "18.3.0-canary-670811593-20240322",
5153
"redux": "^4.2.1",
5254
"ts-jest": "^29.2.5",
5355
"typescript": "^5.6.2"
5456
},
55-
"dependencies": {
56-
},
57+
"dependencies": {},
5758
"peerDependencies": {
5859
"react": ">= 16",
5960
"react-dom": ">= 16",
@@ -64,6 +65,7 @@
6465
],
6566
"scripts": {
6667
"test": "jest node_package/tests",
68+
"test:react-18": "USE_REACT_18=true jest node_package/tests/RSCClientRoot.test.jsx",
6769
"clean": "rm -rf node_package/lib",
6870
"start": "nps",
6971
"prepack": "nps build.prepack",

yarn.lock

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5520,6 +5520,18 @@ queue-microtask@^1.2.2:
55205520
resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243"
55215521
integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==
55225522

5523+
"react-18@npm:[email protected]":
5524+
version "18.3.0-canary-670811593-20240322"
5525+
resolved "https://registry.yarnpkg.com/react/-/react-18.3.0-canary-670811593-20240322.tgz#3735250b45468d313ed36121324452bb5a732e9b"
5526+
integrity sha512-EI6+q3tOT+0z4OkB2sz842Ra/n/yz7b3jOJhSK1HQwi4Ng29VJzLGngWmSuxQ94YfdE3EBhpUKDfgNgzoKM9Vg==
5527+
5528+
"react-dom-18@npm:[email protected]":
5529+
version "18.3.0-canary-670811593-20240322"
5530+
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-18.3.0-canary-670811593-20240322.tgz#ac677b164fd83050272bf985e740ed4ca65337be"
5531+
integrity sha512-AHxCnyDzZueXIHY4WA2Uba1yaL7/vbjhO3D3TWPQeruKD5MwgD0/xExZi0T104gBr6Thv6MEsLSxFjBAHhHKKg==
5532+
dependencies:
5533+
scheduler "0.24.0-canary-670811593-20240322"
5534+
55235535
react-dom@^19.0.0:
55245536
version "19.0.0"
55255537
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-19.0.0.tgz#43446f1f01c65a4cd7f7588083e686a6726cfb57"
@@ -5542,14 +5554,13 @@ react-is@^18.0.0:
55425554
resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.2.0.tgz#199431eeaaa2e09f86427efbb4f1473edb47609b"
55435555
integrity sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==
55445556

5545-
react-server-dom-webpack@^19.0.0:
5546-
version "19.0.0"
5547-
resolved "https://registry.yarnpkg.com/react-server-dom-webpack/-/react-server-dom-webpack-19.0.0.tgz#c60819b6cb54e317e675ddc0c5959ff915b789d0"
5548-
integrity sha512-hLug9KEXLc8vnU9lDNe2b2rKKDaqrp5gNiES4uyu2Up3FZfZJZmdwLFXlWzdA9gTB/6/cWduSB2K1Lfag2pSvw==
5557+
react-server-dom-webpack@18.3.0-canary-670811593-20240322:
5558+
version "18.3.0-canary-670811593-20240322"
5559+
resolved "https://registry.yarnpkg.com/react-server-dom-webpack/-/react-server-dom-webpack-18.3.0-canary-670811593-20240322.tgz#e9b99b1f0179357e5acbf2fbacaee88dd1e8bf3b"
5560+
integrity sha512-YaCk3AvvOXcOo0FL7SlAY2GVBeuZKFQ/5FfAtE48IjpI6MvXTwMBu3QVnT/Ukk9Y4M9GzpIbLtuc8hPjfFAOaw==
55495561
dependencies:
55505562
acorn-loose "^8.3.0"
55515563
neo-async "^2.6.1"
5552-
webpack-sources "^3.2.0"
55535564

55545565
react@^19.0.0:
55555566
version "19.0.0"
@@ -5799,6 +5810,11 @@ saxes@^6.0.0:
57995810
dependencies:
58005811
xmlchars "^2.2.0"
58015812

5813+
5814+
version "0.24.0-canary-670811593-20240322"
5815+
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.24.0-canary-670811593-20240322.tgz#45c5c45f18a127ab4e3c805dd466bc231b20adf3"
5816+
integrity sha512-IGX6Fq969h1L0X7jV0sJ/EdI4fr+mRetbBNJl55nn+/RsCuQSVwgKnZG6Q3NByixDNbkRI8nRmWuhOm8NQowGQ==
5817+
58025818
scheduler@^0.25.0:
58035819
version "0.25.0"
58045820
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.25.0.tgz#336cd9768e8cceebf52d3c80e3dcf5de23e7e015"
@@ -6483,11 +6499,6 @@ webidl-conversions@^7.0.0:
64836499
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-7.0.0.tgz#256b4e1882be7debbf01d05f0aa2039778ea080a"
64846500
integrity sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==
64856501

6486-
webpack-sources@^3.2.0:
6487-
version "3.2.3"
6488-
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde"
6489-
integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==
6490-
64916502
whatwg-encoding@^2.0.0:
64926503
version "2.0.0"
64936504
resolved "https://registry.yarnpkg.com/whatwg-encoding/-/whatwg-encoding-2.0.0.tgz#e7635f597fd87020858626805a2729fa7698ac53"

0 commit comments

Comments
 (0)