forked from AmadeusITGroup/AgnosUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
playwright.config.ts
132 lines (123 loc) · 3.87 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
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 type {PlaywrightTestConfig} from '@playwright/test';
import {devices} from '@playwright/test';
import path from 'path';
import type {FixtureOptions} from './e2e/fixture';
import type {Frameworks, Project} from './e2e/types';
const isCI = process.env.CI === 'true';
const allBrowsers = {
chromium: devices['Desktop Chrome'],
firefox: devices['Desktop Firefox'],
webkit: devices['Desktop Safari'],
};
const processEnvList = <T extends string>(name: string, valuesMap: Record<T, any>): {fullList: T[]; filteredList?: T[]} => {
const fullList = Object.keys(valuesMap) as T[];
const envValue = process.env[name]?.trim()?.toLowerCase()?.split(',');
if (!envValue) {
return {fullList};
}
const envValueSet = new Set<T>(envValue as T[]);
for (const value of envValueSet) {
if (!Object.prototype.hasOwnProperty.call(valuesMap, value)) {
throw new Error(`Invalid value for ${name}: ${value}`);
}
}
return {fullList, filteredList: [...envValueSet]};
};
const playwrightProjects: PlaywrightTestConfig<FixtureOptions>['projects'] = [];
const allFrameworks: Record<Frameworks, any> = {
angular: {},
react: {},
svelte: {},
};
const allProjects: Record<Project, () => void> = {
main: () => {
(selectedFrameworks.filteredList ?? selectedFrameworks.fullList).forEach((framework) => {
(selectedBrowsers.filteredList ?? selectedBrowsers.fullList).forEach((browser) => {
playwrightProjects.push({
name: `main:${framework}:${browser}`,
testMatch: '**/*.e2e-spec.ts',
use: {
...allBrowsers[browser],
framework,
project: 'main',
},
});
});
});
},
singlebrowser: () => {
(selectedFrameworks.filteredList ?? selectedFrameworks.fullList).forEach((framework) => {
(selectedBrowsers.filteredList ?? ['chromium']).forEach((browser) => {
playwrightProjects.push({
name: `singleBrowser:${framework}:${browser}`,
testMatch: '**/*.singlebrowser-e2e-spec.ts',
use: {
...allBrowsers[browser],
framework,
project: 'singlebrowser',
},
});
});
});
},
demo: () => {
(selectedBrowsers.filteredList ?? ['chromium']).forEach((browser) => {
playwrightProjects.push({
name: `demo:${browser}`,
testMatch: '**/*.demo-e2e-spec.ts',
use: {
...allBrowsers[browser],
project: 'demo',
},
});
});
},
stackblitz: () => {
(selectedFrameworks.filteredList ?? selectedFrameworks.fullList).forEach((framework) => {
(selectedBrowsers.filteredList ?? ['chromium']).forEach((browser) => {
playwrightProjects.push({
name: `stackblitz:${framework}:${browser}`,
testMatch: 'samplesMarkup.singlebrowser-e2e-spec.ts',
use: {
...allBrowsers[browser],
framework,
project: 'stackblitz',
},
});
});
});
},
ssr: () => {
(selectedFrameworks.filteredList ?? selectedFrameworks.fullList).forEach((framework) => {
(selectedBrowsers.filteredList ?? ['chromium']).forEach((browser) => {
playwrightProjects.push({
name: `ssr:${framework}:${browser}`,
testMatch: '**/*.ssr-e2e-spec.ts',
use: {
...allBrowsers[browser],
framework,
project: 'ssr',
},
});
});
});
},
};
const selectedProjects = processEnvList('PROJECT', allProjects);
const selectedFrameworks = processEnvList('FRAMEWORK', allFrameworks);
const selectedBrowsers = processEnvList('BROWSER', allBrowsers);
(selectedProjects.filteredList ?? selectedProjects.fullList).forEach((project) => allProjects[project]());
const config: PlaywrightTestConfig<FixtureOptions> = {
globalSetup: path.join(import.meta.dirname, './e2e/global-setup'),
testDir: 'e2e',
retries: 1,
reporter: [[isCI ? 'github' : 'list'], isCI ? ['blob'] : ['html', {open: 'never'}]],
forbidOnly: isCI,
snapshotPathTemplate: '{testDir}/{testFilePath}-snapshots/{arg}{ext}',
use: {
trace: 'on-all-retries',
video: 'on-first-retry',
},
projects: playwrightProjects,
};
export default config;