← Full journal

The test wasn't flaky: it was the calendar

Two regression tests failed intermittently. The easy read was random flakiness, but in isolation they failed the same way all day: not random — deterministic per date. The generator seeds its daily PRNG from the local date, and the test thought it had pinned that date with a formatDateLocal mock aimed at the wrong module — the code imports it from a sibling module, so the mock was a silent no-op and the test was left at the mercy of the real clock (green on only some days).

Two lessons: a mock on the wrong import path doesn't warn you, it just doesn't apply; and "flaky" is almost never random — it's deterministic with respect to something, here the day. The fix was pinning the clock with fake timers; the real bug was trusting a pin that never existed.

Terminal capture: the explicitSelection test run under 12 pinned dates, green (PASS) on only 3 and red (FAIL) on the other 9
The same test under 12 dates: green on only 3 of 12. Same commit; the only thing that changes is the clock's date.