-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
124 lines (112 loc) · 3.64 KB
/
Copy pathplaywright.config.ts
File metadata and controls
124 lines (112 loc) · 3.64 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
import { defineConfig, devices } from '@playwright/test';
import type { ReporterDescription } from '@playwright/test';
import path from 'node:path';
import env from './utilities/env';
// Helper to detect BrowserStack run
const isBrowserStack = Boolean(
process.env.BROWSERSTACK_USERNAME && process.env.BROWSERSTACK_ACCESS_KEY,
);
function buildBrowserStackEndpoint(testName: string) {
const caps = {
browser: 'chrome',
browser_version: 'latest',
os: 'os x',
os_version: 'catalina',
name: testName,
build: process.env.CI_BUILD_NUMBER || 'local-run',
'browserstack.username': process.env.BROWSERSTACK_USERNAME,
'browserstack.accessKey': process.env.BROWSERSTACK_ACCESS_KEY,
};
return `wss://cdp.browserstack.com/playwright?caps=${encodeURIComponent(JSON.stringify(caps))}`;
}
export default defineConfig({
testDir: './tests',
outputDir: './test-results', // Custom output directory
globalSetup: require.resolve(path.join(__dirname, 'tests/global-setup')),
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 1 : 0,
workers: process.env.CI ? 2 : undefined,
timeout: process.env.CI ? 120_000 : 60_000,
expect: {
toHaveScreenshot: { maxDiffPixelRatio: 0.2 },
},
reporter: ((): ReporterDescription[] => {
const reporters: ReporterDescription[] = [
['html', { open: 'never', outputFolder: 'playwright-report' }],
['json', { outputFile: 'test-results/last-run.json' }],
];
// In CI, emit a blob report per shard so a downstream job can merge all shards
// and upload to Xray once (avoids concurrent per-shard uploads → Xray HTTP 500).
if (process.env.CI) {
reporters.push(['blob']);
}
reporters.push(['./utilities/xray-json-reporter.ts']);
return reporters;
})(),
use: {
baseURL: env.BASE_URL,
trace: 'on-first-retry',
screenshot: 'only-on-failure',
video: 'retain-on-failure',
// Custom test attachment naming
testIdAttribute: 'data-testid',
},
projects: [
{
name: 'chromium-personal',
testMatch: '**/personal/**/*.spec.ts',
use: {
...devices['Desktop Chrome'],
storageState: 'tests/.auth/personal.json',
headless: !!process.env.CI,
},
},
{
name: 'chromium-claimed',
testMatch: '**/claimed/**/*.spec.ts',
use: {
...devices['Desktop Chrome'],
storageState: 'tests/.auth/claimed.json',
headless: !!process.env.CI,
},
},
{
name: 'chromium-clinician',
testMatch: '**/clinician/**/*.spec.ts',
use: {
...devices['Desktop Chrome'],
storageState: 'tests/.auth/clinician.json',
headless: !!process.env.CI,
},
},
...(isBrowserStack
? [
{
name: 'bs-chrome-personal',
testMatch: '**/personal/**/*.spec.ts',
use: {
storageState: 'tests/.auth/personal.json',
connectOptions: { wsEndpoint: buildBrowserStackEndpoint('Personal Patient Tests') },
},
},
{
name: 'bs-chrome-claimed',
testMatch: '**/claimed/**/*.spec.ts',
use: {
storageState: 'tests/.auth/claimed.json',
connectOptions: { wsEndpoint: buildBrowserStackEndpoint('Claimed Patient Tests') },
},
},
{
name: 'bs-chrome-clinician',
testMatch: '**/clinician/**/*.spec.ts',
use: {
storageState: 'tests/.auth/clinician.json',
connectOptions: { wsEndpoint: buildBrowserStackEndpoint('Clinician Tests') },
},
},
]
: []),
],
});