@@ -67,12 +67,18 @@ function waitFor(
67
67
reject ( error )
68
68
return
69
69
}
70
- // we *could* (maybe should?) use `advanceTimersToNextTimer` but it's
71
- // possible that could make this loop go on forever if someone is using
72
- // third party code that's setting up recursive timers so rapidly that
73
- // the user's timer's don't get a chance to resolve. So we'll advance
74
- // by an interval instead. (We have a test for this case).
75
- advanceTimersWrapper ( ( ) => {
70
+
71
+ // In this rare case, we *need* to wait for in-flight promises
72
+ // to resolve before continuing. We don't need to take advantage
73
+ // of parallelization so we're fine.
74
+ // https://stackoverflow.com/a/59243586/971592
75
+ // eslint-disable-next-line no-await-in-loop
76
+ await advanceTimersWrapper ( async ( ) => {
77
+ // we *could* (maybe should?) use `advanceTimersToNextTimer` but it's
78
+ // possible that could make this loop go on forever if someone is using
79
+ // third party code that's setting up recursive timers so rapidly that
80
+ // the user's timer's don't get a chance to resolve. So we'll advance
81
+ // by an interval instead. (We have a test for this case).
76
82
jest . advanceTimersByTime ( interval )
77
83
} )
78
84
@@ -85,18 +91,6 @@ function waitFor(
85
91
if ( finished ) {
86
92
break
87
93
}
88
-
89
- // In this rare case, we *need* to wait for in-flight promises
90
- // to resolve before continuing. We don't need to take advantage
91
- // of parallelization so we're fine.
92
- // https://stackoverflow.com/a/59243586/971592
93
- // eslint-disable-next-line no-await-in-loop
94
- await advanceTimersWrapper ( async ( ) => {
95
- await new Promise ( r => {
96
- setTimeout ( r , 0 )
97
- jest . advanceTimersByTime ( 0 )
98
- } )
99
- } )
100
94
}
101
95
} else {
102
96
try {
0 commit comments