File tree 1 file changed +9
-4
lines changed
1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 9
9
// an environment that's faked the timers out.
10
10
checkContainerType ,
11
11
} from './dtlHelpers'
12
+ import act , { asyncAct } from './act-compat'
12
13
13
14
// Not supported for external libraries. Only supported internally in @testing -library/dom
14
15
function runWithExpensiveErrorDiagnosticsDisabled ( callback ) {
@@ -77,7 +78,9 @@ function waitFor(
77
78
// third party code that's setting up recursive timers so rapidly that
78
79
// the user's timer's don't get a chance to resolve. So we'll advance
79
80
// by an interval instead. (We have a test for this case).
80
- jest . advanceTimersByTime ( interval )
81
+ act ( ( ) => {
82
+ jest . advanceTimersByTime ( interval )
83
+ } )
81
84
82
85
// It's really important that checkCallback is run *before* we flush
83
86
// in-flight promises. To be honest, I'm not sure why, and I can't quite
@@ -90,9 +93,11 @@ function waitFor(
90
93
// of parallelization so we're fine.
91
94
// https://stackoverflow.com/a/59243586/971592
92
95
// eslint-disable-next-line no-await-in-loop
93
- await new Promise ( r => {
94
- setTimeout ( r , 0 )
95
- jest . advanceTimersByTime ( 0 )
96
+ await asyncAct ( async ( ) => {
97
+ await new Promise ( r => {
98
+ setTimeout ( r , 0 )
99
+ jest . advanceTimersByTime ( 0 )
100
+ } )
96
101
} )
97
102
}
98
103
} else {
You can’t perform that action at this time.
0 commit comments