import path from "node:path" import { fileURLToPath } from "node:url" import dotenv from "dotenv" const __filename = fileURLToPath(import.meta.url) const __dirname = path.dirname(__filename) dotenv.config({ path: path.join(__dirname, "../../.env") }) function getEnvVar(name: string): string { const value = process.env[name] if (!value) { throw new Error(`Environment variable ${name} is undefined`) } return value } export const firstSuperuser = getEnvVar("FIRST_SUPERUSER") export const firstSuperuserPassword = getEnvVar("FIRST_SUPERUSER_PASSWORD") /** * The two origins a run talks to: the app in the browser, and the API for the * setup and teardown around a spec. * * Deliberately *not* taken from `../../.env` above, which in a checkout * configured for a deployment names the deployment. A suite reading it would * drive a browser at the local stack while sending its `DELETE`s to the live * instance. Both origins come from the same place instead: whatever the browser * is pointed at is what teardown may write to. */ export const appUrl = process.env.PLAYWRIGHT_BASE_URL || "http://app.test.localhost" /** The API is a path on the origin that serves the dashboard. */ export const apiUrl = process.env.PLAYWRIGHT_API_URL || new URL(appUrl).origin