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

[Suspense] Add Batched Mode variant to fuzz tester (#15734)

Andrew Clark committed May 28, 2019 at 11:41 UTC d915a4c1f16f9a5f516df0eb79e5a7e35ed89281
2 files changed +16 -13
packages/react-noop-renderer/src/createReactNoop.js
+2 -2
@@ -969,10 +969,10 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
969 NoopRenderer.updateContainer(children, fiberRoot, null, null);
970 },
971 getChildren() {
972 - return getChildren(fiberRoot);
972 + return getChildren(container);
973 },
974 getChildrenAsJSX() {
975 - return getChildrenAsJSX(fiberRoot);
975 + return getChildrenAsJSX(container);
976 },
977 };
978 },
packages/react-reconciler/src/__tests__/ReactSuspenseFuzz-test.internal.js
+14 -11
@@ -160,16 +160,14 @@ describe('ReactSuspenseFuzz', () => {
160 );
161
162 resetCache();
163 - ReactNoop.renderToRootWithID(
163 + const expectedRoot = ReactNoop.createRoot();
164 + expectedRoot.render(
165 <ShouldSuspendContext.Provider value={false}>
166 {children}
167 </ShouldSuspendContext.Provider>,
167 - 'expected',
168 );
169 resolveAllTasks();
170 - const expectedOutput = ReactNoop.getChildrenAsJSX('expected');
171 - ReactNoop.renderToRootWithID(null, 'expected');
172 - Scheduler.unstable_flushWithoutYielding();
170 + const expectedOutput = expectedRoot.getChildrenAsJSX();
171
172 resetCache();
173 ReactNoop.renderLegacySyncRoot(children);
@@ -179,13 +177,18 @@ describe('ReactSuspenseFuzz', () => {
177 ReactNoop.renderLegacySyncRoot(null);
178
179 resetCache();
182 - ReactNoop.renderToRootWithID(children, 'concurrent');
183 - Scheduler.unstable_flushWithoutYielding();
180 + const batchedSyncRoot = ReactNoop.createSyncRoot();
181 + batchedSyncRoot.render(children);
182 + resolveAllTasks();
183 + const batchedSyncOutput = batchedSyncRoot.getChildrenAsJSX();
184 + expect(batchedSyncOutput).toEqual(expectedOutput);
185 +
186 + resetCache();
187 + const concurrentRoot = ReactNoop.createRoot();
188 + concurrentRoot.render(children);
189 resolveAllTasks();
185 - const concurrentOutput = ReactNoop.getChildrenAsJSX('concurrent');
190 + const concurrentOutput = concurrentRoot.getChildrenAsJSX();
191 expect(concurrentOutput).toEqual(expectedOutput);
187 - ReactNoop.renderToRootWithID(null, 'concurrent');
188 - Scheduler.unstable_flushWithoutYielding();
192 }
193
194 function pickRandomWeighted(rand, options) {
@@ -321,7 +324,7 @@ describe('ReactSuspenseFuzz', () => {
324 );
325 });
326
324 - it('generative tests', () => {
327 + it(`generative tests (random seed: ${SEED})`, () => {
328 const {generateTestCase, testResolvedOutput} = createFuzzer();
329
330 const rand = Random.create(SEED);