File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
packages/internal-test-utils Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import type {Thenable} from 'shared/ReactTypes';
19
19
import * as Scheduler from 'scheduler/unstable_mock' ;
20
20
21
21
import enqueueTask from './enqueueTask' ;
22
+ import { diff } from 'jest-diff' ;
22
23
23
24
export let actingUpdatesScopeDepth : number = 0 ;
24
25
@@ -45,6 +46,18 @@ export async function act<T>(scope: () => Thenable<T>): Thenable<T> {
45
46
) ;
46
47
}
47
48
49
+ const actualYields = Scheduler . unstable_clearLog ( ) ;
50
+ if ( actualYields . length !== 0 ) {
51
+ const error = Error (
52
+ 'Log of yielded values is not empty. Call assertLog first.\n\n' +
53
+ `Received:\n${ diff ( '' , actualYields . join ( '\n' ) , {
54
+ omitAnnotationLines : true ,
55
+ } ) } `,
56
+ ) ;
57
+ Error . captureStackTrace ( error , act ) ;
58
+ throw error ;
59
+ }
60
+
48
61
// $FlowFixMe[cannot-resolve-name]: Flow doesn't know about global Jest object
49
62
if ( ! jest . isMockFunction ( setTimeout ) ) {
50
63
throw Error (
You can’t perform that action at this time.
0 commit comments