Files
mal/tests/e2e/global-setup.ts
mkelvers 7701ec5a7e
All checks were successful
Build and Push Container Image / build-and-push (push) Successful in 8m45s
test(e2e): add global setup, sign-in helpers and authenticated page tests
2026-06-25 02:36:19 +02:00

25 lines
769 B
TypeScript

import { spawnSync } from "node:child_process";
const port = process.env.PORT ?? "3100";
export default function globalSetup() {
if (process.env.PLAYWRIGHT_BASE_URL !== undefined) {
return;
}
const username = process.env.E2E_USERNAME ?? "e2e@example.com";
const password = process.env.E2E_PASSWORD ?? "e2e-password";
const databaseFile = process.env.DATABASE_FILE ?? `/tmp/mal-e2e-${port}.db`;
const result = spawnSync("go", ["run", "./cmd/user", username, password], {
env: { ...process.env, DATABASE_FILE: databaseFile, GIN_MODE: "test" },
input: "y\n",
stdio: ["pipe", "pipe", "pipe"],
encoding: "utf8",
});
if (result.status !== 0) {
throw new Error(`Failed to seed e2e user:\n${result.stderr || result.stdout}`);
}
}