We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ee062e7 commit bf00145Copy full SHA for bf00145
1 file changed
tests/utils/misc/wait.ts
@@ -1,9 +1,18 @@
1
+import {createConfig} from '#src/setup/setup'
2
import {wait} from '#src/utils/misc/wait'
3
4
test('advances timers when set', async () => {
5
+ const beforeReal = performance.now()
6
jest.useFakeTimers()
- jest.setTimeout(50)
- // If this wasn't advancing fake timers, we'd timeout and fail the test
7
- await wait(10000, jest.advanceTimersByTime)
+ const beforeFake = performance.now()
8
+
9
+ const config = createConfig({
10
+ delay: 1000,
11
+ advanceTimers: jest.advanceTimersByTime,
12
+ })
13
+ await wait(config)
14
15
+ expect(performance.now() - beforeFake).toBe(1000)
16
jest.useRealTimers()
-})
17
+ expect(performance.now() - beforeReal).toBeLessThan(10)
18
+}, 10)
0 commit comments