-
Notifications
You must be signed in to change notification settings - Fork 29
/
playwright.config.ts
91 lines (82 loc) · 2.51 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
import type { PlaywrightTestConfig } from '@playwright/test';
import { devices } from '@playwright/test';
import dotenv from 'dotenv';
dotenv.config();
const chromeConfig = {
name: 'chromium',
use: {
...devices['Desktop Chrome'],
// Use prepared auth state.
storageState: 'playwright/.auth/user.json'
},
dependencies: ['setup']
};
// LEAVE THIS COMMENTED OUT CODE FOR DEVELOPMENT PURPOSES/TESTING
// const firefoxConfig = {
// name: 'firefox',
// use: {
// ...devices['Desktop Firefox'],
// // Use prepared auth state.
// storageState: 'playwright/.auth/user.json'
// },
// dependencies: ['setup']
// };
// const webkitConfig = {
// name: 'webkit',
// use: { ...devices['Desktop Safari'], storageState: 'playwright/.auth/user.json' },
// dependencies: ['setup']
// };
// const edgeConfig = {
// name: 'Edge',
// use: {
// ...devices['Desktop Edge'],
// channel: 'msedge',
// storageState: 'playwright/.auth/user.json'
// },
// dependencies: ['setup']
// };
const defaultConfig: PlaywrightTestConfig = {
// running more than 1 worker can cause flakiness due to test files being run at the same time in different browsers
// (e.x. navigation history is incorrect)
// Additionally, Leapfrog API is slow when attaching files to assistants, resulting in flaky tests
// We can attempt in increase number of browser and workers in the pipeline when the API is faster
workers: 1,
projects: [
{ name: 'setup', testMatch: /global\.setup\.ts/, teardown: 'cleanup' },
{
name: 'cleanup',
testMatch: /global\.teardown\.ts/
},
{ ...chromeConfig }
]
};
// when in dev, create a local webserver
const devConfig: PlaywrightTestConfig = {
webServer: {
command: 'npm run build && npm run preview',
port: 4173,
stderr: 'pipe'
},
testDir: 'tests',
testMatch: /(.+\.)?(test|spec)\.[jt]s/,
use: {
baseURL: 'http://localhost:4173'
}
};
// when e2e testing, use the deployed instance
const CI_Config: PlaywrightTestConfig = {
use: {
baseURL: 'https://ai.uds.dev',
screenshot: 'only-on-failure',
video: 'retain-on-failure'
},
reporter: [['html', { outputFolder: 'e2e-report' }]]
};
// get the environment type from command line. If none, set it to dev
const environment = process.env.TEST_ENV || 'development';
// config object with default configuration and environment specific configuration
const config: PlaywrightTestConfig = {
...defaultConfig,
...(environment === 'CI' ? CI_Config : devConfig)
};
export default config;