Repository navigation
Expand file tree
/
Copy pathplaywright.config.js
More file actions
84 lines (71 loc) · 2.74 KB
/
Copy pathplaywright.config.js
File metadata and controls
84 lines (71 loc) · 2.74 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
78
79
80
81
82
83
84
// @ts-check
import { defineConfig, devices } from '@playwright/test';
/**
* Playwright E2E Configuration
* Cross-browser matrix: Chromium, Firefox, WebKit
* Runs against the local Vite dev server (started automatically).
*/
export default defineConfig({
// Root directory for all test specs
testDir: './e2e/specs',
// Maximum time one test can run before it is considered failed
timeout: 45_000,
// Expect timeout for individual assertions
expect: {
timeout: 8_000,
},
// Fail the build on CI if you accidentally left test.only in the source
forbidOnly: !!process.env.CI,
// Retry failed tests once on both CI and locally (server flakes / connection drops)
retries: process.env.CI ? 2 : 1,
// Parallelism: cap at 2 locally to avoid overloading the Vite dev server
// (too many parallel Firefox/WebKit instances cause mock route drops)
workers: process.env.CI ? 2 : 2,
// Reporter: GitHub Actions-aware on CI, human-readable locally
reporter: process.env.CI
? [['github'], ['html', { outputFolder: 'playwright-report', open: 'never' }]]
: [['list'], ['html', { outputFolder: 'playwright-report', open: 'on-failure' }]],
// Shared settings for all projects (browsers)
use: {
// Base URL for page.goto('/') calls
baseURL: 'http://localhost:5173',
// Capture trace on first retry — invaluable for debugging CI failures
trace: 'on-first-retry',
// Screenshot only on failure
screenshot: 'only-on-failure',
// Realistic viewport
viewport: { width: 1280, height: 720 },
},
// ── Browser matrix ──────────────────────────────────────────────────────────
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
// Mobile smoke tests (Chromium engine) to catch responsive-layout regressions
{
name: 'mobile-chrome',
use: { ...devices['Pixel 5'] },
},
],
// ── Local dev server ────────────────────────────────────────────────────────
// Playwright will start `vite` automatically before running tests and shut it
// down afterwards. On CI the server is started the same way.
webServer: {
command: 'npm run dev',
url: 'http://localhost:5173',
reuseExistingServer: !process.env.CI,
timeout: 60_000,
// Suppress Vite's noisy output in CI logs
stdout: process.env.CI ? 'ignore' : 'pipe',
stderr: 'pipe',
},
});