@samitouri / QOS-React-2 / commits / de0ee76dbd

Add unstable_strictModeLevel to test renderer (#20914)

Matches what we do for React DOM

Andrew Clark committed Mar 2, 2021 at 12:41 UTC de0ee76dbde0a5ec507cf4a62c9690f67b56d7b6
1 file changed +6 -1
packages/react-test-renderer/src/ReactTestRenderer.js
+6 -1
@@ -56,6 +56,7 @@ const {IsSomeRendererActing} = ReactSharedInternals;
56 type TestRendererOptions = {
57 createNodeMock: (element: React$Element<any>) => any,
58 unstable_isConcurrent: boolean,
59 + unstable_strictModeLevel: number,
60 ...
61 };
62
@@ -433,6 +434,7 @@ function propsMatch(props: Object, filter: Object): boolean {
434 function create(element: React$Element<any>, options: TestRendererOptions) {
435 let createNodeMock = defaultTestOptions.createNodeMock;
436 let isConcurrent = false;
437 + let strictModeLevel = null;
438 if (typeof options === 'object' && options !== null) {
439 if (typeof options.createNodeMock === 'function') {
440 createNodeMock = options.createNodeMock;
@@ -440,6 +442,9 @@ function create(element: React$Element<any>, options: TestRendererOptions) {
442 if (options.unstable_isConcurrent === true) {
443 isConcurrent = true;
444 }
445 + if (options.unstable_strictModeLevel !== undefined) {
446 + strictModeLevel = options.unstable_strictModeLevel;
447 + }
448 }
449 let container = {
450 children: [],
@@ -451,7 +456,7 @@ function create(element: React$Element<any>, options: TestRendererOptions) {
456 isConcurrent ? ConcurrentRoot : LegacyRoot,
457 false,
458 null,
454 - null,
459 + strictModeLevel,
460 );
461 invariant(root != null, 'something went wrong');
462 updateContainer(element, root, null, null);