-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
57 lines (50 loc) · 1.99 KB
/
playwright.config.ts
File metadata and controls
57 lines (50 loc) · 1.99 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
56
57
import { defineConfig } from "@playwright/test";
import path from "node:path";
import { fileURLToPath } from "node:url";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
// choose a unique port per worker to avoid collisions when tests start their own server
// PW_WORKER_INDEX is provided by Playwright when spawning workers.
// ensure we don't end up with NaN if the env var is missing or corrupt
let basePort = 3000;
if (process.env.PW_WORKER_INDEX) {
const idx = Number.parseInt(process.env.PW_WORKER_INDEX, 10);
if (!Number.isNaN(idx)) {
basePort += idx;
}
}
export default defineConfig({
testDir: "./e2e",
timeout: 90000,
// Global teardown: prints race-condition summary and runs leak check in CI
globalTeardown: path.resolve(__dirname, "e2e/global-teardown.ts"),
// Reporters: built-in list reporter + custom race-condition reporter
reporter: [
["list"],
[path.resolve(__dirname, "e2e/race-condition-reporter.ts")],
],
// PARALLELISIERUNG AKTIVIERT
// Nutzt 4 Worker lokal, in der CI (GitHub Actions etc.) 2, um Überlastung zu vermeiden
workers: process.env.CI ? 2 : 4,
fullyParallel: true, // Erlaubt Playwright, Tests innerhalb einer Datei parallel auszuführen
retries: 1, // 1 Retry für flaky Cold-Start-Timing-Probleme
expect: {
timeout: 10000,
},
use: {
// Nutzt den dynamischen basePort für die Kommunikation mit dem Webserver
baseURL: process.env.BASE_URL || `http://localhost:${basePort}`,
trace: "on-first-retry",
screenshot: "only-on-failure",
video: "off",
},
// ... restliche Config
webServer: {
// Übergibt den dynamischen Port an den Server-Startbefehl mit zusätzlichen gatekeeper-overrides
command: `PORT=${basePort} VITE_DISABLE_TOASTS=true DISABLE_COMPILE_GATEKEEPER=true DISABLE_RATE_LIMIT=true npm run dev:full`,
url: `http://localhost:${basePort}`,
reuseExistingServer: !process.env.CI,
timeout: 180 * 1000,
stdout: "pipe",
stderr: "pipe",
},
});