-
Notifications
You must be signed in to change notification settings - Fork 8
/
playwright.config.js
115 lines (108 loc) · 3.4 KB
/
playwright.config.js
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import { defineConfig, devices } from '@playwright/test'
export default defineConfig({
testDir: './test-e2e',
testMatch: /(.+\.)?(test|spec)\.[jt]s/,
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: Boolean(process.env.CI),
/* Retry on CI only */
retries: (process.env.CI != null) ? 2 : 0,
/* 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:3333',
/* 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/global-setup.ts',
globalTeardown: './test-e2e/global-teardown.ts',
projects: [
{
name: 'chromium',
use: {
...devices['Desktop Chrome']
}
},
{
name: 'firefox',
use: {
...devices['Desktop Firefox']
}
},
/**
* 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. You need to `import {testNoServiceWorker as test, expect} from './fixtures/config-test-fixtures.js'` to use this project.
* Anything needing a service worker will be skipped when this project is ran.
*/
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
}
},
beforeEach: async ({ page }) => {
await page.addInitScript(() => {
Object.defineProperty(navigator, 'serviceWorker', {
get: () => undefined
})
})
}
}
}
],
// TODO: disable webservers when testing `deployed` project
webServer: [
{
command: 'node test-e2e/reverse-proxy.js',
timeout: 5 * 1000,
env: {
BACKEND_PORT: '3000',
PROXY_PORT: '3333'
},
stdout: process.env.CI ? undefined : 'pipe',
stderr: process.env.CI ? undefined : 'pipe'
},
{
command: 'node test-e2e/ipfs-gateway.js',
timeout: 5 * 1000,
env: {
PROXY_PORT: '3334',
GATEWAY_PORT: '8088'
},
stdout: process.env.CI ? undefined : 'pipe',
stderr: process.env.CI ? undefined : 'pipe'
},
{
// need to use built assets due to service worker loading issue.
// TODO: figure out how to get things working with npm run start
command: 'npm run build && npx http-server --silent -p 3000 dist',
port: 3000,
timeout: 10 * 1000,
reuseExistingServer: !process.env.CI,
stdout: process.env.CI ? undefined : 'pipe',
stderr: process.env.CI ? undefined : 'pipe'
}
]
})