Skip to content

Commit 98ed317

Browse files
committed
test(jest): set timezone for stable snapshots
Signed-off-by: Adam Setch <[email protected]>
1 parent a2462cd commit 98ed317

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

jest.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Config } from 'jest';
22

33
const config: Config = {
44
preset: 'ts-jest',
5+
globalSetup: '<rootDir>/src/renderer/__helpers__/jest.setup.env.ts',
56
setupFilesAfterEnv: ['<rootDir>/src/renderer/__helpers__/jest.setup.ts'],
67
testEnvironment: 'jsdom',
78
collectCoverage: true,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,4 @@
141141
"*": "biome check --fix --no-errors-on-unmatched",
142142
"*.{js,ts,tsx}": "pnpm test --findRelatedTests --passWithNoTests --updateSnapshot"
143143
}
144-
}
144+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* Jest Global Setup
3+
* This runs once before all test suites
4+
* Sets timezone to UTC for consistent date/time in tests and snapshots
5+
*/
6+
export default () => {
7+
process.env.TZ = 'UTC';
8+
};

src/renderer/__helpers__/jest.setup.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ window.gitify = {
4545
raiseNativeNotification: jest.fn(),
4646
};
4747

48-
// Mock OAuth client ID and secret
49-
process.env.OAUTH_CLIENT_ID = 'FAKE_CLIENT_ID_123';
50-
process.env.OAUTH_CLIENT_SECRET = 'FAKE_CLIENT_SECRET_123';
51-
5248
globalThis.HTMLMediaElement.prototype.play = jest.fn();
5349

5450
globalThis.matchMedia = (query: string): MediaQueryList => ({

0 commit comments

Comments
 (0)