Fix failing test (#21697)
Dan Abramov committed
Jun 17, 2021 at 13:56 UTC
43f4cc160811657135508cdefe6aed2b3522a905
1 file changed
+10
-19
packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js
+10
-19
@@ -695,28 +695,19 @@ describe('ReactSuspense', () => {
695
expect(Scheduler).toFlushAndYield(['Child 1', 'create layout']);
696
expect(root).toMatchRenderedOutput('Child 1');
697
698
- ReactTestRenderer.act(() => {
698
+ act(() => {
699
_setShow(true);
700
});
701
- expect(Scheduler).toHaveYielded(
702
- // DEV behavior differs from prod
703
- // In DEV sometimes the work loop sync-flushes the commit
704
- // where as in production, it schedules it behind a timeout.
705
- // See shouldForceFlushFallbacksInDEV() usage
706
- __DEV__
707
- ? ['Child 1', 'Suspend! [Child 2]', 'Loading...', 'destroy layout']
708
- : ['Child 1', 'Suspend! [Child 2]', 'Loading...'],
709
- );
701
+ expect(Scheduler).toHaveYielded([
702
+ 'Child 1',
703
+ 'Suspend! [Child 2]',
704
+ 'Loading...',
705
+ ]);
706
jest.advanceTimersByTime(1000);
711
- expect(Scheduler).toHaveYielded(
712
- // DEV behavior differs from prod
713
- // In DEV sometimes the work loop sync-flushes the commit
714
- // where as in production, it schedules it behind a timeout.
715
- // See shouldForceFlushFallbacksInDEV() usage
716
- __DEV__
717
- ? ['Promise resolved [Child 2]']
718
- : ['destroy layout', 'Promise resolved [Child 2]'],
719
- );
707
+ expect(Scheduler).toHaveYielded([
708
+ 'destroy layout',
709
+ 'Promise resolved [Child 2]',
710
+ ]);
711
expect(Scheduler).toFlushAndYield(['Child 1', 'Child 2', 'create layout']);
712
expect(root).toMatchRenderedOutput(['Child 1', 'Child 2'].join(''));
713
});