Repository navigation
Expand file tree
/
Copy pathplaywright.config.js
More file actions
51 lines (46 loc) · 2.26 KB
/
Copy pathplaywright.config.js
File metadata and controls
51 lines (46 loc) · 2.26 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
// Playwright config for the layout regression suite (tests/layout.spec.js).
//
// These tests assert geometric invariants — content is on screen, nothing
// overflows horizontally, the sidebar collapses below lg — rather than
// comparing screenshots. Screenshot diffs would churn on every content change;
// the invariants hold no matter what the pages say.
//
// `webServer` starts the Hugo dev server and waits for it, so `npm run
// test:layout` works from a clean checkout with no manual setup.
const { defineConfig } = require('@playwright/test');
const PORT = Number(process.env.LAYOUT_TEST_PORT || 1314);
module.exports = defineConfig({
testDir: './tests',
// The invariants are deterministic; a retry would only mask a real flake.
retries: 0,
// Hugo serves one site; parallel page loads are cheap, browser contexts are not.
workers: process.env.CI ? 2 : undefined,
fullyParallel: true,
reporter: process.env.CI ? [['github'], ['list']] : [['list']],
// 60s, not 30s. Every test here finishes in about a second on its own; what
// spends the budget is `page.goto` under a cold server and a full set of
// parallel workers, which on this machine intermittently pushed a single
// navigation past 30s. Three separate runs lost one or two tests that way
// and every one of them passed alone, which is the signature of contention
// rather than a defect - and a flake that looks like a failure is worse than
// a slow test, because the next real failure gets waved through as "probably
// the flake". 60s is still a ceiling a genuinely hung page cannot pass.
timeout: 60_000,
expect: { timeout: 10_000 },
use: {
baseURL: `http://127.0.0.1:${PORT}`,
trace: 'on-first-retry',
},
webServer: {
// Mirrors `npm run serve` (-e dev -DFE renders drafts/future/expired pages),
// but calls hugo directly: the npm script chain puts flags before the
// `serve` subcommand, and --port is only valid after it.
command: `npx --no-install hugo serve -e dev -DFE --renderToMemory --port ${PORT} --bind 127.0.0.1`,
url: `http://127.0.0.1:${PORT}/`,
reuseExistingServer: !process.env.CI,
// A cold Hugo build of ~1100 pages takes well over a minute on CI runners.
timeout: 300_000,
stdout: 'ignore',
stderr: 'pipe',
},
});