forked from sanity-io/sanity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
playwright.config.ts
44 lines (38 loc) · 1.39 KB
/
playwright.config.ts
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
import {defineConfig, type PlaywrightTestConfig} from '@playwright/test'
import {createPlaywrightConfig} from '@sanity/test'
import {loadEnvFiles} from './scripts/utils/loadEnvFiles'
import {readBoolEnv, readEnv} from './test/e2e/helpers/envVars'
loadEnvFiles()
const CI = readBoolEnv('CI', false)
const HEADLESS = readBoolEnv('HEADLESS', true)
/**
* Excludes the GitHub reporter until https://github.com/microsoft/playwright/issues/19817 is resolved, since it creates a lot of noise in our PRs.
* @param reporters - The reporters config to exclude the github reporter from
*/
function excludeGithub(reporters: PlaywrightTestConfig['reporter']) {
if (Array.isArray(reporters)) {
return reporters.filter((reporterDescription) => reporterDescription[0] !== 'github')
}
return reporters === 'github' ? undefined : reporters
}
const playwrightConfig = createPlaywrightConfig({
projectId: readEnv('SANITY_E2E_PROJECT_ID'),
token: readEnv('SANITY_E2E_SESSION_TOKEN'),
playwrightOptions(config): PlaywrightTestConfig {
return {
...config,
reporter: excludeGithub(config.reporter),
use: {
...config.use,
baseURL: 'http://localhost:3339',
headless: HEADLESS,
},
webServer: {
...config.webServer,
command: CI ? 'pnpm e2e:start' : 'pnpm e2e:dev',
port: 3339,
},
}
},
})
export default defineConfig(playwrightConfig)