File tree 1 file changed +6
-3
lines changed
1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ describe('fake timers and missing act warnings', () => {
55
55
jest . useRealTimers ( )
56
56
} )
57
57
58
- test ( 'cleanup does not flush microtasks' , async ( ) => {
58
+ test ( 'cleanup does flush microtasks' , async ( ) => {
59
59
const microTaskSpy = jest . fn ( )
60
60
function Test ( ) {
61
61
const counter = 1
@@ -72,16 +72,19 @@ describe('fake timers and missing act warnings', () => {
72
72
73
73
return ( ) => {
74
74
cancelled = true
75
+ Promise . resolve ( ) . then ( ( ) => {
76
+ microTaskSpy ( )
77
+ } )
75
78
}
76
79
} , [ counter ] )
77
80
78
81
return null
79
82
}
80
83
await render ( < Test /> )
84
+ expect ( microTaskSpy ) . toHaveBeenCalledTimes ( 1 )
81
85
82
86
await cleanup ( )
83
-
84
- expect ( microTaskSpy ) . toHaveBeenCalledTimes ( 0 )
87
+ expect ( microTaskSpy ) . toHaveBeenCalledTimes ( 2 )
85
88
// console.error is mocked
86
89
// eslint-disable-next-line no-console
87
90
expect ( console . error ) . toHaveBeenCalledTimes ( 0 )
You can’t perform that action at this time.
0 commit comments