import { execFileSync } from 'node:child_process'; /** * Database-backed tests run only when TEST_DATABASE_URL is set (locally: * the compose dev db on port 5434; in CI: the postgres service container). * This setup pushes the current Prisma schema into that database once per * test run; tests skip themselves when the variable is absent. */ export default function globalSetup(): void { const url = process.env.TEST_DATABASE_URL; if (!url) return; execFileSync( process.execPath, [require.resolve('prisma/build/index.js'), 'db', 'push', '--skip-generate'], { env: { ...process.env, DATABASE_URL: url }, stdio: 'inherit', cwd: __dirname }, ); }