From c693cd29ef35b511bb9afdf6a842fe8b450cf427 Mon Sep 17 00:00:00 2001 From: Chris Bobbe Date: Wed, 15 Jul 2020 16:29:31 -0700 Subject: [PATCH] backoffMachine tests: Remove Lolex. Use Jest's "modern" fake timers instead of our Lolex wrapper. --- src/utils/__tests__/backoffMachine-test.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) 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; };