-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
53 lines (50 loc) · 1.4 KB
/
playwright.config.ts
File metadata and controls
53 lines (50 loc) · 1.4 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
import { defineConfig, devices } from '@playwright/test'
const env = process.env
const isCI = env?.CI === 'true'
const includeWebKit = env?.PLAYWRIGHT_INCLUDE_WEBKIT === 'true'
const HOST = env?.PLAYWRIGHT_HOST ?? '127.0.0.1'
const PORT = Number(env?.PLAYWRIGHT_PORT ?? 4174)
const baseURL = env?.PLAYWRIGHT_BASE_URL ?? `http://${HOST}:${PORT}`
const webServerMode = env?.PLAYWRIGHT_WEB_SERVER_MODE ?? 'dev'
const usePreviewServer = webServerMode === 'preview'
const webServerCommand = usePreviewServer
? `npx http-server dist -a ${HOST} -p ${PORT} -c-1`
: `npx http-server . -a ${HOST} -p ${PORT} -c-1`
const webServerReadyUrl = usePreviewServer
? `${baseURL}/index.html`
: `${baseURL}/src/index.html`
const projects = [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
]
if (isCI || includeWebKit) {
projects.push({
name: 'webkit',
use: { ...devices['Desktop Safari'] },
})
}
export default defineConfig({
testDir: 'playwright',
timeout: isCI ? 120_000 : 20_000,
retries: isCI ? 1 : 0,
workers: isCI ? 1 : undefined,
expect: {
timeout: isCI ? 90_000 : 15_000,
},
reporter: isCI ? 'github' : 'list',
use: {
baseURL,
trace: 'on-first-retry',
screenshot: 'only-on-failure',
video: 'retain-on-failure',
},
webServer: {
command: webServerCommand,
url: webServerReadyUrl,
reuseExistingServer: !isCI,
timeout: 120_000,
},
projects,
})