From b97a68edfb380e174b00db6214565339f63bd023 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 23 Apr 2026 18:59:23 +0300 Subject: [PATCH] test(e2e): add globalSetup to run prisma migrate reset before e2e suite Adds tests/e2e/global-setup.ts which loads .env.test and runs prisma migrate reset --force before the test suite starts. This ensures the test database schema is always clean and up-to-date when targeting a separate test database. --- tests/e2e/global-setup.ts | 10 ++++++++++ vitest.e2e.config.ts | 1 + 2 files changed, 11 insertions(+) create mode 100644 tests/e2e/global-setup.ts diff --git a/tests/e2e/global-setup.ts b/tests/e2e/global-setup.ts new file mode 100644 index 0000000..3248814 --- /dev/null +++ b/tests/e2e/global-setup.ts @@ -0,0 +1,10 @@ +import { execSync } from "node:child_process"; +import { config } from "dotenv"; + +export default function setup(): void { + const { parsed } = config({ path: ".env.test" }); + execSync("npx prisma migrate reset --force", { + stdio: "inherit", + env: { ...process.env, ...parsed }, + }); +} diff --git a/vitest.e2e.config.ts b/vitest.e2e.config.ts index 9fe9d82..cf0a80d 100644 --- a/vitest.e2e.config.ts +++ b/vitest.e2e.config.ts @@ -9,6 +9,7 @@ export default defineConfig({ globals: true, environment: "node", include: ["tests/e2e/**/*.test.ts", "tests/e2e/**/*.spec.ts"], + globalSetup: ["tests/e2e/global-setup.ts"], setupFiles: ["tests/e2e/setup.ts"], testTimeout: 30000, hookTimeout: 30000,