Skip to content

Commit

Permalink
Add stable concurrent option to react-test-renderer (#27804)
Browse files Browse the repository at this point in the history
## Summary

Concurrent rendering has been the default since React 18 release.
ReactTestRenderer requires passing `{unstable_isConcurrent: true}` to
match this behavior, which means by default tests written with RTR use a
different rendering method than the code they test.

Eventually, RTR should only use ConcurrentRoot. As a first step, let's
add a version of the concurrent option that isn't marked unstable. Next
we will follow up with removing the unstable option when it is safe to
merge.

## How did you test this change?

`yarn test
packages/react-test-renderer/src/__tests__/ReactTestRendererAsync-test.js`

DiffTrain build for commit b36ae8d.
  • Loading branch information
jackpope committed Dec 7, 2023
1 parent 108b7a6 commit d101850
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<b7d1bb0f480a798225aca9bde21b4786>>
* @generated SignedSource<<ad4f3cc032aebbca30e14b6cadc89a2a>>
*/

"use strict";
Expand Down Expand Up @@ -25474,7 +25474,7 @@ if (__DEV__) {
return root;
}

var ReactVersion = "18.3.0-canary-be8aa7687-20231206";
var ReactVersion = "18.3.0-canary-b36ae8d7a-20231207";

// Might add PROFILE later.

Expand Down Expand Up @@ -26378,7 +26378,10 @@ if (__DEV__) {
createNodeMock = options.createNodeMock;
}

if (options.unstable_isConcurrent === true) {
if (
options.unstable_isConcurrent === true ||
options.isConcurrent === true
) {
isConcurrent = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<e0841359e25675fd194913db141bb8f4>>
* @generated SignedSource<<758185a6b91c6a9da438a42c527e57ca>>
*/

"use strict";
Expand Down Expand Up @@ -9083,7 +9083,7 @@ var devToolsConfig$jscomp$inline_1033 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-canary-be8aa7687-20231206",
version: "18.3.0-canary-b36ae8d7a-20231207",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1226 = {
Expand Down Expand Up @@ -9114,7 +9114,7 @@ var internals$jscomp$inline_1226 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-canary-be8aa7687-20231206"
reconcilerVersion: "18.3.0-canary-b36ae8d7a-20231207"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1227 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand All @@ -9136,15 +9136,16 @@ exports.create = function (element, options) {
isConcurrent = !1,
isStrictMode = !1,
concurrentUpdatesByDefault = null;
"object" === typeof options &&
null !== options &&
("function" === typeof options.createNodeMock &&
(createNodeMock = options.createNodeMock),
!0 === options.unstable_isConcurrent && (isConcurrent = !0),
!0 === options.unstable_strictMode && (isStrictMode = !0),
if ("object" === typeof options && null !== options) {
"function" === typeof options.createNodeMock &&
(createNodeMock = options.createNodeMock);
if (!0 === options.unstable_isConcurrent || !0 === options.isConcurrent)
isConcurrent = !0;
!0 === options.unstable_strictMode && (isStrictMode = !0);
void 0 !== options.unstable_concurrentUpdatesByDefault &&
(concurrentUpdatesByDefault =
options.unstable_concurrentUpdatesByDefault));
options.unstable_concurrentUpdatesByDefault);
}
var container = {
children: [],
createNodeMock: createNodeMock,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<9c511bbcbb96d7f0fe52befe1fc1cbec>>
* @generated SignedSource<<85d704372814074410fc8d3c9e856fbb>>
*/

"use strict";
Expand Down Expand Up @@ -9509,7 +9509,7 @@ var devToolsConfig$jscomp$inline_1075 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-canary-be8aa7687-20231206",
version: "18.3.0-canary-b36ae8d7a-20231207",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1267 = {
Expand Down Expand Up @@ -9540,7 +9540,7 @@ var internals$jscomp$inline_1267 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-canary-be8aa7687-20231206"
reconcilerVersion: "18.3.0-canary-b36ae8d7a-20231207"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1268 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand All @@ -9562,15 +9562,16 @@ exports.create = function (element, options) {
isConcurrent = !1,
isStrictMode = !1,
concurrentUpdatesByDefault = null;
"object" === typeof options &&
null !== options &&
("function" === typeof options.createNodeMock &&
(createNodeMock = options.createNodeMock),
!0 === options.unstable_isConcurrent && (isConcurrent = !0),
!0 === options.unstable_strictMode && (isStrictMode = !0),
if ("object" === typeof options && null !== options) {
"function" === typeof options.createNodeMock &&
(createNodeMock = options.createNodeMock);
if (!0 === options.unstable_isConcurrent || !0 === options.isConcurrent)
isConcurrent = !0;
!0 === options.unstable_strictMode && (isStrictMode = !0);
void 0 !== options.unstable_concurrentUpdatesByDefault &&
(concurrentUpdatesByDefault =
options.unstable_concurrentUpdatesByDefault));
options.unstable_concurrentUpdatesByDefault);
}
var container = {
children: [],
createNodeMock: createNodeMock,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if (__DEV__) {
) {
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
}
var ReactVersion = "18.3.0-canary-be8aa7687-20231206";
var ReactVersion = "18.3.0-canary-b36ae8d7a-20231207";

// ATTENTION
// When adding new symbols to this file,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,4 +580,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactCurrentDispatcher.current.useTransition();
};
exports.version = "18.3.0-canary-be8aa7687-20231206";
exports.version = "18.3.0-canary-b36ae8d7a-20231207";
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactCurrentDispatcher.current.useTransition();
};
exports.version = "18.3.0-canary-be8aa7687-20231206";
exports.version = "18.3.0-canary-b36ae8d7a-20231207";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
be8aa76873e231555676483a36534bb48ad1b1a3
b36ae8d7aab94dae285d9d6a1c5f004e6fc19fc9

0 comments on commit d101850

Please sign in to comment.