Repository navigation
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
73 lines (67 loc) · 2.44 KB
/
Copy pathplaywright.config.ts
File metadata and controls
73 lines (67 loc) · 2.44 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
import { defineConfig, devices } from '@playwright/test';
import { readFileSync } from 'node:fs';
// The backend reads FEED_PROXY_SECRET from backend/.dev.vars, and feed ingest is
// fail-closed, so the proxy has to start with that same value or every fetch
// 401s and the timeline stays empty. Read it from the file rather than pinning a
// literal here: CI writes test-e2e-secret into .dev.vars, and a local dev setup
// keeps whatever dev-local.sh uses.
function feedProxySecret(): string {
try {
const vars = readFileSync(new URL('./backend/.dev.vars', import.meta.url), 'utf8');
return vars.match(/^FEED_PROXY_SECRET=(.*)$/m)?.[1].trim() || 'test-e2e-secret';
} catch {
return 'test-e2e-secret';
}
}
export default defineConfig({
testDir: './e2e',
// One worker: every test drives the same backend + frontend dev servers, and
// running several at once against them makes tests flake. CI gets its speed
// from sharding across runners instead (.github/workflows/e2e.yml), each with
// its own servers. fullyParallel lets a shard take individual tests rather
// than whole files, so one long file (highlight-review) can't set the pace.
// Tests must not depend on each other's order — each seeds its own user.
fullyParallel: true,
workers: 1,
// A retry on CI turns a rare flake into a warning instead of a red build, and
// it's what makes `trace: 'on-first-retry'` produce anything at all.
retries: process.env.CI ? 2 : 0,
// CI shards write blob reports that the e2e workflow merges into one HTML report.
reporter: process.env.CI ? [['blob'], ['list']] : 'html',
timeout: 30_000,
globalSetup: './e2e/global-setup.ts',
use: {
baseURL: 'http://127.0.0.1:5173',
trace: 'on-first-retry',
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
],
webServer: [
{
command: 'bun run dev',
cwd: './feed-proxy',
port: 3000,
reuseExistingServer: !process.env.CI,
timeout: 10_000,
env: { PROXY_SECRET: feedProxySecret(), PORT: '3000' },
},
{
// wrangler dev under a supervisor that restarts it if it crashes mid-run.
command: './e2e/backend-supervisor.sh',
port: 8787,
reuseExistingServer: !process.env.CI,
timeout: 30_000,
},
{
command: 'npm run dev',
cwd: './frontend',
url: 'http://127.0.0.1:5173',
reuseExistingServer: !process.env.CI,
timeout: 30_000,
},
],
});