-
Notifications
You must be signed in to change notification settings - Fork 131
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
131 lines (121 loc) 路 3.29 KB
/
Copy pathplaywright.config.ts
File metadata and controls
131 lines (121 loc) 路 3.29 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
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
/* eslint-disable jsdoc/require-jsdoc */
import type { ReporterDescription } from '@playwright/test'
import { defineConfig, devices } from '@playwright/test'
const COMPARISON_E2E = process.env.TEXT_COMPARISON_E2E === '1'
const COMPARISON_TESTS = /playwright\/comparison\/.*\.spec\.ts/
const COMPARISON_BASE_URL = process.env.TEXT_COMPARISON_BASE_URL || process.env.baseURL || 'http://localhost:8089/index.php/'
const EXTERNAL_COMPARISON_SERVER = Boolean(process.env.TEXT_COMPARISON_BASE_URL || process.env.baseURL)
function comparisonProjects() {
if (!COMPARISON_E2E) {
return []
}
return [{
name: 'comparison-chromium',
testMatch: COMPARISON_TESTS,
grepInvert: /@memory/,
use: {
...devices['Desktop Chrome'],
baseURL: COMPARISON_BASE_URL,
ignoreHTTPSErrors: true,
screenshot: 'only-on-failure' as const,
trace: 'retain-on-failure' as const,
},
}, {
name: 'comparison-webkit',
testMatch: COMPARISON_TESTS,
grepInvert: /@memory/,
use: {
...devices['Desktop Safari'],
baseURL: COMPARISON_BASE_URL,
ignoreHTTPSErrors: true,
screenshot: 'only-on-failure' as const,
trace: 'retain-on-failure' as const,
},
}, {
name: 'comparison-chromium-memory',
testMatch: COMPARISON_TESTS,
grep: /@memory/,
use: {
...devices['Desktop Chrome'],
baseURL: COMPARISON_BASE_URL,
ignoreHTTPSErrors: true,
screenshot: 'only-on-failure' as const,
trace: 'retain-on-failure' as const,
},
}]
}
/**
* Used locally - i.e. if `CI` is not set as an environment variable.
*/
const LOCAL_CONFIG = {
// Just the html report with the traces
reporter: 'list',
} as const
/**
* Used on CI - i.e. if `CI` is set as an environment variable.
*/
const CI_CONFIG = {
// ensure no `test.only` is left in the code causing false positives
forbidOnly: true,
// blob (so we can merge reports and download them for inspection),
// dot (so we have a quick overview in the logs while the tests are running)
// github (to have annotations in the PR)
reporter: [
['blob'],
['json', { outputFile: 'test-results/results.json' }],
['line'],
['github'],
] as ReporterDescription[],
retries: 1,
timeout: 45_000,
// we shard to speed up the tests so no parallelism in workers
workers: 1,
} as const
function comparisonWebServer() {
if (EXTERNAL_COMPARISON_SERVER) {
return undefined
}
return {
command: 'npm run start:nextcloud',
gracefulShutdown: {
signal: 'SIGTERM' as const,
timeout: 10000,
},
reuseExistingServer: false,
stderr: 'pipe' as const,
stdout: 'pipe' as const,
timeout: 5 * 60 * 1000,
wait: {
stdout: /Nextcloud is now ready to use/,
},
}
}
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './playwright',
...(process.env.CI ? CI_CONFIG : LOCAL_CONFIG),
workers: COMPARISON_E2E ? 1 : undefined,
use: {
// Base URL to use in actions like `await page.goto('./')`.
baseURL: COMPARISON_BASE_URL,
// record traces but only keep them when the test fails
trace: 'on-first-retry',
},
projects: [
{
name: 'chromium',
testIgnore: COMPARISON_TESTS,
use: {
...devices['Desktop Chrome'],
},
},
...comparisonProjects(),
],
webServer: comparisonWebServer(),
})