Skip to content

Commit

Permalink
refactor(fake-timers): don't setup fakeTimerAPIs unless needed (#10551)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgriesser authored Oct 19, 2020
1 parent 621ecf7 commit ecb31a7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

### Fixes

- `[jest-fake-timers]` Lazily instantiate mock timers ([#10551](https://github.com/facebook/jest/pull/10551))
- `[jest-runtime]` `require.main` is no longer `undefined` when using `jest.resetModules` ([#10626](https://github.com/facebook/jest/pull/10626))
- `[@jest/types]` Add missing values for `timers` ([#10632](https://github.com/facebook/jest/pull/10632))

Expand Down
3 changes: 1 addition & 2 deletions packages/jest-fake-timers/src/legacyFakeTimers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ export default class FakeTimers<TimerRef> {
};

this.reset();
this._createMocks();
}

clearAllTimers(): void {
Expand Down Expand Up @@ -349,7 +348,7 @@ export default class FakeTimers<TimerRef> {
}

private _checkFakeTimers() {
if (this._global.setTimeout !== this._fakeTimerAPIs.setTimeout) {
if (this._global.setTimeout !== this._fakeTimerAPIs?.setTimeout) {
this._global.console.warn(
`A function to advance timers was called but the timers API is not ` +
`mocked with fake timers. Call \`jest.useFakeTimers()\` in this ` +
Expand Down

0 comments on commit ecb31a7

Please sign in to comment.