-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathplaywright.config.ts
84 lines (72 loc) · 2.19 KB
/
playwright.config.ts
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
import { PlaywrightTestConfig, defineConfig, devices } from '@playwright/test';
const defaultServerConfig = {
url: 'http://localhost:8005/',
ignoreHTTPSErrors: true,
reuseExistingServer: true,
timeout: 10 * 60 * 1000,
};
/* eslint-disable no-param-reassign */
const configurators = {
'smoke-deprecated': (baseConfig: PlaywrightTestConfig) => {
baseConfig.workers = 1;
baseConfig.testDir = './playwright/tests/smoke-deprecated';
baseConfig.webServer = {
...defaultServerConfig,
command: 'cd sites/test-site && npm run start',
};
},
'smoke-vital': (baseConfig: PlaywrightTestConfig) => {
// The number of workers is choosen depending on number of renderers in applitools configuration
// in components-visual.spec.ts file
baseConfig.workers = process.env.PW_INCLUDE_ALL_RENDERERS === 'true' ? 3 : 5;
baseConfig.testDir = './playwright/tests/smoke';
baseConfig.webServer = {
...defaultServerConfig,
command: 'cd sites/vital-demo && npm run serve:test',
};
baseConfig.globalSetup = require.resolve('./playwright/tests/setup/setup.ts');
},
};
/* eslint-enable no-param-reassign */
/**
* See https://playwright.dev/docs/test-configuration.
*/
const config: PlaywrightTestConfig = {
testDir: './playwright/tests',
timeout: 90 * 1000,
expect: {
timeout: 5000,
},
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: [
['html', { open: 'never' }],
['junit', { outputFile: 'playwright-report/results.xml' }]
],
use: {
actionTimeout: 0,
baseURL: 'http://localhost:8005',
trace: 'on',
testIdAttribute: 'id'
},
projects: [
{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
viewport: { width: 1200, height: 850 },
},
},
],
};
const suite: string = process.env.PLAYWRIGHT_SUITE as string;
if (!suite) {
throw Error('The PLAYWRIGHT_SUITE environment variable is not set');
}
const configurator = configurators[suite];
if (!configurator) {
throw Error(`Unknown playwright suite: ${suite}, use one of ${Object.keys(configurators)}`);
}
configurator(config);
export default defineConfig(config);