MCPcopy
hub / github.com/jestjs/jest / _checkFakeTimers

Method _checkFakeTimers

packages/jest-fake-timers/src/legacyFakeTimers.ts:423–438  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

421 }
422
423 private _checkFakeTimers() {
424 if (!this._fakingTime) {
425 this._global.console.warn(
426 'A function to advance timers was called but the timers APIs are not mocked ' +
427 'with fake timers. Call `jest.useFakeTimers({legacyFakeTimers: true})` ' +
428 'in this test file or enable fake timers for all tests by setting ' +
429 "{'enableGlobally': true, 'legacyFakeTimers': true} in " +
430 `Jest configuration file.\nStack Trace:\n${formatStackTrace(
431 // eslint-disable-next-line unicorn/error-message
432 new Error().stack!,
433 this._config,
434 {noStackTrace: false},
435 )}`,
436 );
437 }
438 }
439
440 #createMockFunction<T extends FunctionLike = UnknownFunction>(
441 implementation: T,

Callers 6

runAllTicksMethod · 0.95
runAllImmediatesMethod · 0.95
runAllTimersMethod · 0.95
runOnlyPendingTimersMethod · 0.95
advanceTimersByTimeMethod · 0.95
getTimerCountMethod · 0.95

Calls 2

formatStackTraceFunction · 0.90
warnMethod · 0.45

Tested by

no test coverage detected