mosh-helpdesk/e2e/global-setup.ts
2026-02-13 08:46:19 -08:00

34 lines
772 B
TypeScript

import { execSync } from "child_process";
import path from "path";
import dotenv from "dotenv";
export default function globalSetup() {
const envPath = path.resolve(__dirname, "../server/.env.test");
const env = dotenv.config({ path: envPath });
console.log("Resetting test database...");
const serverDir = path.resolve(__dirname, "../server");
const execEnv = {
...process.env,
...env.parsed,
PRISMA_USER_CONSENT_FOR_DANGEROUS_AI_ACTION: "Yes",
};
execSync("bunx prisma migrate reset --force", {
cwd: serverDir,
stdio: "inherit",
env: execEnv,
});
console.log("Running seed...");
execSync("bun prisma/seed.ts", {
cwd: serverDir,
stdio: "inherit",
env: execEnv,
});
console.log("Test database ready.");
}