{"id":"06f2b9f2cc699b36","repo":"jestjs/jest","slug":"jest-settimertickmode-is-not-available-when-us","errorCode":null,"errorMessage":"`jest.setTimerTickMode()` is not available when using legacy fake timers.","messagePattern":"`jest\\.setTimerTickMode\\(\\)` 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":428,"sourceCode":"        if (fakeTimers === this.environment.fakeTimersModern) {\n          fakeTimers.setSystemTime(now);\n        } else {\n          throw new TypeError(\n            '`jest.setSystemTime()` is not available when using legacy fake timers.',\n          );\n        }\n      },\n      setTimeout,\n      setTimerTickMode: (\n        mode:\n          | {mode: 'manual' | 'nextAsync'}\n          | {mode: 'interval'; delta?: number},\n      ) => {\n        const fakeTimers = _getFakeTimers();\n        if (fakeTimers === this.environment.fakeTimersModern) {\n          fakeTimers.setTimerTickMode(mode);\n        } else {\n          throw new TypeError(\n            '`jest.setTimerTickMode()` is not available when using legacy fake timers.',\n          );\n        }\n        return jestObject;\n      },\n      spyOn,\n      unmock,\n      unstable_mockModule: mockModule,\n      unstable_unmockModule: unmockModule,\n      useFakeTimers,\n      useRealTimers,\n    };\n    return jestObject;\n  }\n}\n","sourceCodeStart":410,"sourceCodeEnd":444,"githubUrl":"https://github.com/jestjs/jest/blob/f49721c78e195558b40913977c9230f5b7f559d8/packages/jest-runtime/src/internals/JestGlobals.ts#L410-L444","documentation":"TypeError thrown by `jest.setTimerTickMode()` when legacy fake timers are active. `setTimerTickMode` controls how the modern fake timers backend advances time per macrotask (manual/nextAsync/interval modes) and has no legacy equivalent.","triggerScenarios":"Calling `jest.setTimerTickMode({ mode: 'manual' })` (or any mode) while `legacyFakeTimers: true` is in effect.","commonSituations":"Fine-grained timer control in tests that share a config defaulting to legacy timers; using tick modes to coordinate async timer flushing.","solutions":["Switch to modern fake timers: `jest.useFakeTimers()` (default).","If you must keep legacy timers, you cannot use tick modes — structure the test around explicit `advanceTimersByTime` calls instead."],"exampleFix":"// before\njest.useFakeTimers({ legacyFakeTimers: true });\njest.setTimerTickMode({ mode: 'manual' }); // throws\n\n// after\njest.useFakeTimers();\njest.setTimerTickMode({ mode: 'manual' });","handlingStrategy":"validation","validationCode":"// setTimerTickMode is modern-only\njest.useFakeTimers(); // modern\njest.setTimerTickMode({ mode: 'manual' });","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use modern fake timers when you need tick modes.","Centralize timer configuration so legacy vs modern is decided once."],"tags":["fake-timers","legacy","tick-mode","config"],"analyzedSha":"f49721c78e195558b40913977c9230f5b7f559d8","analyzedAt":"2026-08-03T20:16:28.571Z","schemaVersion":2}