-
Notifications
You must be signed in to change notification settings - Fork 1
/
playwright.config.js
50 lines (44 loc) · 1.03 KB
/
playwright.config.js
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
/**
* External dependencies
*/
import {
fileURLToPath
} from 'url';
import {
defineConfig,
devices
} from '@playwright/test';
/**
* WordPress dependencies
*/
const baseConfig = require('@wordpress/scripts/config/playwright.config');
// Parse the .wp-env.json file to get the "barn2" property.
const wpEnv = require('./package.json');
const {
barn2
} = wpEnv;
// Now that we have the barn2 property, we can use it to programmatically generate projects.
const barn2Projects = [];
for (const [index, themeConfig] of Object.entries(barn2.tests)) {
barn2Projects.push({
name: themeConfig.name,
use: {
...devices['Desktop Chrome'],
},
testDir: `./tests/e2e/${ themeConfig.name }`,
});
}
// Merge the base config with the barn2 projects.
const config = defineConfig({
...baseConfig,
reporter: process.env.CI ? [
['github']
] : 'list',
workers: 1,
testDir: './tests/e2e',
globalSetup: fileURLToPath(
new URL('./tests/e2e/global-setup.js', 'file:' + __filename).href
),
projects: barn2Projects,
});
export default config;