diff --git a/src/utils/__tests__/backoffMachine-test.js b/src/utils/__tests__/backoffMachine-test.js index 1cfb5836c90..dad6f037b72 100644 --- a/src/utils/__tests__/backoffMachine-test.js +++ b/src/utils/__tests__/backoffMachine-test.js @@ -1,6 +1,5 @@ /* @flow strict-local */ import { BackoffMachine } from '../async'; -import { Lolex } from '../../__tests__/lib/lolex'; // Since BackoffMachine is in async.js, these tests *should* be in // async-test.js. But doing that introduces some interference between these @@ -10,20 +9,17 @@ import { Lolex } from '../../__tests__/lib/lolex'; // (https://github.com/facebook/jest/pull/8897). But as of 2020-03, putting them // in a separate file is our workaround. -describe('BackoffMachine', () => { - const lolex: Lolex = new Lolex(); +jest.useFakeTimers('modern'); +describe('BackoffMachine', () => { afterEach(() => { - lolex.clearAllTimers(); - }); - - afterAll(() => { - lolex.dispose(); + expect(jest.getTimerCount()).toBe(0); + jest.clearAllTimers(); }); const measureWait = async (promise: Promise) => { const start = Date.now(); - lolex.runOnlyPendingTimers(); + jest.runOnlyPendingTimers(); await promise; return Date.now() - start; };