Repository navigation
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
58 lines (54 loc) · 1.98 KB
/
Copy pathplaywright.config.ts
File metadata and controls
58 lines (54 loc) · 1.98 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
import { defineConfig, devices } from '@playwright/test'
const PORT = 8731
const baseURL = `http://localhost:${PORT}`
// `http-demo` drives `site/worker`, whose R2 bindings are `remote = true`
// — `wrangler dev` needs CF credentials and live buckets. `mock-demo` is
// hermetic. `E2E_MOCK_ONLY` drops the worker server so CI can run the
// hermetic half with no secrets and no network.
const mockOnly = !!process.env.E2E_MOCK_ONLY
// Which Chromium to drive. Default is Playwright's own build, which it
// downloads into `~/Library/Caches/ms-playwright` — that's what CI does.
// `E2E_CHANNEL=chrome` runs against an already-installed Chrome instead:
// same engine, nothing to fetch, and a working local `e2e` on a machine
// where that download won't complete.
const channel = process.env.E2E_CHANNEL
export default defineConfig({
testDir: './e2e',
// Under `mockOnly` the worker server is dropped, so the one worker-driven
// spec (`http-demo`) can't run — ignore it and the rest of `e2e/` (all
// `MockStore`-backed) is the hermetic set CI runs.
...(mockOnly ? { testIgnore: '**/http-demo.spec.ts' } : {}),
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: process.env.CI ? 'github' : [['list'], ['html', { open: 'never' }]],
use: {
baseURL,
trace: 'on-first-retry',
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'], ...(channel ? { channel } : {}) },
},
],
webServer: [
{
command: 'pnpm build && pnpm --dir site dev',
url: baseURL,
reuseExistingServer: !process.env.CI,
stdout: 'pipe',
stderr: 'pipe',
timeout: 120_000,
},
...(mockOnly ? [] : [{
command: 'pnpm --dir site/worker dev',
url: 'http://localhost:8732/v1/files/list?prefix=',
reuseExistingServer: !process.env.CI,
stdout: 'pipe' as const,
stderr: 'pipe' as const,
timeout: 120_000,
}]),
],
})