From c44ea54633d8adc39ad4816a489fb99c449faa69 Mon Sep 17 00:00:00 2001 From: eps1lon Date: Sun, 13 Jun 2021 21:42:49 +0200 Subject: [PATCH 1/2] test(waitFor): Add current behavior for legacy fake timers and requestAnimationFrame --- src/__tests__/fake-timers.js | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/__tests__/fake-timers.js b/src/__tests__/fake-timers.js index fddea181..9eaf49f8 100644 --- a/src/__tests__/fake-timers.js +++ b/src/__tests__/fake-timers.js @@ -79,3 +79,42 @@ test('recursive timers do not cause issues', async () => { recurse = false }) + +test('legacy fake timers do not waitFor requestAnimationFrame', async () => { + jest.useFakeTimers('legacy') + + let exited = false + requestAnimationFrame(() => { + exited = true + }) + + await expect(async () => { + await waitFor(() => { + expect(exited).toBe(true) + }) + }).rejects.toThrowErrorMatchingInlineSnapshot(` + "expect(received).toBe(expected) // Object.is equality + + Expected: true + Received: false + + Ignored nodes: comments,