diff --git a/CHANGELOG.md b/CHANGELOG.md index 59327bcc66b9..af509dc47089 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/packages/jest-fake-timers/src/legacyFakeTimers.ts b/packages/jest-fake-timers/src/legacyFakeTimers.ts index 66be88c2518f..cb7a2abab30c 100644 --- a/packages/jest-fake-timers/src/legacyFakeTimers.ts +++ b/packages/jest-fake-timers/src/legacyFakeTimers.ts @@ -94,7 +94,6 @@ export default class FakeTimers { }; this.reset(); - this._createMocks(); } clearAllTimers(): void { @@ -349,7 +348,7 @@ export default class FakeTimers { } 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 ` +