File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 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', () => {
5555 jest . useRealTimers ( )
5656 } )
5757
58- test ( 'cleanup does not flush microtasks' , async ( ) => {
58+ test ( 'cleanup does flush microtasks' , async ( ) => {
5959 const microTaskSpy = jest . fn ( )
6060 function Test ( ) {
6161 const counter = 1
@@ -72,16 +72,19 @@ describe('fake timers and missing act warnings', () => {
7272
7373 return ( ) => {
7474 cancelled = true
75+ Promise . resolve ( ) . then ( ( ) => {
76+ microTaskSpy ( )
77+ } )
7578 }
7679 } , [ counter ] )
7780
7881 return null
7982 }
8083 await render ( < Test /> )
84+ expect ( microTaskSpy ) . toHaveBeenCalledTimes ( 1 )
8185
8286 await cleanup ( )
83-
84- expect ( microTaskSpy ) . toHaveBeenCalledTimes ( 0 )
87+ expect ( microTaskSpy ) . toHaveBeenCalledTimes ( 2 )
8588 // console.error is mocked
8689 // eslint-disable-next-line no-console
8790 expect ( console . error ) . toHaveBeenCalledTimes ( 0 )
You can’t perform that action at this time.
0 commit comments