diff --git a/playwright.config.ts b/playwright.config.ts index 0aeac7774..d3fee4d9d 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -84,10 +84,12 @@ const config: PlaywrightTestConfig = { webServer: [ { - command: "npm run start -- --strictPort --port 3001", + // Use preview server (pre-built app) for main server - much faster startup + command: "npm run serve -- --strictPort --port 3001", port: 3001, }, // Required by test tests/e2e/repo/commits.spec.ts "loading more commits, adds them to the commits list" + // Keep dev server here since it needs custom runtime config { command: "npm run start -- --strictPort --port 3002", port: 3002, diff --git a/tests/support/globalSetup.ts b/tests/support/globalSetup.ts index 0a9b755dd..abec90ebd 100644 --- a/tests/support/globalSetup.ts +++ b/tests/support/globalSetup.ts @@ -53,6 +53,13 @@ export default async function globalSetup(): Promise<() => void> { process.exit(1); } + // Build the app once before running tests to avoid compilation + // overhead on each worker. + console.log("Building the app for tests..."); + const { execa: exec } = await import("execa"); + await exec("npm", ["run", "build"], { stdio: "inherit" }); + console.log("Build complete"); + if (!process.env.SKIP_FIXTURE_CREATION) { console.log( "Recreating static fixtures. Set SKIP_FIXTURE_CREATION to skip this",