{"id":"702b56054fcf6121","repo":"jestjs/jest","slug":"jest-getrealsystemtime-is-not-available-when-u","errorCode":null,"errorMessage":"`jest.getRealSystemTime()` is not available when using legacy fake timers.","messagePattern":"`jest\\.getRealSystemTime\\(\\)` is not available when using legacy fake timers\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/jest-runtime/src/internals/JestGlobals.ts","lineNumber":348,"sourceCode":"      },\n      autoMockOff: disableAutomock,\n      autoMockOn: enableAutomock,\n      clearAllMocks,\n      clearAllTimers: () => _getFakeTimers().clearAllTimers(),\n      createMockFromModule: moduleName => this.generateMock(from, moduleName),\n      deepUnmock,\n      disableAutomock,\n      doMock: mock,\n      dontMock: unmock,\n      enableAutomock,\n      fn,\n      getRealSystemTime: () => {\n        const fakeTimers = _getFakeTimers();\n\n        if (fakeTimers === this.environment.fakeTimersModern) {\n          return fakeTimers.getRealSystemTime();\n        } else {\n          throw new TypeError(\n            '`jest.getRealSystemTime()` is not available when using legacy fake timers.',\n          );\n        }\n      },\n      getSeed: () => this.globalConfig.seed,\n      getTimerCount: () => _getFakeTimers().getTimerCount(),\n      isEnvironmentTornDown: () => this.testState.isTornDown(),\n      isMockFunction: this.moduleMocker.isMockFunction,\n      isolateModules,\n      isolateModulesAsync,\n      mock,\n      mocked,\n      now: () => _getFakeTimers().now(),\n      onGenerateMock,\n      replaceProperty,\n      requireActual: moduleName => this.requireActualBridge(from, moduleName),\n      requireMock: moduleName => this.requireMockBridge(from, moduleName),\n      resetAllMocks,","sourceCodeStart":330,"sourceCodeEnd":366,"githubUrl":"https://github.com/jestjs/jest/blob/f49721c78e195558b40913977c9230f5b7f559d8/packages/jest-runtime/src/internals/JestGlobals.ts#L330-L366","documentation":"TypeError thrown by `jest.getRealSystemTime()` when legacy fake timers are active. Reading the real system clock while faking time is a modern-fake-timers-only feature; the legacy implementation does not expose it.","triggerScenarios":"Calling `jest.getRealSystemTime()` with `legacyFakeTimers: true` set in config or via `useFakeTimers`.","commonSituations":"Logging or seeding real timestamps inside a fake-timer test where the project defaulted to legacy timers; profiling code that reads real time between fake ticks.","solutions":["Switch to modern fake timers: `jest.useFakeTimers()` (default).","If you must keep legacy timers, capture `Date.now()` or `performance.now()` before `useFakeTimers` and reuse that reference."],"exampleFix":"// before\njest.useFakeTimers({ legacyFakeTimers: true });\nconst real = jest.getRealSystemTime(); // throws\n\n// after\njest.useFakeTimers();\nconst real = jest.getRealSystemTime();","handlingStrategy":"validation","validationCode":"// Capture real time before faking if you may run under legacy timers\nconst realStart = Date.now();\njest.useFakeTimers(); // modern; then jest.getRealSystemTime() is available","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use modern fake timers (default) to access getRealSystemTime.","If legacy is required, snapshot Date.now() before useFakeTimers."],"tags":["fake-timers","legacy","time","config"],"analyzedSha":"f49721c78e195558b40913977c9230f5b7f559d8","analyzedAt":"2026-08-03T20:16:28.571Z","schemaVersion":2}