-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
132 lines (123 loc) · 3.58 KB
/
Copy pathplaywright.config.ts
File metadata and controls
132 lines (123 loc) · 3.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
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
import {
defineConfig,
devices
} from '@playwright/test';
import {
AUTH_STORAGE_STATE_PATH,
hasE2EAuthCredentials,
loadE2EEnvFromDotEnv
} from './e2e/helpers/auth';
/**
* Playwright configuration for Patcher E2E tests.
*
* Run:
* pnpm test:e2e — local, list reporter
* pnpm test:e2e:ci — CI, single worker
*
* For local runs against localhost:5556, Playwright starts the Angular dev server automatically.
* Set BASE_URL env var to point tests at another host (e.g. staging URL).
*/
const BASE_URL = process.env['BASE_URL'] ?? 'http://localhost:5556';
const LOCAL_DEV_SERVER_URL = 'http://localhost:5556';
const AUTH_SPEC_GLOB = '**/auth-*.spec.ts';
loadE2EEnvFromDotEnv();
const hasAuthCredentials = hasE2EAuthCredentials();
const usesLocalDevServer = (() => {
try {
const parsedBaseURL = new URL(BASE_URL);
return ['localhost', '127.0.0.1'].includes(parsedBaseURL.hostname) && parsedBaseURL.port === '5556';
} catch {
return false;
}
})();
if (!hasAuthCredentials) {
console.warn('[e2e-auth] Authenticated tests are disabled until E2E_TEST_EMAIL and E2E_TEST_PASSWORD are set.');
}
export default defineConfig({
testDir: './e2e',
testMatch: [
'**/manufacturer-browser.spec.ts',
'**/module-browser.spec.ts',
'**/module-browser-pagination.spec.ts',
'**/module-browser-tags.spec.ts',
'**/module-details.spec.ts',
'**/module-editor-ux-review.spec.ts',
'**/patch-browser.spec.ts',
'**/patch-graph-stability.spec.ts',
'**/rack-browser.spec.ts',
'**/rack-details-layout.spec.ts',
'**/home.spec.ts',
'**/navigation.spec.ts',
'**/info-pages.spec.ts',
'**/patch-details.spec.ts',
'**/public-id-links.spec.ts',
'**/login-pages-smoke.spec.ts',
'**/public-profile.spec.ts',
AUTH_SPEC_GLOB
],
/* Use Node-compatible tsconfig — root tsconfig uses "bundler" which breaks Playwright */
tsconfig: './e2e/tsconfig.json',
globalSetup: './e2e/global-setup.ts',
/* Each test gets its own timeout */
timeout: 30_000,
expect: {timeout: 5_000},
/* Fail fast on first failure in CI */
fullyParallel: true,
forbidOnly: !!process.env['CI'],
retries: process.env['CI'] ? 2 : 0,
workers: process.env['CI'] ? 1 : undefined,
reporter: 'list',
webServer: usesLocalDevServer
? {
command: 'pnpm start',
url: LOCAL_DEV_SERVER_URL,
reuseExistingServer: !process.env['CI'],
timeout: 180_000
}
: undefined,
use: {
baseURL: BASE_URL,
/* Collect trace only when retrying a failed test */
trace: 'on-first-retry',
screenshot: 'only-on-failure',
headless: true,
},
projects: [
{
name: 'chromium',
testIgnore: [AUTH_SPEC_GLOB],
use: {...devices['Desktop Chrome']},
},
{
name: 'webkit',
testIgnore: [AUTH_SPEC_GLOB],
use: {...devices['Desktop Safari']},
},
...(hasAuthCredentials
? [{
name: 'chromium-auth',
testMatch: [AUTH_SPEC_GLOB],
testIgnore: ['**/screenshots/**/*.spec.ts'],
use: {
...devices['Desktop Chrome'],
storageState: AUTH_STORAGE_STATE_PATH
}
}, {
name: 'chromium-screenshots',
testMatch: ['**/screenshots/**/*.spec.ts'],
use: {
...devices['Desktop Chrome'],
storageState: AUTH_STORAGE_STATE_PATH
}
}, {
name: 'webkit-auth',
testMatch: [AUTH_SPEC_GLOB],
testIgnore: ['**/screenshots/**/*.spec.ts'],
use: {
...devices['Desktop Safari'],
storageState: AUTH_STORAGE_STATE_PATH
}
}]
: []),
],
});