-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Closed
Description
π Bug Report
Callbacks scheduled with requestAnimationFrame
are not called when using jest.useFakeTimers('legacy')
and jest.advanceTimersByTime(17)
To Reproduce
test.each(["legacy", "modern"])(
"%s fake timers wait for requestAnimationFrame",
async (timerImplementation) => {
jest.useFakeTimers(timerImplementation);
let exited = false;
// implemented in JSDOm with `setInterval(callback, 16.6666)`
requestAnimationFrame(() => {
exited = true;
});
jest.advanceTimersByTime(15);
expect(exited).toBe(false);
jest.advanceTimersByTime(2);
expect(exited).toBe(true);
}
);
Expected behavior
Tests pass with legacy and modern fake timers
Link to repl or repo (highly encouraged)
https://github.com/eps1lon/jest-fake-timers-request-animation-frame
envinfo
System:
OS: Linux 5.4 Ubuntu 20.04.2 LTS (Focal Fossa)
CPU: (6) x64 Intel(R) Core(TM) i5-9400 CPU @ 2.90GHz
Binaries:
Node: 12.22.1 - ~/.nvm/versions/node/v12.22.1/bin/node
Yarn: 1.22.5 - /usr/bin/yarn
npm: 6.14.12 - ~/.nvm/versions/node/v12.22.1/bin/npm
npmPackages:
jest: ^27.0.4 => 27.0.4