Skip to content

Commit

Permalink
Updated test to account for DEV/prod differences
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Vaughn committed Jun 16, 2021
1 parent d90747d commit 742d0b0
Showing 1 changed file with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -698,14 +698,25 @@ describe('ReactSuspense', () => {
ReactTestRenderer.act(() => {
_setShow(true);
});
expect(Scheduler).toHaveYielded([
'Child 1',
'Suspend! [Child 2]',
'Loading...',
'destroy layout',
]);
expect(Scheduler).toHaveYielded(
// DEV behavior differs from prod
// In DEV sometimes the work loop sync-flushes the commit
// where as in production, it schedules it behind a timeout.
// See shouldForceFlushFallbacksInDEV() usage
__DEV__
? ['Child 1', 'Suspend! [Child 2]', 'Loading...', 'destroy layout']
: ['Child 1', 'Suspend! [Child 2]', 'Loading...'],
);
jest.advanceTimersByTime(1000);
expect(Scheduler).toHaveYielded(['Promise resolved [Child 2]']);
expect(Scheduler).toHaveYielded(
// DEV behavior differs from prod
// In DEV sometimes the work loop sync-flushes the commit
// where as in production, it schedules it behind a timeout.
// See shouldForceFlushFallbacksInDEV() usage
__DEV__
? ['Promise resolved [Child 2]']
: ['destroy layout', 'Promise resolved [Child 2]'],
);
expect(Scheduler).toFlushAndYield(['Child 1', 'Child 2', 'create layout']);
expect(root).toMatchRenderedOutput(['Child 1', 'Child 2'].join(''));
});
Expand Down

0 comments on commit 742d0b0

Please sign in to comment.