-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathplaywright.config.js
More file actions
101 lines (94 loc) · 2.81 KB
/
playwright.config.js
File metadata and controls
101 lines (94 loc) · 2.81 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
98
99
100
101
import { defineConfig, devices } from '@playwright/test'
process.env.NODE_ENV ??= 'test'
export default defineConfig({
testDir: './test-e2e',
testMatch: /(.+\.)?(test|spec)\.[jt]s/,
// Run tests in files in parallel
fullyParallel: process.env.CI == null,
workers: process.env.CI == null ? undefined : 1,
// Retry on CI only
retries: (process.env.CI != null) ? 2 : 0,
timeout: process.env.CI != null ? 30_000 : undefined,
// Reporter to use. See https://playwright.dev/docs/test-reporters
// reporter: 'html', // Uncomment to generate HTML report
use: {
// Base URL to use in actions like `await page.goto('/')`.
baseURL: 'http://localhost:3000',
// Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer
trace: 'on-first-retry',
// 'allow' serviceWorkers is the default, but we want to be explicit
serviceWorkers: 'allow'
},
globalSetup: './test-e2e/fixtures/global-setup.ts',
globalTeardown: './test-e2e/fixtures/global-teardown.ts',
projects: [
{
name: 'chromium',
use: {
...devices['Desktop Chrome']
}
},
{
name: 'firefox',
use: {
...devices['Desktop Firefox'],
launchOptions: {
firefoxUserPrefs: {
// if we redirect too quickly, too many times, Firefox deletes all
// site application data (e.g. the service worker)
'privacy.bounceTrackingProtection.mode': 0
}
}
}
},
{
// NOTE: github CI isn't running these tests successfully, but they work locally.
name: 'safari',
use: {
...devices['Desktop Safari']
}
},
/**
* Test a deployed site such as inbrowser.dev with `BASE_URL="https://inbrowser.dev" npm run test:deployed`
* or inbrowser.link with `BASE_URL="https://inbrowser.link" npm run test:deployed`
*/
{
name: 'deployed',
use: {
...devices['Desktop Chrome'],
...devices['Desktop Firefox'],
baseURL: process.env.BASE_URL
}
},
{
/**
* Test the site with service workers disabled
*/
name: 'no-service-worker',
testMatch: /test-e2e\/no-service-worker\.test\.ts/,
use: {
...devices['Desktop Firefox'],
contextOptions: {
serviceWorkers: 'block'
},
launchOptions: {
firefoxUserPrefs: {
'dom.serviceWorkers.enabled': false
}
},
/**
*
* @param {object} param0
* @param {import('@playwright/test').Page} param0.page
*/
beforeEach: async ({ page }) => {
await page.addInitScript(() => {
Object.defineProperty(navigator, 'serviceWorker', {
get: () => undefined
})
})
}
}
}
]
})