Three flaky tests eliminated from CI pipeline
A trio of unreliable tests that together caused roughly 200 CI failures across 40-plus branches over the past week have been stabilized.
The test suite was generating noise. Three separate tests failed intermittently in CI — sometimes because a timestamp drifted by a millisecond between function calls, sometimes because a cache miss triggered a real network request that timed out under CI constraints, and sometimes because test isolation hooks weren't properly applied. Each failure cascaded: flaky tests mean failed branches, failed branches mean blocked developers.
These three tests have now been rewritten with deterministic behavior. Timestamps use fake timers instead of the real clock, eliminating race conditions. External network calls are mocked so tests complete in milliseconds rather than waiting for timeouts. Network isolation is properly configured so tests can't leak requests to live APIs. The testing infrastructure is more reliable — developers pushing branches should see consistent results regardless of timing quirks or network conditions in CI workers.
The changes touch three separate packages in the monorepo: the ExecutionPersistence tests, the TypeScript Worker tests, and the GoogleSheetsTrigger tests.
View Original GitHub Description
Summary
Fix three flaky unit tests that accounted for ~200 CI failures across 40+ branches in the last 7 days (data from Codecov test analytics).
1. ExecutionPersistence — timestamp off-by-one (15 failures / 15 branches)
The test captured Date.now() after calling the function under test, then asserted the backdated deletedAt was <= that value minus the buffer. When the clock ticked by 1ms between the implementation's and the test's Date.now() calls, the assertion failed. Fixed by using Jest fake timers so Date.now() is deterministic.
2. TypeScript Worker — CDN fetch timeout (8 failures / 8 branches)
The test didn't mock indexedDbCache, so it opened real IndexedDB via fake-indexeddb. When the luxon type cache missed, the worker tried to fetch types from cdn.jsdelivr.net, which timed out under CI network constraints. Fixed by mocking the cache module with a cache hit, eliminating both IndexedDB and network overhead (tests now run in 9ms vs timing out at 5000ms).
3. GoogleSheetsTrigger — missing nock isolation (23 failures each × 5 tests / 8 branches)
The test file was missing nock.disableNetConnect(). While globalSetup.ts calls it, Jest runs global setup in a separate context from test workers. Without it, unmatched requests could leak to the real Google Sheets API. Fixed by adding proper nock lifecycle hooks (disableNetConnect, cleanAll, enableNetConnect).
Related Linear tickets, Github issues, and Community forum posts
N/A — identified via Codecov test analytics API flaky test analysis.
Review / Merge checklist
- I have seen this code, I have run this code, and I take responsibility for this code.
- PR title and summary are descriptive. (conventions)
- Docs updated or follow-up ticket created.
- Tests included.