react
react copied to clipboard
fix tests mock by using Module instance instead of plain js object
Summary
Use module instance in react-server-dom-turbopack
and react-server-dom-webpack
tests instead of plain js object, for this function call originalCompile.apply(this, arguments)
will throw error if object is passed as context this
.
Before this change run yarn test
would cause several test cases to fail.
ENV: [email protected], [email protected], [email protected] (23B81).
FAIL packages/react-server-dom-webpack/src/tests/ReactFlightDOMForm-test.js ● ReactFlightDOMForm › can submit a passed server action without hydrating it
TypeError: The "mod" argument must be an instance of Module. Received an instance of Object
80 |
81 | if (useServer) {
> 82 | originalCompile.apply(this, arguments);
| ^
83 |
84 | const moduleId: string = (url.pathToFileURL(filename).href: any);
85 |
at Object.Module._compile (packages/react-server-dom-webpack/src/ReactFlightWebpackNodeRegister.js:82:23)
at serverExports (packages/react-server-dom-webpack/src/__tests__/utils/WebpackMock.js:150:15)
at Object.<anonymous> (packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMForm-test.js:134:24)
Test Suites: 3 failed, 303 passed, 306 total Tests: 19 failed, 32 skipped, 8038 passed, 8089 total Snapshots: 177 passed, 177 total Time: 146.72 s
How did you test this change?
Run yarn test
locally after the changes.
Test Suites: 306 passed, 306 total Tests: 32 skipped, 8057 passed, 8089 total Snapshots: 177 passed, 177 total Time: 140.891 s
Comparing: a870b2d5494351d75b68c3d9baf03a52fd40a8ef...a4bf0c7a6e4c20172a04e806196abd5eab8155a7
Critical size changes
Includes critical production bundles, as well as any change greater than 2%:
Name | +/- | Base | Current | +/- gzip | Base gzip | Current gzip |
---|---|---|---|---|---|---|
oss-stable/react-dom/cjs/react-dom.production.min.js | = | 176.83 kB | 176.83 kB | = | 54.91 kB | 54.91 kB |
oss-experimental/react-dom/cjs/react-dom.production.min.js | = | 173.55 kB | 173.55 kB | = | 54.11 kB | 54.11 kB |
facebook-www/ReactDOM-prod.classic.js | = | 594.16 kB | 594.16 kB | = | 104.42 kB | 104.42 kB |
facebook-www/ReactDOM-prod.modern.js | = | 577.42 kB | 577.42 kB | = | 101.45 kB | 101.45 kB |
test_utils/ReactAllWarnings.js | Deleted | 66.87 kB | 0.00 kB | Deleted | 16.36 kB | 0.00 kB |
Significant size changes
Includes any change greater than 0.2%:
Expand to show
Name | +/- | Base | Current | +/- gzip | Base gzip | Current gzip |
---|---|---|---|---|---|---|
test_utils/ReactAllWarnings.js | Deleted | 66.87 kB | 0.00 kB | Deleted | 16.36 kB | 0.00 kB |
Generated by :no_entry_sign: dangerJS against a4bf0c7a6e4c20172a04e806196abd5eab8155a7
@M-Izadmehr hello, this message for github developer. @rick-ast you can learn a lot of thing and explore from at here.