From 90648a3f605d7bc860bc8b90cd5eb8958c9e0179 Mon Sep 17 00:00:00 2001 From: Harry Hogg Date: Mon, 13 Sep 2021 10:35:32 +0100 Subject: [PATCH] chore(backstage-cli): Set global jest timezone to UTC Signed-off-by: Harry Hogg --- packages/cli/src/commands/testCommand.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/cli/src/commands/testCommand.ts b/packages/cli/src/commands/testCommand.ts index d885e1aec9..24a4e06f9e 100644 --- a/packages/cli/src/commands/testCommand.ts +++ b/packages/cli/src/commands/testCommand.ts @@ -63,6 +63,13 @@ export default async (cmd: Command) => { (process.env as any).NODE_ENV = 'test'; } + // This is to have a consistent timezone for when running tests that involve checking + // the formatting of date/times. + // https://stackoverflow.com/questions/56261381/how-do-i-set-a-timezone-in-my-jest-config + if (!process.env.TZ) { + process.env.TZ = 'UTC'; + } + // eslint-disable-next-line jest/no-jest-import await require('jest').run(args); };