Skip to content

Commit

Permalink
[tests] Assert scheduler log empty in internalAct
Browse files Browse the repository at this point in the history
  • Loading branch information
rickhanlonii committed Apr 3, 2024
1 parent a5aedd1 commit eed73a7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/internal-test-utils/internalAct.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ export async function act<T>(scope: () => Thenable<T>): Thenable<T> {
);
}

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(
Expand Down

0 comments on commit eed73a7

Please sign in to comment.