-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
97 lines (91 loc) · 2.83 KB
/
playwright.config.ts
File metadata and controls
97 lines (91 loc) · 2.83 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
import type { PlaywrightTestConfig } from '@playwright/test';
import path from 'path';
import url from 'url';
const __filename = url.fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// Storage state paths for different test users
// These are stored outside e2e-test-results to avoid being wiped by the HTML reporter
export const STORAGE_STATE = path.join(__dirname, '.playwright/.auth/test.json');
export const STORAGE_STATE_USER_A = path.join(__dirname, '.playwright/.auth/userA.json');
export const STORAGE_STATE_USER_B = path.join(__dirname, '.playwright/.auth/userB.json');
export const SHARED_TEST_DATA = path.join(__dirname, '.playwright/.shared/test-data.json');
// Map of user names to their storage state paths
export const USER_STORAGE_STATES: Record<string, string> = {
test: STORAGE_STATE,
userA: STORAGE_STATE_USER_A,
userB: STORAGE_STATE_USER_B,
};
const MAIN_TEST_SUITE_BASE_URL = 'http://localhost:3000';
const SEQUENCE_TEMPLATE_TEST_SUITE_BASE_URL = 'http://localhost:3001';
const config: PlaywrightTestConfig = {
forbidOnly: !!process.env.CI,
projects: [
{
name: 'setup-auth',
testMatch: /global\.setup\.auth\.ts/,
use: {
baseURL: MAIN_TEST_SUITE_BASE_URL,
},
},
{
name: 'setup-jar',
testMatch: /global\.setup\.jar\.ts/,
},
{
dependencies: ['setup-auth', 'setup-jar'],
name: 'e2e tests',
teardown: 'teardown',
testDir: './e2e-tests',
testIgnore: /.*\/sequence-templates\.test\.ts/,
use: {
baseURL: MAIN_TEST_SUITE_BASE_URL,
storageState: STORAGE_STATE,
},
},
{
dependencies: ['setup-auth', 'setup-jar'],
name: 'e2e sequence template tests',
teardown: 'teardown',
testDir: './e2e-tests',
testMatch: /.*\/sequence-templates\.test\.ts/,
use: {
baseURL: SEQUENCE_TEMPLATE_TEST_SUITE_BASE_URL,
storageState: STORAGE_STATE,
},
},
{
name: 'teardown',
testMatch: /global\.teardown\.ts/,
},
],
reportSlowTests: {
max: 0,
threshold: 60000,
},
reporter: [
['list'],
...(process.env.CI ? [['github'] as const] : []),
['html', { open: 'never', outputFile: 'index.html', outputFolder: 'e2e-test-results' }],
['json', { outputFile: 'e2e-test-results/json-results.json' }],
['junit', { outputFile: 'e2e-test-results/junit-results.xml' }],
],
retries: 2,
testDir: './e2e-tests',
use: {
browserName: 'chromium',
trace: process.env.CI ? 'retain-on-failure' : 'off',
video: process.env.CI ? 'retain-on-failure' : 'off',
},
webServer: [
{
command: 'npm run preview',
port: 3000,
reuseExistingServer: !process.env.CI,
},
{
command: 'PUBLIC_COMMAND_EXPANSION_MODE=templating npm run preview',
port: 3001,
},
],
};
export default config;