-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
77 lines (64 loc) · 2.26 KB
/
Copy pathplaywright.config.ts
File metadata and controls
77 lines (64 loc) · 2.26 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { defineConfig, devices } from "@playwright/test";
/**
* Playwright configuration for E2E web tests
*
* See https://playwright.dev/docs/test-configuration
*/
export default defineConfig({
testDir: "./test-e2e",
// Maximum time one test can run (longer for CI to handle slower environments)
timeout: process.env.CI ? 60 * 1000 : 30 * 1000,
// Maximum time to wait for expect() assertions
expect: {
timeout: process.env.CI ? 15 * 1000 : 10 * 1000,
},
// Test execution settings
fullyParallel: false, // Run serially to avoid resource contention
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: 1, // Single worker for stability
// Reporter configuration - use multiple reporters in CI
reporter: process.env.CI
? [["github"], ["html", { open: "never" }]]
: [["list"], ["html", { open: "on-failure" }]],
// Shared settings for all projects
use: {
// Base URL for the app — override with BASE_URL env var to target a
// deployed preview (e.g. Cloudflare Pages) instead of the local server.
baseURL: process.env.BASE_URL ?? "http://127.0.0.1:8080",
// Collect trace on failure for debugging
trace: "on-first-retry",
// Take screenshots on failure
screenshot: "only-on-failure",
// Record video on first retry (helps debug flaky tests)
video: "retain-on-failure",
// Navigation timeout (longer for CI to handle API calls and Flutter initialization)
navigationTimeout: process.env.CI ? 45 * 1000 : 15 * 1000,
// Action timeout (clicks, fills, etc.)
actionTimeout: process.env.CI ? 15 * 1000 : 10 * 1000,
},
// Test projects for different browsers
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},
// Uncomment to test on additional browsers
// {
// name: 'firefox',
// use: { ...devices['Desktop Firefox'] },
// },
// {
// name: 'webkit',
// use: { ...devices['Desktop Safari'] },
// },
],
// Note: webServer is NOT used here because CI needs more control
// over the http-server lifecycle. Instead:
// 1. CI starts http-server in the background
// 2. Tests run
// 3. CI stops http-server
//
// For local development, start the server manually:
// npm run serve:web
});