Skip to content

Commit d915a4c

Browse files
authored
[Suspense] Add Batched Mode variant to fuzz tester (#15734)
1 parent 7c5645d commit d915a4c

2 files changed

Lines changed: 16 additions & 13 deletions

File tree

packages/react-noop-renderer/src/createReactNoop.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -969,10 +969,10 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
969969
NoopRenderer.updateContainer(children, fiberRoot, null, null);
970970
},
971971
getChildren() {
972-
return getChildren(fiberRoot);
972+
return getChildren(container);
973973
},
974974
getChildrenAsJSX() {
975-
return getChildrenAsJSX(fiberRoot);
975+
return getChildrenAsJSX(container);
976976
},
977977
};
978978
},

packages/react-reconciler/src/__tests__/ReactSuspenseFuzz-test.internal.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -160,16 +160,14 @@ describe('ReactSuspenseFuzz', () => {
160160
);
161161

162162
resetCache();
163-
ReactNoop.renderToRootWithID(
163+
const expectedRoot = ReactNoop.createRoot();
164+
expectedRoot.render(
164165
<ShouldSuspendContext.Provider value={false}>
165166
{children}
166167
</ShouldSuspendContext.Provider>,
167-
'expected',
168168
);
169169
resolveAllTasks();
170-
const expectedOutput = ReactNoop.getChildrenAsJSX('expected');
171-
ReactNoop.renderToRootWithID(null, 'expected');
172-
Scheduler.unstable_flushWithoutYielding();
170+
const expectedOutput = expectedRoot.getChildrenAsJSX();
173171

174172
resetCache();
175173
ReactNoop.renderLegacySyncRoot(children);
@@ -179,13 +177,18 @@ describe('ReactSuspenseFuzz', () => {
179177
ReactNoop.renderLegacySyncRoot(null);
180178

181179
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);
184189
resolveAllTasks();
185-
const concurrentOutput = ReactNoop.getChildrenAsJSX('concurrent');
190+
const concurrentOutput = concurrentRoot.getChildrenAsJSX();
186191
expect(concurrentOutput).toEqual(expectedOutput);
187-
ReactNoop.renderToRootWithID(null, 'concurrent');
188-
Scheduler.unstable_flushWithoutYielding();
189192
}
190193

191194
function pickRandomWeighted(rand, options) {
@@ -321,7 +324,7 @@ describe('ReactSuspenseFuzz', () => {
321324
);
322325
});
323326

324-
it('generative tests', () => {
327+
it(`generative tests (random seed: ${SEED})`, () => {
325328
const {generateTestCase, testResolvedOutput} = createFuzzer();
326329

327330
const rand = Random.create(SEED);

0 commit comments

Comments
 (0)