playwright.config.ts
2.76 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
import { defineConfig, devices } from '@playwright/test';
const isCI = Boolean(process.env.CI);
const singlePageApiTarget = process.env.E2E_SINGLE_PAGE_API_TARGET || 'http://192.168.1.191:8000/';
const webServersByProject = [
{
projectName: 'agent-admin-web',
config: {
command: 'npm run dev -- --host 127.0.0.1 --port 5173',
cwd: '../workspace/agent-admin/web',
url: 'http://127.0.0.1:5173',
reuseExistingServer: !isCI,
timeout: 120_000,
},
},
{
projectName: 'agent-admin-single-page',
config: {
command: 'npm run dev -- --host 127.0.0.1 --port 3001',
cwd: '../workspace/agent-admin/single-page',
env: {
VITE_API_PROXY_TARGET: singlePageApiTarget,
},
url: 'http://127.0.0.1:3001/gl-agent-position/',
reuseExistingServer: !isCI,
timeout: 120_000,
},
},
{
projectName: 'single-pages',
config: {
command: 'npm run dev -- --host 127.0.0.1 --port 4173',
cwd: '../workspace/single-pages/front',
url: 'http://127.0.0.1:4173/prelearning.html',
reuseExistingServer: !isCI,
timeout: 120_000,
},
},
];
const requestedProjectNames = process.argv
.flatMap((arg, index, args) => {
if (arg === '--project' && args[index + 1]) {
return [args[index + 1]];
}
if (arg.startsWith('--project=')) {
return [arg.slice('--project='.length)];
}
return [];
})
.filter((name) => name.length > 0);
const selectedWebServers = requestedProjectNames.length > 0
? webServersByProject
.filter((server) => requestedProjectNames.includes(server.projectName))
.map((server) => server.config)
: webServersByProject.map((server) => server.config);
export default defineConfig({
testDir: './tests',
timeout: 30_000,
expect: {
timeout: 8_000,
},
fullyParallel: true,
forbidOnly: isCI,
retries: isCI ? 2 : 0,
workers: isCI ? 1 : undefined,
reporter: [['list'], ['html', { open: 'never' }]],
use: {
trace: 'retain-on-failure',
screenshot: 'only-on-failure',
video: 'retain-on-failure',
},
webServer: process.env.E2E_SKIP_WEBSERVER === '1' ? undefined : selectedWebServers,
projects: [
{
name: 'agent-admin-web',
testMatch: /agent-admin-web\/.*\.spec\.ts/,
use: {
...devices['Desktop Chrome'],
baseURL: 'http://127.0.0.1:5173',
},
},
{
name: 'agent-admin-single-page',
testMatch: /agent-admin-single-page\/.*\.spec\.ts/,
use: {
...devices['Desktop Chrome'],
baseURL: 'http://127.0.0.1:3001/gl-agent-position/',
},
},
{
name: 'single-pages',
testMatch: /single-pages\/.*\.spec\.ts/,
use: {
...devices['Desktop Chrome'],
baseURL: 'http://127.0.0.1:4173',
},
},
],
});