From eed73a787a1182f8e8654140cd9a9fcf9cf1f8f1 Mon Sep 17 00:00:00 2001 From: Rick Hanlon Date: Wed, 3 Apr 2024 16:53:56 -0500 Subject: [PATCH] [tests] Assert scheduler log empty in internalAct --- packages/internal-test-utils/internalAct.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/internal-test-utils/internalAct.js b/packages/internal-test-utils/internalAct.js index 7b22c44697e36..6439e8aabee00 100644 --- a/packages/internal-test-utils/internalAct.js +++ b/packages/internal-test-utils/internalAct.js @@ -45,6 +45,15 @@ export async function act(scope: () => Thenable): Thenable { ); } + const actualYields = Scheduler.unstable_clearLog(); + if (actualYields.length !== 0) { + const error = Error( + 'Log of yielded values is not empty. ' + 'Call assertLog first.', + ); + Error.captureStackTrace(error, act); + throw error; + } + // $FlowFixMe[cannot-resolve-name]: Flow doesn't know about global Jest object if (!jest.isMockFunction(setTimeout)) { throw Error(