From cc79999a31b46e68a4dca5d536fc2fb4fe3d5199 Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Fri, 14 Feb 2020 16:54:29 +0100 Subject: [PATCH] fix: force timezone to be UTC for tests (#38215) react-calendar-heatmap's output depends on the timezone, which means that snapshots can fail if the timezone changes. This sets the timezone as UTC during client tests to avoid that problem. --- client/jest-timezone-setup.js | 3 +++ client/jest.config.js | 1 + client/jest.test.js | 6 ++++++ 3 files changed, 10 insertions(+) create mode 100644 client/jest-timezone-setup.js create mode 100644 client/jest.test.js diff --git a/client/jest-timezone-setup.js b/client/jest-timezone-setup.js new file mode 100644 index 0000000000..6e1fbf41d0 --- /dev/null +++ b/client/jest-timezone-setup.js @@ -0,0 +1,3 @@ +module.exports = async () => { + process.env.TZ = 'UTC'; +}; diff --git a/client/jest.config.js b/client/jest.config.js index 86cabeba97..0922809dd1 100644 --- a/client/jest.config.js +++ b/client/jest.config.js @@ -12,6 +12,7 @@ module.exports = { globals: { __PATH_PREFIX__: '' }, + globalSetup: './jest-timezone-setup.js', verbose: true, transform: { '^.+\\.js$': '/jest.transform.js' diff --git a/client/jest.test.js b/client/jest.test.js new file mode 100644 index 0000000000..9819289191 --- /dev/null +++ b/client/jest.test.js @@ -0,0 +1,6 @@ +/* global expect */ +describe('Timezones', () => { + it('should always be UTC', () => { + expect(new Date().getTimezoneOffset()).toBe(0); + }); +});