Repository navigation
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
55 lines (51 loc) · 1.97 KB
/
Copy pathplaywright.config.ts
File metadata and controls
55 lines (51 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// playwright.config.ts - minimal Playwright config for the smoke suite.
//
// How to run:
// 1. Build the GitHub Pages artifact: bash build_github_pages.sh
// 2. Run the suite: npx playwright test
//
// The config serves the built dist/ folder on a fixed local port (4173) via
// Python's http.server, so the baseURL is stable (unlike run_web_server.sh,
// which picks a random port per session). webServer.reuseExistingServer lets a
// dev keep a server running across reruns. Tests live in tests/playwright/.
import { defineConfig, devices } from "@playwright/test";
// Fixed port for the smoke server; stable so baseURL never changes.
const PORT = 4173;
const BASE_URL = `http://localhost:${PORT}`;
// Detect CI without depending on Node's process typings (kept out of the src
// tsconfig types). Reads the CI env var off globalThis.process when present.
function is_ci(): boolean {
const proc = (globalThis as { process?: { env?: Record<string, string | undefined> } }).process;
return proc?.env?.CI !== undefined && proc.env.CI !== "";
}
const CI = is_ci();
export default defineConfig({
// Smoke and other browser specs live alongside the Playwright helpers.
testDir: "tests/playwright",
// Only *.spec.ts files are Playwright specs; *.mjs files are plain helpers.
testMatch: "**/*.spec.ts",
// Fail the CI build if test.only is left in the source.
forbidOnly: CI,
// Keep the suite serial-friendly and deterministic for a smoke check.
fullyParallel: false,
retries: 0,
reporter: "list",
use: {
baseURL: BASE_URL,
trace: "on-first-retry",
},
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},
],
// Serve the prebuilt dist/ folder. The build is a separate step (run
// build_github_pages.sh first); this only serves the static artifact.
webServer: {
command: `python3 -m http.server ${PORT} --directory dist`,
url: BASE_URL,
reuseExistingServer: !CI,
timeout: 30_000,
},
});