Skip to content

Commit e215fad

Browse files
committed
performance.now is mocked in jest 27 fake timers
1 parent fd06070 commit e215fad

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/__tests__/fake-timers.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,8 @@ test('times out after 1000ms by default', async () => {
5050
).rejects.toThrowErrorMatchingInlineSnapshot(
5151
`Timed out in waitForElementToBeRemoved.`,
5252
)
53-
// NOTE: this assertion ensures that the timeout runs in the declared (fake) clock
54-
// while in real time the time was only a fraction since the real clock is only bound by the CPU
55-
// So 10ms is really just an approximation on how long the CPU needs to execute our code.
56-
// If people want to timeout in real time they should rely on their test runners.
57-
expect(performance.now() - start).toBeLessThanOrEqual(10)
53+
// NOTE: this assertion ensures that the timeout runs in the declared (fake) clock.
54+
expect(performance.now() - start).toBeGreaterThanOrEqual(1000)
5855
})
5956

6057
test('recursive timers do not cause issues', async () => {

0 commit comments

Comments
 (0)