You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/__tests__/wait-for.js
+2-2
Original file line number
Diff line number
Diff line change
@@ -207,7 +207,7 @@ test('if you switch from fake timers to real timers during the wait period you g
207
207
consterror=awaitwaitForError
208
208
209
209
expect(error.message).toMatchInlineSnapshot(
210
-
`Changed from using fake timers to real timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing what timers your test is using. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830`,
210
+
`Changed from using fake timers to real timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing to real timers. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830`,
211
211
)
212
212
// stack trace has this file in it
213
213
expect(error.stack).toMatch(__dirname)
@@ -223,7 +223,7 @@ test('if you switch from real timers to fake timers during the wait period you g
223
223
consterror=awaitwaitForError
224
224
225
225
expect(error.message).toMatchInlineSnapshot(
226
-
`Changed from using real timers to fake timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing what timers your test is using. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830`,
226
+
`Changed from using real timers to fake timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing to fake timers. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830`,
// we *could* (maybe should?) use `advanceTimersToNextTimer` but it's
81
-
// possible that could make this loop go on forever if someone is using
82
-
// third party code that's setting up recursive timers so rapidly that
83
-
// the user's timer's don't get a chance to resolve. So we'll advance
84
-
// by an interval instead. (We have a test for this case).
85
-
jest.advanceTimersByTime(interval)
86
-
})
87
-
88
-
// In this rare case, we *need* to wait for in-flight promises
89
-
// to resolve before continuing. We don't need to take advantage
90
-
// of parallelization so we're fine.
91
-
// https://stackoverflow.com/a/59243586/971592
92
-
// eslint-disable-next-line no-await-in-loop
93
-
awaitadvanceTimersWrapper(async()=>{
94
-
awaitnewPromise(r=>{
95
-
setTimeout(r,0)
96
-
jest.advanceTimersByTime(0)
97
-
})
98
-
})
99
-
}catch(error){
62
+
if(!jestFakeTimersAreEnabled()){
63
+
consterror=newError(
64
+
`Changed from using fake timers to real timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing to real timers. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830`,
} while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing what timers your test is using. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830`,
130
+
`Changed from using real timers to fake timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing to fake timers. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830`,
0 commit comments