-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
112 lines (103 loc) · 3.71 KB
/
Copy pathplaywright.config.ts
File metadata and controls
112 lines (103 loc) · 3.71 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
import { defineConfig, devices } from '@playwright/test';
/**
* Playwright config for "Mission by Managed Code".
*
* Visual regression baselines are PLATFORM-SUFFIXED via `snapshotPathTemplate`
* (see `{platform}` below). That means macOS dev baselines (`-darwin`) and
* Linux CI baselines (`-linux`) live side by side and never clobber each other.
* Locally on macOS you generate `-darwin` snapshots. Linux snapshots are
* committed deliberately by humans. `.github/workflows/deploy.yml` compares
* them before publishing, and `.github/workflows/playwright.yml` only uploads
* generated `-linux` snapshots as a manual artifact when requested.
*/
// Dedicated port so the suite never reuses an unrelated dev server that may
// already hold the local dev port (4323). Override with PORT if needed.
const PORT = Number(process.env.PORT ?? 4333);
const BASE_URL = `http://127.0.0.1:${PORT}`;
const DESKTOP_ONLY = /@desktop/;
const MOBILE_AUDIT_ONLY = /@mobile-audit/;
const NON_TARGETED_MOBILE_TESTS = /@desktop|@mobile-audit/;
export default defineConfig({
testDir: './tests',
fullyParallel: true,
forbidOnly: !!process.env.CI,
// One retry everywhere: the tallest full-page captures (home, desktop/-xl) are
// occasionally marginal on Chromium's stable-frame pre-check; a single retry
// self-heals that without masking real content diffs (the diff threshold is
// unchanged below).
retries: 1,
reporter: [['html', { open: 'never' }], ['list']],
// Build the static site and serve it with Astro's preview server on our port.
webServer: {
command: `npm run build && npm run preview:test -- --host 127.0.0.1 --port ${PORT}`,
url: BASE_URL,
reuseExistingServer: false,
timeout: 180_000,
stdout: 'ignore',
},
use: {
baseURL: BASE_URL,
trace: 'on-first-retry',
},
expect: {
toHaveScreenshot: {
maxDiffPixelRatio: 0.02,
// per-pixel YIQ tolerance — absorbs sub-pixel font anti-aliasing noise on
// the very tall full-page captures (real text/layout changes still exceed it)
threshold: 0.25,
animations: 'disabled',
caret: 'hide',
scale: 'css',
},
},
// Platform suffix keeps macOS-dev and Linux-CI baselines from colliding.
snapshotPathTemplate:
'{testDir}/__screenshots__/{testFilePath}/{arg}-{projectName}-{platform}{ext}',
// Full device matrix: small/medium/large phones, tablets, and desktops.
// Names are lowercase/hyphenated because they feed `{projectName}` in the
// platform-suffixed snapshot path template above.
projects: [
{
// Small Android phone — no built-in descriptor, so a custom viewport with
// mobile emulation flags set explicitly.
name: 'phone-sm',
grepInvert: DESKTOP_ONLY,
use: {
...devices['Desktop Chrome'],
viewport: { width: 360, height: 640 },
isMobile: true,
hasTouch: true,
},
},
{
name: 'phone-md',
grepInvert: NON_TARGETED_MOBILE_TESTS,
use: { ...devices['iPhone 13'] }, // 390x844
},
{
name: 'phone-lg',
grepInvert: NON_TARGETED_MOBILE_TESTS,
use: { ...devices['iPhone 14 Pro Max'] }, // 430x932
},
{
name: 'tablet',
grepInvert: NON_TARGETED_MOBILE_TESTS,
use: { ...devices['iPad Mini'] }, // 768x1024
},
{
name: 'tablet-lg',
grepInvert: NON_TARGETED_MOBILE_TESTS,
use: { ...devices['iPad Pro 11'] }, // 834x1194
},
{
name: 'desktop',
grepInvert: MOBILE_AUDIT_ONLY,
use: { ...devices['Desktop Chrome'], viewport: { width: 1440, height: 900 } },
},
{
name: 'desktop-xl',
grepInvert: MOBILE_AUDIT_ONLY,
use: { ...devices['Desktop Chrome'], viewport: { width: 1920, height: 1080 } },
},
],
});