flakiness-value

Detect and contain test flakiness caused by time, randomness, and floating-point nondeterminism.

Updated Jun 24, 2026
One-click install
npx skills add https://github.com/Hakkadaikon/hymme --skill flakiness-value-hakkadaikon
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: flakiness-value
Source: https://github.com/Hakkadaikon/hymme/tree/main/skills/flakiness-value
Command: npx skills add https://github.com/Hakkadaikon/hymme --skill flakiness-value-hakkadaikon

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Tests that pass or fail depending on when they run or what values they generate erode trust in the test suite: real regressions get buried in noise and red builds get retried into green. This Skill addresses the value-level sources of flakiness—wall-clock time, random numbers/UUIDs, and floating-point rounding—by making tests deterministic. ## Core Features & Use Cases - Time dependence containment: Inject a clock or use fake timers (vi.setSystemTime), enumerate dangerous boundaries (midnight, month-end, leap day, DST, timezones), and verify with multi-TZ repeated runs. - Randomness and UUID containment: Inject RNG/id generators, iterate over fixed seeds, use property-based testing with fast-check, and assert on shape (length, uniqueness, pattern) instead of concrete values. - Floating-point comparison fixes: Replace strict equality with toBeCloseTo, or store money as integer minor units/decimal types, with grep-based audits and completion checklists defining when containment is done. - Use Case: A Vitest suite fails only near midnight in CI. Use this Skill to inject a clock into the expiry logic, pin boundary times as fixed regression tests, and confirm green across UTC, Asia/Tokyo, and America/New_York with 50 repetitions each. ## Quick Start Ask the AI to apply the flakiness-value techniques to find and fix time, randomness, or floating-point nondeterminism in your flaky Vitest tests.

Frequently Asked Questions about flakiness-value

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

FAQPage Schema
How do I fix flaky tests caused by Date.now or new Date?

Inject a clock (a now function) into the code under test so tests pass fixed timestamps, or use vi.useFakeTimers with vi.setSystemTime when refactoring is not possible. Then pin boundary times like midnight, month-end, and leap day as fixed regression tests.

How to make tests deterministic when code uses Math.random or randomUUID?

Pass the random source or id generator as an argument so tests supply a seeded pseudo-random generator or fixed values. Assert on the shape of generated values (length, uniqueness, pattern) rather than exact values, and iterate many seeds to confirm stability.

Why does 0.1 + 0.2 fail a strict equality assertion in tests?

Binary floating-point rounding makes 0.1 + 0.2 equal 0.30000000000000004, so toBe or === comparisons fail. Use toBeCloseTo with a meaningful digit count, or store money as integer minor units or a decimal type to avoid floats entirely.

How do I detect time-dependent tests in a Vitest suite?

Run the suite repeatedly under different timezones, for example TZ=UTC, TZ=Asia/Tokyo, and TZ=America/New_York with --repeat=50. If results differ by timezone or time of day, the test depends on the current time and needs a fixed clock.

When should I use property-based testing for flaky randomness?

Use fast-check when generated inputs can hide rare failing combinations that fixed seeds miss. Raise numRuns (1000 or more for critical paths) and pin any failing seed and its minimal counterexample as a permanent regression test.

What are the limits of this flakiness containment approach?

It only covers value-level nondeterminism: time, randomness, and floating-point. Concurrency issues, test-order dependencies, shared state leaks, external network calls, and timer/sleep coordination are handled separately by the flakiness-concurrency guidance.