-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
browser.ts
72 lines (62 loc) · 2.27 KB
/
browser.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
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
export const BROWSER_FAMILY = ['chromium', 'firefox', 'webkit']
type BrowserName = 'electron' | 'chrome' | 'chromium' | 'firefox' | 'webkit' | string
export type BrowserChannel = 'stable' | 'canary' | 'beta' | 'dev' | 'nightly' | string
export type BrowserFamily = typeof BROWSER_FAMILY[number]
export type BrowserValidatorResult = {
// whether or not the browser is supported by Cypress
isSupported: boolean
// optional warning message that will be shown in the GUI
warningMessage?: string
}
export type BrowserValidator = (browser: FoundBrowser, platform: NodeJS.Platform) => BrowserValidatorResult
/**
* Represents a typical browser to try to detect and turn into a `FoundBrowser`.
*/
export type Browser = {
/**
* Short browser name.
*/
name: BrowserName
/**
* The underlying engine for this browser.
*/
family: BrowserFamily
/**
* The release channel of the browser.
*/
channel: BrowserChannel
/**
* Human-readable browser name.
*/
displayName: string
/** RegExp to use to extract version from something like "Google Chrome 58.0.3029.110" */
versionRegex: RegExp
/** If set, this is the base path that will be used for setting userDataDir. Useful for creating profiles in snap confinement. */
profilePath?: string
/** A single binary name or array of binary names for this browser. Not used on Windows. */
binary: string | string[]
/** optional warning that will be shown in the GUI */
warning?: string
/** if set, the majorVersion must be >= this to be run in Cypress */
minSupportedVersion?: number
/** if set, is called to determine if found browser is supported by Cypress */
validator?: BrowserValidator
}
/**
* Represents a real browser that exists on the user's system.
*/
export type FoundBrowser = Omit<Browser, 'versionRegex' | 'binary' | 'validator'> & {
path: string
version: string
majorVersion?: string | null
/** is this a user-supplied browser? */
custom?: boolean
unsupportedVersion?: boolean
disabled?: boolean
}
/**
* Partial browser object, returned by an OS-specific launcher helper.
*/
export type DetectedBrowser = Pick<FoundBrowser, 'name' | 'path' | 'version'>
export const BROWSER_STATUS = ['closed', 'opening', 'open'] as const
export type BrowserStatus = typeof BROWSER_STATUS[number]