forked from vitest-dev/vitest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.ts
More file actions
48 lines (41 loc) · 1.49 KB
/
settings.ts
File metadata and controls
48 lines (41 loc) · 1.49 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
import type { BrowserInstanceOption } from 'vitest/node'
import { playwright } from '@vitest/browser-playwright'
import { preview } from '@vitest/browser-preview'
import { webdriverio } from '@vitest/browser-webdriverio'
const providerName = (process.env.PROVIDER || 'playwright') as 'playwright' | 'webdriverio' | 'preview'
const wsEndpoint = process.env.BROWSER_WS_ENDPOINT === 'true' ? 'ws://127.0.0.1:6677/' : process.env.BROWSER_WS_ENDPOINT
export const providers = {
playwright: (options?: Parameters<typeof playwright>[0]) => playwright(wsEndpoint
? {
...options,
connectOptions: {
wsEndpoint,
exposeNetwork: '<loopback>',
},
}
: options),
preview,
webdriverio,
}
export const provider = providers[providerName]()
const playwrightInstances: BrowserInstanceOption[] = [
{ browser: 'chromium' },
{ browser: 'firefox' },
// hard to setup playwright webkit on some machines (e.g. ArchLinux)
// this allows skipping it locally by BROWSER_NO_WEBKIT=true
...(process.env.BROWSER_NO_WEBKIT ? [] : [{ browser: 'webkit' as const }]),
]
const webdriverioInstances: BrowserInstanceOption[] = [
{ browser: 'chrome' },
{ browser: 'firefox' },
]
export const instances: BrowserInstanceOption[] = process.env.BROWSER
? [
{
browser: process.env.BROWSER as any,
headless: process.env.BROWSER === 'safari' ? false : undefined,
},
]
: provider.name === 'playwright'
? playwrightInstances
: webdriverioInstances