From 9f9663682dedc507b8207c4737c903c01251c4b7 Mon Sep 17 00:00:00 2001 From: Christian Fehmer Date: Thu, 8 Aug 2024 12:10:11 +0200 Subject: [PATCH] chore: fix tests using machine timezone (@fehmer) (#5740) --- .eslintignore | 1 + backend/__tests__/global-setup.ts | 3 ++- frontend/__tests__/global-setup.ts | 3 +++ frontend/vitest.config.js | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 frontend/__tests__/global-setup.ts diff --git a/.eslintignore b/.eslintignore index 1003a5fae..26f7c9ee6 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,3 +2,4 @@ backend/dist backend/__migration__ docker backend/scripts +**/vitest.config.js diff --git a/backend/__tests__/global-setup.ts b/backend/__tests__/global-setup.ts index 461ccb2f4..573bff62c 100644 --- a/backend/__tests__/global-setup.ts +++ b/backend/__tests__/global-setup.ts @@ -1,5 +1,6 @@ import * as MongoDbMock from "vitest-mongodb"; -export async function setup({ provide }): Promise { +export async function setup(): Promise { + process.env.TZ = "UTC"; await MongoDbMock.setup({ serverOptions: { binary: { diff --git a/frontend/__tests__/global-setup.ts b/frontend/__tests__/global-setup.ts new file mode 100644 index 000000000..89d5cfe50 --- /dev/null +++ b/frontend/__tests__/global-setup.ts @@ -0,0 +1,3 @@ +export const setup = () => { + process.env.TZ = "UTC"; +}; diff --git a/frontend/vitest.config.js b/frontend/vitest.config.js index 5351a7ac9..3d607161a 100644 --- a/frontend/vitest.config.js +++ b/frontend/vitest.config.js @@ -4,6 +4,7 @@ export default defineConfig({ test: { globals: true, environment: "happy-dom", + globalSetup: "__tests__/global-setup.ts", setupFiles: ["__tests__/setup-tests.ts"], coverage: {