Skip to content

Commit 80eb323

Browse files
committed
auto run dev server if it's not already runnging
1 parent 61b26fa commit 80eb323

File tree

2 files changed

+53
-41
lines changed

2 files changed

+53
-41
lines changed

playwright.config.mts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { defineConfig, devices } from "@playwright/test";
2+
3+
const BASE_URL = process.env.BASE_URL || "http://localhost:3000";
4+
5+
async function isServerRunning(): Promise<boolean> {
6+
try {
7+
await fetch(BASE_URL, { signal: AbortSignal.timeout(2000) });
8+
return true;
9+
} catch {
10+
return false;
11+
}
12+
}
13+
14+
const serverAlreadyRunning = await isServerRunning();
15+
16+
export default defineConfig({
17+
testDir: "./tests/e2e",
18+
fullyParallel: true,
19+
forbidOnly: !!process.env.CI,
20+
retries: process.env.CI ? 2 : 0,
21+
workers: process.env.CI ? 1 : undefined,
22+
reporter: process.env.CI ? "github" : "list",
23+
timeout: 30_000,
24+
use: {
25+
baseURL: BASE_URL,
26+
trace: "on-first-retry",
27+
screenshot: "only-on-failure",
28+
},
29+
projects: [
30+
{
31+
name: "chromium",
32+
use: { ...devices["Desktop Chrome"] },
33+
},
34+
],
35+
webServer: serverAlreadyRunning
36+
? undefined
37+
: {
38+
command: "pnpm dev",
39+
url: BASE_URL,
40+
timeout: 120_000,
41+
stdout: "pipe",
42+
stderr: "pipe",
43+
env: {
44+
API_BASE_URL: "http://localhost:9090",
45+
OIDC_ISSUER_URL: "http://localhost:4000",
46+
OIDC_CLIENT_ID: "better-auth-dev",
47+
OIDC_CLIENT_SECRET: "dev-secret-change-in-production",
48+
NEXT_PUBLIC_OIDC_PROVIDER_ID: "okta",
49+
BETTER_AUTH_URL: "http://localhost:3000",
50+
BETTER_AUTH_SECRET: "e2e-test-secret-at-least-32-chars-long",
51+
},
52+
},
53+
});

playwright.config.ts

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)