jestjs/jest · error · TypeError

`jest.setTimerTickMode()` is not available when using legacy

Error message

`jest.setTimerTickMode()` is not available when using legacy fake timers.

What it means

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.

Source

Thrown at packages/jest-runtime/src/internals/JestGlobals.ts:428

        if (fakeTimers === this.environment.fakeTimersModern) {
          fakeTimers.setSystemTime(now);
        } else {
          throw new TypeError(
            '`jest.setSystemTime()` is not available when using legacy fake timers.',
          );
        }
      },
      setTimeout,
      setTimerTickMode: (
        mode:
          | {mode: 'manual' | 'nextAsync'}
          | {mode: 'interval'; delta?: number},
      ) => {
        const fakeTimers = _getFakeTimers();
        if (fakeTimers === this.environment.fakeTimersModern) {
          fakeTimers.setTimerTickMode(mode);
        } else {
          throw new TypeError(
            '`jest.setTimerTickMode()` is not available when using legacy fake timers.',
          );
        }
        return jestObject;
      },
      spyOn,
      unmock,
      unstable_mockModule: mockModule,
      unstable_unmockModule: unmockModule,
      useFakeTimers,
      useRealTimers,
    };
    return jestObject;
  }
}

View on GitHub (pinned to f49721c78e)

Solutions

  1. Switch to modern fake timers: `jest.useFakeTimers()` (default).
  2. If you must keep legacy timers, you cannot use tick modes — structure the test around explicit `advanceTimersByTime` calls instead.

Example fix

// before
jest.useFakeTimers({ legacyFakeTimers: true });
jest.setTimerTickMode({ mode: 'manual' }); // throws

// after
jest.useFakeTimers();
jest.setTimerTickMode({ mode: 'manual' });
Defensive patterns

Strategy: validation

Validate before calling

// setTimerTickMode is modern-only
jest.useFakeTimers(); // modern
jest.setTimerTickMode({ mode: 'manual' });

Prevention

When it happens

Trigger: Calling `jest.setTimerTickMode({ mode: 'manual' })` (or any mode) while `legacyFakeTimers: true` is in effect.

Common situations: Fine-grained timer control in tests that share a config defaulting to legacy timers; using tick modes to coordinate async timer flushing.

Related errors


AI-assisted analysis of jestjs/jest@f49721c78e (2026-08-03). Data as JSON: /data/errors/06f2b9f2cc699b36.json. Report an issue: GitHub.