From 8669481a11b76b5958657c4912d3d9cb19d9c6d4 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sun, 28 May 2023 11:14:38 +0200 Subject: [PATCH] fix: Remove redundant flush of microtask queue --- src/pure.js | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/pure.js b/src/pure.js index 7e25c3dd..def6e521 100644 --- a/src/pure.js +++ b/src/pure.js @@ -43,21 +43,7 @@ configureDTL({ const previousActEnvironment = getIsReactActEnvironment() setReactActEnvironment(false) try { - const result = await cb() - // Drain microtask queue. - // Otherwise we'll restore the previous act() environment, before we resolve the `waitFor` call. - // The caller would have no chance to wrap the in-flight Promises in `act()` - await new Promise(resolve => { - setTimeout(() => { - resolve() - }, 0) - - if (jestFakeTimersAreEnabled()) { - jest.advanceTimersByTime(0) - } - }) - - return result + return await cb() } finally { setReactActEnvironment(previousActEnvironment) }