Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(fake-timers): don't setup fakeTimerAPIs unless needed #10551

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/jest-fake-timers/src/legacyFakeTimers.ts
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