-
Notifications
You must be signed in to change notification settings - Fork 0
/
playwright.config.mjs
79 lines (68 loc) · 2 KB
/
playwright.config.mjs
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
import { env } from 'node:process'
import { devices } from '@playwright/test'
import { dateToKebab } from './tests/utils/date.mjs'
import { isInvalidUrl } from './tests/utils/url.mjs'
const baseURL = env.PW_BASE_URL
if (isInvalidUrl(baseURL)) {
throw new Error(`PW_BASE_URL is not a valid URL: ${baseURL}`)
}
const filename = `${env.SERVER_HOST}-${dateToKebab(new Date())}`
/** @type {import('@playwright/test').PlaywrightTestConfig} */
export default {
// testIgnore: '**accessibility-axe**',
// Metadata can be used by test suites.
metadata: {
filename,
},
forbidOnly: !!env.CI,
retries: env.CI ? 2 : 0,
workers: env.CI ? 2 : undefined,
...(env.CI
? { webServer: {
// @todo: consider the following 👇, but consider the value of baseURL first (local Valet environment: no need for a WebServer)…
// command: env.CI ? 'vite preview --port 5173' : 'vite dev',
command: 'npm run preview',
url: baseURL,
ignoreHTTPSErrors: true,
reuseExistingServer: !env.CI,
} }
: null
),
// tons of interesting options: https://playwright.dev/docs/api/class-testoptions
use: {
baseURL,
ignoreHTTPSErrors: true,
trace: 'on-first-retry',
},
// preserveOutput: 'never',
// In CI environment, only run Chromium
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
// {
// name: 'firefox',
// use: { ...devices['Desktop Firefox'] },
// },
// {
// name: 'webkit',
// use: { ...devices['Desktop Safari'] },
// },
].filter(({ name }) => name == 'chromium' || !env.CI),
reporter: env.CI
? [['github'], ['html']]
: [
// ['dot'],
// ['list'],
['html', {
open: 'never',
outputFile: `${filename}.html`, // ignored…, index.html must have its subfolder, otherwise it erases other existing files
outputFolder: `tests/results/html`,
}],
['json', {
outputFile: `tests/results/${filename}.json`,
}],
]
,
}