From d915a4c1f16f9a5f516df0eb79e5a7e35ed89281 Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Tue, 28 May 2019 11:41:01 -0700 Subject: [PATCH] [Suspense] Add Batched Mode variant to fuzz tester (#15734) --- .../src/createReactNoop.js | 4 +-- .../ReactSuspenseFuzz-test.internal.js | 25 +++++++++++-------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/packages/react-noop-renderer/src/createReactNoop.js b/packages/react-noop-renderer/src/createReactNoop.js index a21a9d95c1..3d4ecf32e0 100644 --- a/packages/react-noop-renderer/src/createReactNoop.js +++ b/packages/react-noop-renderer/src/createReactNoop.js @@ -969,10 +969,10 @@ function createReactNoop(reconciler: Function, useMutation: boolean) { NoopRenderer.updateContainer(children, fiberRoot, null, null); }, getChildren() { - return getChildren(fiberRoot); + return getChildren(container); }, getChildrenAsJSX() { - return getChildrenAsJSX(fiberRoot); + return getChildrenAsJSX(container); }, }; }, diff --git a/packages/react-reconciler/src/__tests__/ReactSuspenseFuzz-test.internal.js b/packages/react-reconciler/src/__tests__/ReactSuspenseFuzz-test.internal.js index ee3ad488d8..c6607df92e 100644 --- a/packages/react-reconciler/src/__tests__/ReactSuspenseFuzz-test.internal.js +++ b/packages/react-reconciler/src/__tests__/ReactSuspenseFuzz-test.internal.js @@ -160,16 +160,14 @@ describe('ReactSuspenseFuzz', () => { ); resetCache(); - ReactNoop.renderToRootWithID( + const expectedRoot = ReactNoop.createRoot(); + expectedRoot.render( {children} , - 'expected', ); resolveAllTasks(); - const expectedOutput = ReactNoop.getChildrenAsJSX('expected'); - ReactNoop.renderToRootWithID(null, 'expected'); - Scheduler.unstable_flushWithoutYielding(); + const expectedOutput = expectedRoot.getChildrenAsJSX(); resetCache(); ReactNoop.renderLegacySyncRoot(children); @@ -179,13 +177,18 @@ describe('ReactSuspenseFuzz', () => { ReactNoop.renderLegacySyncRoot(null); resetCache(); - ReactNoop.renderToRootWithID(children, 'concurrent'); - Scheduler.unstable_flushWithoutYielding(); + const batchedSyncRoot = ReactNoop.createSyncRoot(); + batchedSyncRoot.render(children); resolveAllTasks(); - const concurrentOutput = ReactNoop.getChildrenAsJSX('concurrent'); + const batchedSyncOutput = batchedSyncRoot.getChildrenAsJSX(); + expect(batchedSyncOutput).toEqual(expectedOutput); + + resetCache(); + const concurrentRoot = ReactNoop.createRoot(); + concurrentRoot.render(children); + resolveAllTasks(); + const concurrentOutput = concurrentRoot.getChildrenAsJSX(); expect(concurrentOutput).toEqual(expectedOutput); - ReactNoop.renderToRootWithID(null, 'concurrent'); - Scheduler.unstable_flushWithoutYielding(); } function pickRandomWeighted(rand, options) { @@ -321,7 +324,7 @@ describe('ReactSuspenseFuzz', () => { ); }); - it('generative tests', () => { + it(`generative tests (random seed: ${SEED})`, () => { const {generateTestCase, testResolvedOutput} = createFuzzer(); const rand = Random.create(SEED);