diff --git a/integration_tests/request_animation_frame/__tests__/request_animation_frame.test.js b/integration_tests/request_animation_frame/__tests__/request_animation_frame.test.js index 4c16ba8756dc..8f1ff5cbfabf 100644 --- a/integration_tests/request_animation_frame/__tests__/request_animation_frame.test.js +++ b/integration_tests/request_animation_frame/__tests__/request_animation_frame.test.js @@ -12,8 +12,9 @@ test('requestAnimationFrame test', done => { expect.hasAssertions(); - requestAnimationFrame(() => { + requestAnimationFrame(timestamp => { expect(true).toBe(true); + expect(timestamp).toBeGreaterThan(0); done(); }); diff --git a/packages/jest-environment-jsdom/src/index.js b/packages/jest-environment-jsdom/src/index.js index 9427d1313c77..f03b6543c92b 100644 --- a/packages/jest-environment-jsdom/src/index.js +++ b/packages/jest-environment-jsdom/src/index.js @@ -22,6 +22,7 @@ class JSDOMEnvironment { moduleMocker: ?ModuleMocker; constructor(config: ProjectConfig): void { + const jsdomInitialized = process.hrtime(); // lazy require this.document = JSDom.jsdom('', { url: config.testURL, @@ -34,7 +35,11 @@ class JSDOMEnvironment { if (!global.requestAnimationFrame) { global.requestAnimationFrame = callback => { - global.setTimeout(callback, 0); + const hr = process.hrtime(jsdomInitialized); + const hrInNano = hr[0] * 1e9 + hr[1]; + const hrInMicro = hrInNano / 1e6; + + return global.setTimeout(callback, 0, hrInMicro); }; }