Repository navigation
Expand file tree
/
Copy pathplaywright-visual.config.ts
More file actions
76 lines (74 loc) · 2.74 KB
/
Copy pathplaywright-visual.config.ts
File metadata and controls
76 lines (74 loc) · 2.74 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
import { defineConfig, devices } from '@playwright/test';
// Visual regression tests. Baseline screenshots live in an external repository
// (plone/aurora-visual-regression), checked out into `playwright/__screenshots__`
// by CI. They are only ever generated in CI (see the "Update VRT Screenshots"
// workflow), so local runs tolerate small rendering differences.
const isCI = !!process.env.CI || !!process.env.GITHUB_ACTIONS;
export default defineConfig({
testDir: '.',
testMatch: [
'packages/*/acceptance/visual/**/*.{spec,test}.{ts,tsx}',
'apps/*/acceptance/visual/**/*.{spec,test}.{ts,tsx}',
],
testIgnore: ['**/.codex/**', '**/node_modules/**'],
outputDir: 'playwright/results-visual',
// The total worker limit. The app suites limit themselves to one worker, see
// `projects`. CI runs the two projects one after the other: the parallel
// Quanta tests load the machine enough to change how Chrome renders the
// app's images.
workers: isCI ? '100%' : '50%',
forbidOnly: isCI,
retries: isCI ? 1 : 0,
timeout: 30_000,
expect: {
timeout: 10_000,
toHaveScreenshot: {
animations: 'disabled',
caret: 'hide',
// Never commit screenshots made outside CI; locally, allow for font
// rendering differences between platforms. In CI, allow a few pixels
// for anti-aliasing noise, which can differ between runs of the same
// page; any real visual change differs by far more.
...(isCI ? { maxDiffPixels: 10 } : { maxDiffPixelRatio: 0.05 }),
},
},
use: {
baseURL: process.env.BASE_URL ?? 'http://localhost:3000',
browserName: 'chromium',
viewport: { width: 1280, height: 720 },
trace: 'retain-on-failure',
},
// Serves Quanta's static Storybook build for its component screenshots
// (`pnpm --filter @plone/quanta build-storybook`). The app and the backend
// are started separately.
webServer: {
command:
'python3 -m http.server 6007 --directory packages/quanta/storybook-static',
port: 6007,
reuseExistingServer: true,
stdout: 'ignore',
stderr: 'ignore',
},
projects: [
{
// The app and the backend. Tests share one backend that is reset around
// every test, so they run one at a time.
name: 'chromium',
testIgnore: ['packages/quanta/**'],
workers: 1,
use: { ...devices['Desktop Chrome'] },
},
{
// Quanta's components, from the static Storybook. No backend, so the
// tests run in parallel.
name: 'quanta',
testMatch: [
'packages/quanta/acceptance/visual/**/*.{spec,test}.{ts,tsx}',
],
fullyParallel: true,
use: { ...devices['Desktop Chrome'] },
},
],
snapshotPathTemplate:
'playwright/__screenshots__/{testFilePath}/{arg}{-projectName}{ext}',
});