-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathplaywright.config.js
More file actions
80 lines (69 loc) · 2.13 KB
/
playwright.config.js
File metadata and controls
80 lines (69 loc) · 2.13 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
const { defineConfig, devices } = require('@playwright/test');
/**
* Playwright configuration for Hugo documentation site e2e tests
* @see https://playwright.dev/docs/test-configuration
*/
module.exports = defineConfig({
// test directory
testDir: './tests/e2e',
// maximum time one test can run
timeout: 12 * 1000,
// run tests in parallel
fullyParallel: true,
// fail the build on CI if you accidentally left test.only in the source code
forbidOnly: !!process.env.CI,
// retry on CI only
retries: process.env.CI ? 2 : 0,
// reporter configuration
reporter: process.env.CI ? 'github' : 'list',
// shared settings for all projects
use: {
// base URL for tests - uses local Hugo server
baseURL: process.env.BASE_URL || 'http://localhost:1313',
// collect trace when retrying the failed test
trace: 'on-first-retry',
// screenshot on failure
screenshot: 'only-on-failure',
},
// configure projects for different browsers
projects: [
// Desktop browsers - run all tests except mobile-specific ones
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
testIgnore: '**/mobile/**',
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
testIgnore: '**/mobile/**',
},
{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
testIgnore: '**/mobile/**',
},
// Mobile browsers - only run mobile-specific tests
{
name: 'mobile-chrome',
use: { ...devices['Pixel 5'] },
testMatch: '**/mobile/**',
},
{
name: 'mobile-safari',
use: { ...devices['iPhone 12'] },
testMatch: '**/mobile/**',
},
],
// run local dev server before starting tests
webServer: {
command: process.env.CI
// CI: build static site with Pagefind index, then serve
? 'npm run build:dev && npx -y pagefind --site public && npx -y serve public -l 1313'
// Local: use live Hugo server (better for Mermaid controls initialization)
: 'npm run serve:with-search',
url: 'http://localhost:1313',
reuseExistingServer: !process.env.CI,
timeout: 120 * 1000,
},
});