-
Notifications
You must be signed in to change notification settings - Fork 763
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
162 lines (149 loc) · 4.6 KB
/
Copy pathplaywright.config.ts
File metadata and controls
162 lines (149 loc) · 4.6 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
import * as path from 'path';
import * as dotenv from 'dotenv';
dotenv.config({ path: path.resolve(__dirname, 'e2e', '.env'), quiet: true });
import { defineConfig, devices } from '@playwright/test';
import { INTEGRATION_TEST_USER_AGENT } from './packages/console-shared/src/constants/common';
const isCI = !!process.env.OPENSHIFT_CI || !!process.env.CI;
const chrome = { ...devices['Desktop Chrome'], userAgent: INTEGRATION_TEST_USER_AGENT };
const isDebug = process.env.DEBUG === '1' || process.env.DEBUG === 'true';
const baseURL = process.env.WEB_CONSOLE_URL || 'http://localhost:9000';
// Keep these paths in sync with adminStorageState/developerStorageState in
// e2e/setup/login-helper.ts. They cannot be imported here: that module uses
// import.meta (ESM) while Playwright loads this config as CommonJS.
const adminStorageState = path.resolve(__dirname, 'e2e', '.auth', 'kubeadmin.json');
const developerStorageState = path.resolve(__dirname, 'e2e', '.auth', 'developer.json');
const hasDeveloper = !!process.env.BRIDGE_HTPASSWD_USERNAME;
const packages = [
'smoke',
'console',
'dev-console',
'helm',
'knative',
'olm',
'topology',
'webterminal',
];
// Packages that also have developer-persona tests
const devPackages = ['smoke', 'dev-console', 'topology', 'webterminal'];
const chromeArgs = [
'--ignore-certificate-errors',
'--window-size=1920,1080',
'--disable-dev-shm-usage',
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-background-networking',
'--disable-background-timer-throttling',
'--disable-client-side-phishing-detection',
'--disable-default-apps',
'--disable-extensions',
'--disable-popup-blocking',
'--disable-sync',
'--disable-translate',
'--no-first-run',
];
export default defineConfig({
testDir: './e2e/tests',
testMatch: '**/*.spec.ts',
forbidOnly: isCI,
globalTimeout: Number(process.env.GLOBAL_TIMEOUT_MS) || 0,
retries: isCI ? 2 : 0,
timeout: 120_000,
reporter: isCI
? [
['line'],
[
'junit',
{
outputFile: path.resolve(__dirname, 'test-results', 'junit-results.xml'),
includeRetries: true,
},
],
['html', { outputFolder: path.resolve(__dirname, 'playwright-report'), open: 'never' }],
[
'./e2e/reporters/prow-junit-reporter.ts',
{
outputFile: path.resolve(__dirname, 'test-results', 'prow-junit-results.xml'),
},
],
]
: [['list']],
use: {
testIdAttribute: 'data-test',
baseURL,
trace: isCI ? 'on-first-retry' : 'retain-on-failure',
screenshot: 'only-on-failure',
video: isDebug ? 'on' : 'retain-on-failure',
viewport: { width: 1920, height: 1080 },
ignoreHTTPSErrors: true,
launchOptions: {
args: chromeArgs,
},
},
workers: process.env.WORKERS ? Number(process.env.WORKERS) || undefined : undefined,
projects: [
{
name: 'cluster-setup',
testDir: path.resolve(__dirname, 'e2e', 'setup'),
testMatch: 'cluster.setup.ts',
teardown: 'teardown',
},
{
name: 'admin-auth',
testDir: path.resolve(__dirname, 'e2e', 'setup'),
testMatch: 'admin-auth.setup.ts',
dependencies: ['cluster-setup'],
use: {
...chrome,
ignoreHTTPSErrors: true,
launchOptions: {
args: chromeArgs,
},
},
},
{
name: 'developer-auth',
testDir: path.resolve(__dirname, 'e2e', 'setup'),
testMatch: 'developer-auth.setup.ts',
dependencies: ['cluster-setup'],
use: {
...chrome,
ignoreHTTPSErrors: true,
launchOptions: {
args: chromeArgs,
},
},
},
{
name: 'teardown',
testDir: path.resolve(__dirname, 'e2e', 'setup'),
testMatch: 'teardown.setup.ts',
},
{
name: 'knative-setup',
testDir: path.resolve(__dirname, 'e2e', 'setup'),
testMatch: 'knative.setup.ts',
dependencies: ['cluster-setup'],
},
...packages.map((pkg) => ({
name: pkg,
testDir: path.resolve(__dirname, 'e2e', 'tests', pkg),
testIgnore: '**/developer/**',
dependencies: pkg === 'knative' ? ['admin-auth', 'knative-setup'] : ['admin-auth'],
use: {
...chrome,
storageState: adminStorageState,
},
})),
...(hasDeveloper
? devPackages.map((pkg) => ({
name: `${pkg}-developer`,
testDir: path.resolve(__dirname, 'e2e', 'tests', pkg, 'developer'),
dependencies: ['developer-auth'],
use: {
...chrome,
storageState: developerStorageState,
},
}))
: []),
],
});