Skip to content

Commit eed73a7

Browse files
committed
[tests] Assert scheduler log empty in internalAct
1 parent a5aedd1 commit eed73a7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

packages/internal-test-utils/internalAct.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ export async function act<T>(scope: () => Thenable<T>): Thenable<T> {
4545
);
4646
}
4747

48+
const actualYields = Scheduler.unstable_clearLog();
49+
if (actualYields.length !== 0) {
50+
const error = Error(
51+
'Log of yielded values is not empty. ' + 'Call assertLog first.',
52+
);
53+
Error.captureStackTrace(error, act);
54+
throw error;
55+
}
56+
4857
// $FlowFixMe[cannot-resolve-name]: Flow doesn't know about global Jest object
4958
if (!jest.isMockFunction(setTimeout)) {
5059
throw Error(

0 commit comments

Comments
 (0)