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.
This commit is contained in:
Oliver Eyton-Williams 2020-02-14 16:54:29 +01:00 committed by GitHub
parent 701bbc2ae9
commit cc79999a31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 0 deletions

View File

@ -0,0 +1,3 @@
module.exports = async () => {
process.env.TZ = 'UTC';
};

View File

@ -12,6 +12,7 @@ module.exports = {
globals: {
__PATH_PREFIX__: ''
},
globalSetup: './jest-timezone-setup.js',
verbose: true,
transform: {
'^.+\\.js$': '<rootDir>/jest.transform.js'

6
client/jest.test.js Normal file
View File

@ -0,0 +1,6 @@
/* global expect */
describe('Timezones', () => {
it('should always be UTC', () => {
expect(new Date().getTimezoneOffset()).toBe(0);
});
});