From a4312faa934643b1e6adc31f262ef251068f0315 Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Thu, 25 Mar 2021 22:08:53 -0500 Subject: [PATCH] Use `act` in fuzz tester to flush expired work (#21108) * Add failing hard-coded fuzz test Caught in CI by the fuzz tester. Related to expired updates. * Use `act` in fuzz tester to flush expired work Expired work gets scheduled in a microtask now, so we need to use `act` to flush it. --- .../src/__tests__/ReactIncrementalTriangle-test.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/react-reconciler/src/__tests__/ReactIncrementalTriangle-test.js b/packages/react-reconciler/src/__tests__/ReactIncrementalTriangle-test.js index fdf7d37e8250a..275a3feb8c82f 100644 --- a/packages/react-reconciler/src/__tests__/ReactIncrementalTriangle-test.js +++ b/packages/react-reconciler/src/__tests__/ReactIncrementalTriangle-test.js @@ -432,7 +432,9 @@ describe('ReactIncrementalTriangle', () => { assertConsistentTree(activeLeafIndices); } // Flush remaining work - Scheduler.unstable_flushAllWithoutAsserting(); + ReactNoop.act(() => { + Scheduler.unstable_flushAllWithoutAsserting(); + }); assertConsistentTree(activeLeafIndices, expectedCounterAtEnd); } @@ -562,6 +564,12 @@ ${formatActions(actions)} ['b', flush(7)], ['c', toggle(0)], ); + + simulateMultipleRoots( + ['c', step(1)], + ['c', expire(5000)], + ['b', toggle(1)], + ); }); it('generative tests', () => {