Wraps Sinon's standalone @sinonjs/fake-timers library for JS/TS testing: install(), tick() / tickAsync(), setSystemTime(), restore(); covers timers (setTimeout / setInterval / requestAnimationFrame), Date / performance.now() / hrtime, and the toFake option for selective override. Runner-agnostic - drives the clock directly in Mocha, AVA, Jasmine, node:test, or the browser. Use when JS/TS code needs deterministic timer or clock control and the test runner does not already expose this library behind its own built-in fake-timer API.
80
100%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Selective override, absolute clock jumps, and DST/timezone setup extracted from the core skill. Install / tick / tickAsync / teardown usage stays in SKILL.md.
const clock = FakeTimers.install({
now: new Date('2026-05-20T14:30:00Z').getTime(),
toFake: ['setTimeout', 'setInterval', 'Date'], // not 'performance', 'hrtime'
});Useful when you want real performance.now() for benchmarking but fake Date.
clock.setSystemTime(new Date('2027-01-01T00:00:00Z'));
expect(new Date().toISOString()).toBe('2027-01-01T00:00:00.000Z');Jumps the clock without ticking any in-flight timers.
@sinonjs/fake-timers fakes UTC time; for local-zone DST
behaviour, set process.env.TZ first, then install at the UTC
instant of the transition.
process.env.TZ = 'America/New_York';
const clock = FakeTimers.install({
now: new Date('2026-03-08T06:30:00Z').getTime(), // 02:30 EDT - invalid local
});
// ... test that scheduling at 02:30 local degrades gracefullyThe test verifies behaviour at the transition (see the dst-transition-reference skill); the fake clock makes it reproducible.