-
Notifications
You must be signed in to change notification settings - Fork 84
/
playwright.config.ts
61 lines (50 loc) · 1.6 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
import { env } from 'process';
import { config as dotenv } from 'dotenv';
import { defineConfig, devices } from '@playwright/test';
import { isKeyOfObject } from './src/utils/types';
dotenv({ path: '.env.local', override: true });
const PROJECTS_LIST = {
DEV: ['Desktop Chrome'],
GITHUB_MAC: ['Desktop Safari'],
GITHUB_LINUX: ['Desktop Chrome', 'Desktop Firefox'],
};
const mode = (env.TEST_PROJECT_LIST || 'DEV').toUpperCase();
if (!(mode && isKeyOfObject(mode, PROJECTS_LIST))) {
const list = Object.keys(PROJECTS_LIST)
.map((s) => `'${s.toLowerCase()}'`)
.join(' or ');
throw Error(`TEST_PROJECT_LIST should be ${list}`);
}
const isDevMode = Boolean(mode === 'DEV');
export default defineConfig({
testDir: './tests',
testMatch: /.*\.(e2e|test)\.tsx?$/,
snapshotPathTemplate: `{testDir}/{testFileDir}/__screenshots__/${mode.toLowerCase()}/{projectName}/{testFilePath}-{arg}{ext}`,
timeout: 30000,
forbidOnly: !isDevMode,
reporter: 'list',
retries: isDevMode ? 0 : 2,
fullyParallel: !isDevMode,
webServer: {
command: 'npm run test:server',
port: 8000,
reuseExistingServer: isDevMode,
},
use: {
testIdAttribute: 'data-test',
headless: ((value) => (value ? value === 'true' : !isDevMode))(
env.TEST_HEADLESS_MODE,
),
ignoreHTTPSErrors: true,
screenshot: {
fullPage: true,
mode: isDevMode ? 'only-on-failure' : 'on',
},
trace: isDevMode ? 'on-first-retry' : 'on',
video: isDevMode ? 'on-first-retry' : 'on',
},
projects: PROJECTS_LIST[mode].map((project) => ({
name: project,
use: { ...devices[project] },
})),
});