fix: stabilize e2e server startup

This commit is contained in:
Ho Ngoc Hai
2026-05-04 17:34:53 +07:00
parent 388bc972c1
commit 5ed0993f74

View File

@@ -7,11 +7,13 @@ if (!process.env.CI) {
config({ path: path.resolve(__dirname, '.env.test'), override: true });
}
// Server ports configurable via env to avoid conflicts with dev containers.
// Defaults match .env.test (3011/3010); GitHub Actions uses 3001/3000.
// Server ports are configurable via env to avoid conflicts with dev containers.
// GitHub Actions loads .env.test before invoking Playwright.
const API_PORT = process.env.API_PORT ?? '3001';
const WEB_PORT = process.env.WEB_PORT ?? '3000';
const SERVER_STARTUP_TIMEOUT_MS = process.env.CI ? 180_000 : 60_000;
/**
* Playwright E2E configuration for Goodgo Platform.
*
@@ -92,7 +94,7 @@ export default defineConfig({
command: `PORT=${API_PORT} pnpm --filter @goodgo/api run dev`,
url: `http://localhost:${API_PORT}/api/v1/docs`,
reuseExistingServer: !process.env.CI,
timeout: 60_000,
timeout: SERVER_STARTUP_TIMEOUT_MS,
env: {
...process.env as Record<string, string>,
NODE_ENV: 'test',
@@ -105,7 +107,7 @@ export default defineConfig({
cwd: './apps/web',
url: `http://localhost:${WEB_PORT}`,
reuseExistingServer: !process.env.CI,
timeout: 30_000,
timeout: SERVER_STARTUP_TIMEOUT_MS,
env: {
...process.env as Record<string, string>,
PORT: WEB_PORT,