-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathplaywright.config.js
More file actions
84 lines (77 loc) · 2.58 KB
/
Copy pathplaywright.config.js
File metadata and controls
84 lines (77 loc) · 2.58 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
/**
* External dependencies
*/
const fs = require('fs');
const path = require('path');
const { defineConfig } = require('@playwright/test');
const baseConfig = require('@wordpress/scripts/config/playwright.config.js');
/**
* Internal dependencies
*/
const envPath = path.resolve(__dirname, './playwright.env.json');
const prEnvPath = path.resolve(__dirname, './.pr-playwright.env.json');
// If env file exists, load it into process.env.
if (fs.existsSync(envPath)) {
const playwrightEnv = require(envPath);
process.env = {
...process.env,
...playwrightEnv,
};
}
// Optional PR-scoped filter (committed on feature branches only; see check-pr-config-files.yml).
let prPlaywrightEnv = {};
if (fs.existsSync(prEnvPath)) {
prPlaywrightEnv = require(prEnvPath);
}
const config = defineConfig({
...baseConfig,
// Flaky = failed a run then passed on retry; must not fail CI unless explicitly opted in.
failOnFlakyTests: false,
// Snapshot update mode:
// - `all` / UPDATE_SNAPSHOTS=1: rewrite baselines (intentional refresh only).
// - `missing` (CI + local default): compare against committed baselines; on mismatch
// fail and write *-actual.png into test-results. If a baseline file is absent,
// take the screenshot, write *-actual.png (for artifact download), write the
// baseline path, and still fail — so CI does not silently invent goldens.
// - Do NOT use `none` on CI: Playwright short-circuits missing baselines without
// capturing/writing the actual image, so artifacts have nothing to commit.
updateSnapshots: (() => {
if (
process.env.UPDATE_SNAPSHOTS === '1' ||
process.env.UPDATE_SNAPSHOTS === 'all'
) {
return 'all';
}
if (process.env.UPDATE_SNAPSHOTS === 'none') {
return 'none';
}
return 'missing';
})(),
testDir: './',
testMatch: prPlaywrightEnv.testMatch ?? '**/*.ply.js',
// Performance suite has its own Playwright configs under tests/performance/.
// Never include it in e2e / visual CI runs (even if testMatch is widened).
testIgnore: [
'**/tests/performance/**',
...(Array.isArray(prPlaywrightEnv.testIgnore)
? prPlaywrightEnv.testIgnore
: []),
],
reporter: process.env.CI
? [
['list'], // Shows test names and progress in real-time
['github'], // GitHub Actions integration
['html', { outputFolder: 'playwright-report', open: 'never' }], // HTML report
['./packages/dev-playwright/js/config/flaky-tests-report.ts'],
[
'json',
{ outputFile: 'artifacts/playwright-e2e-summary.json' },
],
]
: 'list',
webServer: {
...baseConfig.webServer,
command: 'npm run env:start',
},
});
export default config;