-
Notifications
You must be signed in to change notification settings - Fork 156
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
264 lines (249 loc) · 6.41 KB
/
playwright.config.ts
File metadata and controls
264 lines (249 loc) · 6.41 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
/*---------------------------------------------------------------------------------------------
* Copyright (C) 2024 Posit Software, PBC. All rights reserved.
* Licensed under the Elastic License 2.0. See LICENSE.txt for license information.
*--------------------------------------------------------------------------------------------*/
import { defineConfig, ReporterDescription } from '@playwright/test';
import { CustomTestOptions } from './test/e2e/tests/_test.setup';
import * as fs from 'fs';
process.env.PW_TEST = '1';
const jsonOut = process.env.PW_JSON_FILE || 'test-results/results.json';
const githubSummaryReport = process.env.GH_SUMMARY_REPORT === 'true' ? [['@midleman/github-actions-reporter', {}] as const] : [];
// Custom reporter is enabled by default.
// Disable with: ENABLE_CUSTOM_REPORTER=false (or "false", 0, "0", no, "no")
// YAML booleans are converted to strings by GitHub Actions, so both work.
const disableCustomReporter = process.env.ENABLE_CUSTOM_REPORTER?.toLowerCase() ?? '';
const customReporter = ['false', '0', 'no'].includes(disableCustomReporter)
? []
: [['@midleman/playwright-reporter',
{
repoName: 'positron',
mode: 'prod'
},
] as const];
/**
* See https://playwright.dev/docs/test-configuration.
*/
const projectName = process.env.PW_PROJECT_NAME || 'default';
const baseIgnore = [
'example.test.ts',
'**/workbench/**',
'**/remote-ssh/**',
'**/assistant-eval/**',
'**/release-screenshots/**',
];
let reporter: ReporterDescription[];
if (process.env.CI) {
reporter = [
...githubSummaryReport,
...customReporter,
['json', { outputFile: jsonOut }],
['list'], ['html'], ['blob'],
];
} else {
reporter = [['list']];
if (!process.env.CLAUDE_CODE) {
reporter.push(['html', { open: 'on-failure' }]);
}
}
export default defineConfig<CustomTestOptions>({
captureGitInfo: { commit: true, diff: true },
globalSetup: './test/e2e/tests/_global.setup.ts',
testDir: './test/e2e',
testMatch: '*.test.ts',
testIgnore: process.env.ALLOW_PYREFLY === 'true'
? baseIgnore
: [...baseIgnore, '**/lsp/**'],
fullyParallel: false, // Run individual tests w/in a spec in parallel
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 1 : 0,
workers: 3,
timeout: 2 * 60 * 1000,
reportSlowTests: {
max: 10,
threshold: 60 * 1000, // 1 minute
},
expect: {
timeout: 15000,
},
reporter,
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
headless: false,
trace: 'off', // we are manually handling tracing in _test.setup.ts
actionTimeout: 15000,
navigationTimeout: 15000,
},
projects: [
{
name: 'e2e-electron',
testIgnore: process.env.ALLOW_PYREFLY === 'true'
? [
'example.test.ts',
'**/workbench/**',
'**/remote-ssh/**',
// Note: assistant-eval NOT ignored here - runs on e2e-electron only
]
: [
'example.test.ts',
'**/workbench/**',
'**/remote-ssh/**',
'**/lsp/**',
// Note: assistant-eval NOT ignored here - runs on e2e-electron only
],
use: {
artifactDir: 'e2e-electron'
},
grepInvert: /@:web-only/
},
{
name: 'e2e-chromium',
use: {
artifactDir: 'e2e-chromium',
headless: false,
browserName: 'chromium'
},
grep: /@:web/
},
{
name: 'e2e-firefox',
use: {
artifactDir: 'e2e-firefox',
headless: false,
browserName: 'firefox'
},
grep: /@:cross-browser/
},
{
name: 'e2e-windows',
use: {
artifactDir: 'e2e-windows',
},
grep: /@:win/,
grepInvert: /@:web-only/
},
{
name: 'e2e-webkit',
use: {
artifactDir: 'e2e-webkit',
headless: false,
browserName: 'webkit'
},
grep: /@:cross-browser/
},
{
name: 'e2e-edge',
use: {
artifactDir: 'e2e-edge',
headless: false,
browserName: 'chromium',
channel: 'msedge',
},
grep: /@:cross-browser/
},
{
name: 'e2e-server',
use: {
artifactDir: 'e2e-server',
headless: false,
useExternalServer: true,
externalServerUrl: 'http://localhost:8080/?tkn=dev-token',
browserName: 'chromium'
},
grep: /@:web/
},
{
name: 'e2e-macOS-ci',
use: {
artifactDir: 'e2e-macOS-ci',
},
grep: /@:win/,
grepInvert: /@:web-only|@:interpreter/
},
{
name: 'e2e-workbench',
testIgnore: [
'example.test.ts',
'**/assistant-eval/**',
'**/remote-ssh/**'
],
use: {
artifactDir: 'e2e-workbench',
headless: false,
useExternalServer: true,
externalServerUrl: 'http://localhost:8787',
browserName: 'chromium',
},
grep: /@:workbench/
},
{
name: 'e2e-remote-ssh',
testIgnore: [
'example.test.ts',
'**/assistant-eval/**',
'**/workbench/**',
],
use: {
artifactDir: 'e2e-remote-ssh',
headless: false,
useExternalServer: false,
},
grep: /@:remote-ssh/
},
{
name: 'e2e-jupyter',
testIgnore: [
'example.test.ts',
'**/assistant-eval/**',
'**/remote-ssh/**'
],
use: {
artifactDir: 'e2e-jupyter',
headless: false,
useExternalServer: true,
externalServerUrl: 'http://localhost:8888',
browserName: 'chromium',
},
grep: /@:jupyter/
},
{
name: 'release-screenshots',
testDir: './test/e2e/release-screenshots',
testMatch: '*.screenshot.ts',
testIgnore: [],
use: {
artifactDir: 'release-screenshots',
},
},
],
});
/**
* Check if the current platform is openSUSE
*/
function isOpenSUSE(): boolean {
try {
const osRelease = fs.readFileSync('/etc/os-release', 'utf8').toLowerCase();
const id = osRelease.match(/^id=(.*)$/m)?.[1]?.trim().replace(/^"|"$/g, '') ?? '';
const idLike = osRelease.match(/^id_like=(.*)$/m)?.[1]?.trim().replace(/^"|"$/g, '') ?? '';
return id.startsWith('opensuse') || id.includes('opensuse-leap') || idLike.includes('opensuse');
} catch {
return false;
}
}
/**
* Check if the current platform is SLES (SUSE Linux Enterprise Server)
*/
function isSLES(): boolean {
try {
const osRelease = fs.readFileSync('/etc/os-release', 'utf8').toLowerCase();
const id = osRelease.match(/^id=(.*)$/m)?.[1]?.trim().replace(/^"|"$/g, '') ?? '';
const idLike = osRelease.match(/^id_like=(.*)$/m)?.[1]?.trim().replace(/^"|"$/g, '') ?? '';
return id === 'sles' || idLike.includes('sles');
} catch {
return false;
}
}
// Set environment variable for tests to check
const IS_OPENSUSE = isOpenSUSE();
process.env.IS_OPENSUSE = IS_OPENSUSE ? 'true' : 'false';
const IS_SLES = isSLES();
process.env.IS_SLES = IS_SLES ? 'true' : 'false';