From 43f4cc160811657135508cdefe6aed2b3522a905 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Thu, 17 Jun 2021 13:56:18 +0100 Subject: [PATCH] Fix failing test (#21697) --- .../__tests__/ReactSuspense-test.internal.js | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js b/packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js index 2bfec1aa583a7..e7e167972404f 100644 --- a/packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js +++ b/packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js @@ -695,28 +695,19 @@ describe('ReactSuspense', () => { expect(Scheduler).toFlushAndYield(['Child 1', 'create layout']); expect(root).toMatchRenderedOutput('Child 1'); - ReactTestRenderer.act(() => { + act(() => { _setShow(true); }); - 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...'], - ); + expect(Scheduler).toHaveYielded([ + 'Child 1', + 'Suspend! [Child 2]', + 'Loading...', + ]); jest.advanceTimersByTime(1000); - 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).toHaveYielded([ + 'destroy layout', + 'Promise resolved [Child 2]', + ]); expect(Scheduler).toFlushAndYield(['Child 1', 'Child 2', 'create layout']); expect(root).toMatchRenderedOutput(['Child 1', 'Child 2'].join('')); });