-
Notifications
You must be signed in to change notification settings - Fork 0
/
playwright.config.ts
78 lines (72 loc) · 1.71 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
import type { PlaywrightTestConfig } from '@playwright/test';
import * as glob from 'glob';
const testDir = 'e2e';
const groupTests = (keys: string[]) => {
const pattern = new RegExp(/.*?\.((.+)\.)?test\.ts/);
const testFiles = glob.sync(`${testDir}/**/*.{test,spec}.ts`);
const grouped: { [size: string]: string[] } = Object.fromEntries(keys.map((size) => [size, []]));
for (const filename of testFiles) {
const match = filename.match(pattern) || [];
const size: string | undefined = match[2];
if (size) {
grouped[size].push(filename);
} else {
Object.values(grouped).forEach((arr) => arr.push(filename));
}
}
return grouped;
};
const testGroups = groupTests(['sm', 'md', 'lg']);
// BUG: Playwright seems not detecting file changes (create / delete)
export default {
webServer: {
// NOTE: This will trigger Codecov bundle analysis upload due to build
command: 'yarn run build && yarn run preview',
port: 4173
},
use: {
screenshot: 'only-on-failure'
},
testDir,
testMatch: /(.+\.)?(test|spec)\.[jt]s/,
reporter: [
['list'],
[
'html',
{
open: process.env.CI ? 'never' : 'on-failure',
host: process.env.CONTAINER ? '0.0.0.0' : '127.0.0.1'
}
],
['junit', { outputFile: 'junit.xml' }]
],
projects: [
{
// Phones
name: 'Small devices',
testMatch: testGroups['sm'],
use: {
viewport: { width: 640, height: 1136 }
}
},
{
// Tablets
name: 'Medium devices',
testMatch: testGroups['md'],
use: {
viewport: { width: 768, height: 1280 }
}
},
{
// Laptops
name: 'Large devices',
testMatch: testGroups['lg'],
use: {
viewport: { width: 1024, height: 1366 }
}
}
],
expect: {
timeout: 5000
}
} satisfies PlaywrightTestConfig;