testing-standards

Enforce fake timers for deterministic time-dependent tests in JavaScript/TypeScript projects.

1|Updated Jul 31, 2025
One-click install
npx skills add https://github.com/hughescr/claude-code-config --skill testing-standards-hughescr
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-standards
Source: https://github.com/hughescr/claude-code-config/tree/main/plugins/javascript/skills/testing-standards
Command: npx skills add https://github.com/hughescr/claude-code-config --skill testing-standards-hughescr

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill standardizes testing practices for JavaScript/TypeScript projects by mandating the use of fake timers to ensure deterministic, fast tests.

Core Features & Use Cases

  • Mandatory fake timers: Enforces using bun:test (or Jest-compatible APIs) to mock timers for time-dependent code.
  • Pattern guidance: Provides patterns for debounce, throttle, setInterval, setTimeout, and Date.now usage to ensure deterministic behavior.
  • Use Case: When validating a timer-based feature, apply this Skill to reliably simulate time progression and verify outcomes without real delays.

Quick Start

Use the testing-standards skill to configure tests to run with fake timers, illustrate by initializing fake timers, advancing time, and asserting expected callbacks or state changes.

Frequently Asked Questions about testing-standards

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I test setTimeout and setInterval callbacks deterministically in JavaScript?

Test setTimeout and setInterval deterministically by using fake timers to mock time progression, advancing the clock manually, and asserting expected callbacks or state changes without real delays. This Skill enforces those patterns for JS/TS projects.

What's the best way to mock Date.now in TypeScript unit tests?

Mock Date.now in TypeScript unit tests by applying concrete fake-timer patterns that intercept time-dependent calls. This Skill provides specific mock implementations for Date.now to ensure fast, deterministic test outcomes.

How do I unit test debounce and throttle functions without waiting?

Unit test debounce and throttle functions without waiting by configuring fake timers to simulate time progression. This Skill provides concrete patterns to advance time and verify throttled or debounced callbacks reliably.

Does this fake-timer testing approach work with bun test?

Yes, this fake-timer testing approach works with bun test. It uses bun:test APIs to mock timers in Node environments, enforcing reliable time-dependent testing for JavaScript and TypeScript projects.

Why are my time-dependent JavaScript tests flaky?

Time-dependent JavaScript tests are flaky because they rely on real delays. Enforcing fake-timer usage eliminates real-time dependencies, ensuring deterministic, fast tests by simulating time progression manually for setTimeout, setInterval, and Date.now.