import { execFileSync } from "node:child_process"; /** * Applies migrations and loads the dev/demo seed data against whatever * DATABASE_URL points at before the suite runs. Deliberately does not * create or tear down the database itself — same division of * responsibility as `npm run test:integration`, where the caller is * responsible for pointing DATABASE_URL at a disposable Postgres. */ export default function globalSetup() { if (!process.env.DATABASE_URL) { throw new Error( "DATABASE_URL is not set. Point it at a disposable Postgres before running the e2e suite, e.g.\n" + ' DATABASE_URL="postgresql://user:pass@localhost:5432/nextchair_e2e" npm run test:e2e', ); } const env = { ...process.env }; execFileSync("npx", ["prisma", "migrate", "deploy"], { stdio: "inherit", env }); execFileSync("npx", ["tsx", "prisma/seed.ts"], { stdio: "inherit", env }); }