Repository navigation
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
114 lines (110 loc) · 4.95 KB
/
Copy pathplaywright.config.ts
File metadata and controls
114 lines (110 loc) · 4.95 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import { defineConfig, devices } from '@playwright/test';
import { filesOfShard, parseShard, WEBKIT_SPEC } from './scripts/e2e-shards';
// E2E_PORT lets several checkouts (git worktrees) run their suites at once:
// with a shared port, `reuseExistingServer` would test another checkout's build.
const PORT = Number(process.env.E2E_PORT ?? 4173);
// Set PLAYWRIGHT_CHROMIUM_PATH to use an installed Chromium instead of the
// browser that `pnpm e2e:install` downloads (useful on distros Playwright
// does not officially support); E2E_GPU=1 turns on real GPU rendering (below).
const executablePath = process.env.PLAYWRIGHT_CHROMIUM_PATH;
// CI shards by duration, not by count: E2E_SHARD=<current>/<total> picks this
// shard's spec files (scripts/e2e-shards.ts, e2e/timings.json). Unset locally.
const shard = parseShard(process.env.E2E_SHARD);
const shardFiles = shard ? filesOfShard(shard) : undefined;
const NONE = /(?!)/;
/** A testMatch for exactly these e2e files (every file when not sharding). */
const match = (files: string[] | undefined, fallback: RegExp) =>
files === undefined
? fallback
: files.length
? new RegExp(`/(?:${files.map((f) => f.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|')})$`)
: NONE;
export default defineConfig({
testDir: 'e2e',
expect: {
// Text antialiasing differs slightly between Linux distributions (Arch
// locally, Ubuntu in CI): about a dozen pixels over the colour threshold
// per full-page shot. 0.1 % still catches any layout change.
// The render rate in the status bar varies from run to run: hidden in shots.
toHaveScreenshot: { maxDiffPixelRatio: 0.001, stylePath: './e2e/screenshot.css' },
},
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 1 : 0,
// CI also writes a JSON report: its per-test durations feed e2e/timings.json
// (uploaded as the playwright-results-<shard> artifact).
reporter: process.env.CI
? [['github'], ['html', { open: 'never' }], ['json', { outputFile: 'playwright-results.json' }]]
: 'list',
use: {
baseURL: `http://127.0.0.1:${PORT}`,
trace: 'retain-on-failure',
// The production build registers a service worker that precaches 20 MB of
// WASM; only e2e/pwa.spec.ts wants it.
serviceWorkers: 'block',
// The app follows the system theme by default (ADR-0079, round 2) and Playwright reports a
// light one: pin dark so the app renders, and the baselines look, as they always did.
colorScheme: 'dark',
// The e2e browser draws WebGL in software (SwiftShader), so every spec would
// get the "Software rendering" toast (ADR-0076). The preference is stored the
// way platform/preferences.ts does: key `extrudo.<key>`, JSON value.
storageState: {
cookies: [],
origins: [
{
origin: `http://127.0.0.1:${PORT}`,
localStorage: [{ name: 'extrudo.render.softwareNotice', value: '"dismissed"' }],
},
],
},
},
projects: [
{
name: 'chromium',
testIgnore: /webkit-smoke\.spec\.ts/,
testMatch: match(
shardFiles?.filter((f) => f !== WEBKIT_SPEC),
/.*\.spec\.ts/,
),
use: {
...devices['Desktop Chrome'],
// Opt-in GPU rendering for local runs on a machine with a GPU
// (measured on an NVIDIA GTX 1050 Ti: WebGL about 150x faster than
// SwiftShader, e2e specs 17-39 % faster). Never in CI: the
// screenshot baselines are made with SwiftShader and GPU pixels
// differ. '--use-gl=egl' alone silently stays on SwiftShader, so the
// angle backend has to be named too.
launchOptions: {
...(executablePath ? { executablePath } : {}),
...(process.env.E2E_GPU
? { args: ['--use-angle=gl-egl', '--ignore-gpu-blocklist', '--enable-gpu'] }
: {}),
},
},
},
{
// Safari's engine: one smoke spec, rectangle → extrude, the flow that
// broke there before the Symbol.dispose polyfill (`@extrudo/core/polyfills`).
// A canary for WebKit as a whole (WASM threads, COOP/COEP, WebGL), not a
// test of the polyfill: Playwright's WebKit 26.6 has Symbol.dispose
// (26.0 lacked it; see docs/agent/e2e-notes.md for a real repro). Run it
// with `pnpm e2e --project webkit` after `pnpm exec playwright install
// --with-deps webkit`.
name: 'webkit',
testMatch: match(
shardFiles?.filter((f) => f === WEBKIT_SPEC),
/webkit-smoke\.spec\.ts/,
),
use: { ...devices['Desktop Safari'] },
},
],
webServer: {
// Start Vite's own script with node. Going through pnpm (`pnpm --filter`,
// `pnpm exec`) leaves the server running after the tests on pnpm 12, because
// pnpm does not pass Playwright's stop signal on to Vite.
command: `node node_modules/vite/bin/vite.js preview --host 127.0.0.1 --port ${PORT} --strictPort`,
cwd: 'apps/web',
url: `http://127.0.0.1:${PORT}`,
reuseExistingServer: !process.env.CI,
},
});