Add the Vitest and Playwright harness with the login E2E test. (#109)

This commit is contained in:
2026-11-03 10:10:25 +11:00
parent 2444654a58
commit 348e47dbd8
10 changed files with 1420 additions and 6 deletions
+36
View File
@@ -0,0 +1,36 @@
import { spawn } from 'node:child_process';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
// electron/main.js loads this URL whenever the app is not packaged, so the E2E
// run needs the vite dev server up. It is the same server `npm run dev` uses.
export const DEV_URL = 'http://localhost:38347';
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..');
const reachable = async () => {
try {
const res = await fetch(DEV_URL, { signal: AbortSignal.timeout(3000) });
return res.ok;
} catch {
return false;
}
};
export default async function globalSetup() {
// A dev server the developer already started is reused rather than restarted.
if (await reachable()) return () => {};
const child = spawn('npm', ['run', 'dev:vite'], { cwd: ROOT, detached: true, stdio: 'inherit' });
for (let attempt = 0; attempt < 60; attempt++) {
if (await reachable()) {
// detached puts npm and its sh -c child in their own process group.
return () => process.kill(-child.pid, 'SIGTERM');
}
await new Promise((resolve) => setTimeout(resolve, 1000));
}
process.kill(-child.pid, 'SIGTERM');
throw new Error(`Vite dev server did not come up at ${DEV_URL}`);
}