-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplaywright.config.js
More file actions
87 lines (75 loc) · 2.56 KB
/
Copy pathplaywright.config.js
File metadata and controls
87 lines (75 loc) · 2.56 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
85
86
87
// @ts-check
import { defineConfig, devices } from '@playwright/test';
/**
* Headless mode configuration:
* - Default: headless=true (browsers run in background, no UI)
* - Set PLAYWRIGHT_HEADLESS=false to see browser windows
* - CI always runs headless
*
* npm scripts:
* - npm run test:e2e → headless (default)
* - npm run test:e2e:headed → shows browser windows
* - npm run test:e2e:debug → debug mode with browser visible
* - npm run test:e2e:ui → Playwright UI mode
*/
const headless = process.env.PLAYWRIGHT_HEADLESS !== 'false'; // Default to headless=true
const shouldStartWebServer = process.env.PW_SKIP_WEB_SERVER !== '1';
export default defineConfig({
testDir: './test/e2e',
testMatch: '**/*.spec.{js,ts}',
// Run tests in parallel
fullyParallel: true,
// Fail fast on CI, retry locally
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
// Structured output for AI parsing
reporter: [
['list'], // Console output
['json', { outputFile: 'test-results/e2e-results.json' }],
['html', { open: 'never' }], // HTML report for manual review
],
use: {
// Base URL for tests
baseURL: 'http://localhost:8080',
// Headless mode (CI or env override)
headless,
// Capture on failure
screenshot: 'only-on-failure',
video: 'retain-on-failure',
trace: 'retain-on-failure',
// Browser viewport
viewport: { width: 1280, height: 720 },
},
// Test tiers via projects
// - smoke: Critical paths (~15 tests, <30s) - run always
// - chromium: Full suite (~285 tests, ~5min) - PR/nightly
//
// Usage:
// npx playwright test --project=smoke # Quick validation
// npx playwright test # Full suite
projects: [
{
name: 'smoke',
use: { ...devices['Desktop Chrome'] },
grep: /@smoke/, // Only run tests tagged with @smoke
},
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
],
// Dev server
// NOTE: `bb dev` starts shadow-cljs watch — the HTTP port comes up almost
// immediately, but the JS bundle takes 15-25s to compile. Probing the
// bundle URL ensures Playwright waits until the app can actually boot;
// probing the root would let the first alphabetical tests (aria-structure)
// run against an empty page and fail with `[data-block-id]` timeouts.
webServer: shouldStartWebServer
? {
command: 'bb dev',
url: 'http://localhost:8080/js/blocks-ui/main.js',
reuseExistingServer: !process.env.CI,
timeout: 180000,
}
: undefined,
});