Repository navigation
Expand file tree
/
Copy pathplaywright.config.js
More file actions
154 lines (149 loc) Β· 4.73 KB
/
Copy pathplaywright.config.js
File metadata and controls
154 lines (149 loc) Β· 4.73 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
const { defineConfig, devices } = require( '@playwright/test' );
// Defaults to the local dev WordPress. Override via env var in CI.
const baseURL =
process.env.PLAYWRIGHT_BASE_URL ||
'http://wordpress-stable-docker-mariadb.test:8282';
// Where the cached admin session is written and read from. Overridable so a
// run against another install β wp-env, say β gets its own session file
// instead of overwriting the one for the dev WordPress.
const storageState =
process.env.PLAYWRIGHT_STORAGE_STATE || 'tests/playwright/.auth/admin.json';
// Specs captured by tests/screenshot/run.sh against the fresh Playground
// instance (plus `banner`, which renders local HTML over file://).
const screenshotSpecs = [
'playground',
'dashboard-widget',
'inline-diff',
'event-details',
'user-events',
'plugin-install',
'insights-widget',
'stats-page',
'email-settings',
'ip-popover',
'email-preview',
'compact-view',
'banner',
];
const screenshotTestMatch = new RegExp(
`screenshot-(${ screenshotSpecs.join( '|' ) })\\.spec\\.js$`
);
// @wordpress/e2e-test-utils-playwright reads WP_BASE_URL from env at module
// load time, so set it here before any test files import the package.
process.env.WP_BASE_URL = baseURL;
module.exports = defineConfig( {
testDir: './tests/playwright',
fullyParallel: true,
forbidOnly: !! process.env.CI,
retries: process.env.CI ? 2 : 0,
reporter: 'html',
use: {
baseURL,
trace: 'on-first-retry',
launchOptions: {
// The dev and test sites use throwaway passwords like
// "claude", which Chrome finds in its leaked-password list and
// warns about on every login in headed and UI mode.
args: [ '--disable-features=PasswordLeakDetection' ],
},
},
projects: [
{
name: 'setup',
testMatch: /auth\.setup\.js/,
},
// These two specs flip the site-wide experimental-features option
// through the dev-tools endpoint. Run in parallel they race each
// other, so they run as a chain of their own before `tests`.
{
name: 'experimental-privacy',
use: {
...devices[ 'Desktop Chrome' ],
storageState,
},
testMatch: /privacy-data\.spec\.js$/,
dependencies: [ 'setup' ],
},
{
name: 'experimental-hide',
use: {
...devices[ 'Desktop Chrome' ],
storageState,
},
testMatch: /hide-event-type\.spec\.js$/,
dependencies: [ 'experimental-privacy' ],
},
// events-view-toggle.spec.js stores the admin's event log view
// preference and toggles it through the UI. Run with `fullyParallel`
// against the shared admin session, it races other specs that assume
// the detailed view (e.g. ones that look for
// .SimpleHistoryLogitem__details). Give it its own project so it runs
// on its own, like the experimental-features specs above.
{
name: 'events-view',
use: {
...devices[ 'Desktop Chrome' ],
storageState,
},
testMatch: /events-view-toggle\.spec\.js$/,
dependencies: [ 'experimental-hide' ],
},
{
// The premium table view replaces the whole log area and stores a
// view preference, so it races specs that assume the detailed
// list. Own project, like events-view above.
name: 'premium-table',
use: {
...devices[ 'Desktop Chrome' ],
storageState,
},
testMatch: /premium-table-view\.spec\.js$/,
dependencies: [ 'events-view' ],
},
{
name: 'tests',
use: {
...devices[ 'Desktop Chrome' ],
// Reuse admin login session across tests.
storageState,
},
// Screenshot specs are not tests β they run via the dedicated
// `screenshot` project (tests/screenshot/run.sh) against a fresh
// Playground instance, so keep them out of the regular suite.
// The experimental-features specs run in their own projects above.
testIgnore: [
/screenshot-.*\.spec\.js$/,
/privacy-data\.spec\.js$/,
/hide-event-type\.spec\.js$/,
/events-view-toggle\.spec\.js$/,
/premium-table-view\.spec\.js$/,
],
dependencies: [ 'premium-table' ],
},
{
// Teaser user-card screenshots, captured against the dev WordPress
// via scripts/capture-teaser-screenshots.sh (logs in as sally).
// Kept in its own project so it stays out of the regular `tests`
// suite but still runs against the dev install, not Playground.
name: 'teaser',
use: {
...devices[ 'Desktop Chrome' ],
storageState,
},
testMatch: /screenshot-teaser-.*\.spec\.js$/,
dependencies: [ 'setup' ],
},
{
// Used by tests/screenshot/run.sh against a fresh WP Playground
// instance. No setup dependency β logs in fresh per run. Matches
// both the main log screenshot and the dashboard widget screenshot.
name: 'screenshot',
use: {
...devices[ 'Desktop Chrome' ],
baseURL:
process.env.PLAYWRIGHT_BASE_URL || 'http://127.0.0.1:9445',
},
testMatch: screenshotTestMatch,
},
],
} );