Skip to content

Commit

Permalink
backoffMachine tests: Remove Lolex.
Browse files Browse the repository at this point in the history
Use Jest's "modern" fake timers instead of our Lolex wrapper.
  • Loading branch information
chrisbobbe committed Apr 13, 2021
1 parent 12812fb commit ad10c37
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions 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
Expand All @@ -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<void>) => {
const start = Date.now();
lolex.runOnlyPendingTimers();
jest.runOnlyPendingTimers();
await promise;
return Date.now() - start;
};
Expand Down

0 comments on commit ad10c37

Please sign in to comment.