From 3108b2f3362bb9a0f40273f68fe8e99f27b1d66f Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Wed, 29 Jul 2026 13:31:56 +1200 Subject: [PATCH] fix: avoid leaving TZ="undefined" when restoring an unset timezone process.env coerces assigned values to strings, so process.env.TZ = originalTZ left the literal string "undefined" behind (instead of clearing TZ) when it was unset before the test ran. Delete the var in that case instead of assigning undefined. --- lib/__tests__/forward-as-attachment.test.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/__tests__/forward-as-attachment.test.ts b/lib/__tests__/forward-as-attachment.test.ts index 40d3d5d7..ceec2b7f 100644 --- a/lib/__tests__/forward-as-attachment.test.ts +++ b/lib/__tests__/forward-as-attachment.test.ts @@ -10,7 +10,10 @@ beforeAll(() => { process.env.TZ = 'UTC'; }); afterAll(() => { - process.env.TZ = originalTZ; + // process.env coerces to strings, so `= undefined` would leave the literal + // string "undefined" behind when TZ was originally unset - delete instead. + if (originalTZ === undefined) delete process.env.TZ; + else process.env.TZ = originalTZ; }); function makeEmail(overrides: Partial = {}): Email {