Skip to content
Critiq Docs

Search docs

Search documentation pages and rules

quality.testing

Prefer fake timers in unit tests

Real timers, sleeps, or wall-clock reads in unit tests are flaky unless fake timers are enabled for the file.

#Metadata

Rule ID
ts.testing.no-flaky-timer-test
Severity
low
Confidence
0.68
Languages
javascript, typescript
Presets
recommended, strict
Stability
experimental
Applies to
block
Tags
quality, rules-catalog, testing, timers

#Why it matters

Wall-clock based tests race CI load and parallelization; fake timers keep behavior deterministic.

#Remediation

Enable fake timers for the suite, inject a clock abstraction, or move timing assertions behind a test double.

#Repository path

The generated metadata points to critiq-rules/libs/rules/catalog/rules/typescript/ts.testing.no-flaky-timer-test.rule.yaml.