19 lines
562 B
TypeScript
19 lines
562 B
TypeScript
import { execSync } from "child_process";
|
|
import { join } from "path";
|
|
|
|
/**
|
|
* Vitest global setup — bring the test database schema up to date via Prisma
|
|
* migrations before any test runs. Runs once for the whole suite.
|
|
*/
|
|
export default function setup() {
|
|
const backendRoot = join(__dirname, "../..");
|
|
const dbUrl =
|
|
process.env.TEST_DATABASE_URL ||
|
|
"postgresql://patchpass:patchpass@localhost:5433/patchpass_test";
|
|
execSync("npx prisma migrate deploy", {
|
|
cwd: backendRoot,
|
|
env: { ...process.env, DATABASE_URL: dbUrl },
|
|
stdio: "inherit",
|
|
});
|
|
}
|