CtrlK
BlogDocsLog inGet started
Tessl Logo
PluginPublic

testland/jest-fake-timers

Wraps Jest's built-in modern fake-timers (built on @sinonjs/fake-timers since Jest 27): jest.useFakeTimers(), jest.setSystemTime(), jest.advanceTimersByTime(), jest.runAllTimers(), and jest.useRealTimers() for selective restoration. Use when testing JS/TS code in Jest where setTimeout / setInterval / Date / Date.now need deterministic control.

80

Quality

100%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide
SecuritybySnyk

Passed

No findings from the security scan

This plugin was archived by the owner on Oct 11, 2026

Reason: Tile archived: Retired from testland/qa (merged into another skill or removed).

Overview
Quality
Evals
Security
Files

advanced-scenarios.mdreferences/

jest fake-timers advanced scenarios

Selective faking, DST/timezone tests, and fake-timer + mocked fetch interplay extracted from the core skill. Enable / advance / run-all usage stays in SKILL.md.

Selective faking

jest.useFakeTimers({
  doNotFake: ['nextTick', 'queueMicrotask'],
  now: new Date('2026-05-20T14:30:00Z').getTime(),
});

DST tests

Set the runtime zone before enabling fake timers, then set system time to the UTC instant of the transition.

beforeAll(() => {
  process.env.TZ = 'America/New_York';
  jest.useFakeTimers();
});

test('spring-forward behaviour', () => {
  jest.setSystemTime(new Date('2026-03-08T06:30:00Z'));  // 02:30 EDT - invalid local
  expect(new Date().toString()).toMatch(/03:30/);  // Browser/Node normalises
});

Mix fake-timers with real fetch

If fetch is mocked separately, ensure the mock awaits a faked timer too:

test('debounce + fetch', async () => {
  global.fetch = jest.fn().mockResolvedValue({ json: () => ({ ok: true }) });

  myDebouncedFetch();

  await jest.advanceTimersByTimeAsync(300);
  expect(fetch).toHaveBeenCalled();
});

SKILL.md

tile.json