@vitest/browser 1.6.0 → 2.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/context.d.ts +127 -0
- package/dist/client/.vite/manifest.json +24 -0
- package/dist/client/__vitest__/assets/index-BMAciMM5.js +51 -0
- package/dist/client/__vitest__/assets/index-BcFb8Rbc.css +1 -0
- package/dist/client/__vitest__/index.html +2 -2
- package/dist/client/__vitest_browser__/orchestrator-BCpOi5ot.js +301 -0
- package/dist/client/__vitest_browser__/{rpc-slP7oy1q.js → rpc-CImfI7bO.js} +288 -392
- package/dist/client/__vitest_browser__/{tester-RmfypyZ0.js → tester-e70VCOgC.js} +351 -44
- package/dist/client/esm-client-injector.js +14 -28
- package/dist/client/{index.html → orchestrator.html} +8 -7
- package/dist/client/tester.html +4 -3
- package/dist/context.js +87 -0
- package/dist/index.d.ts +6 -3
- package/dist/index.js +406 -268
- package/dist/providers.js +12 -112
- package/dist/webdriver-CXn0ag9T.js +170 -0
- package/package.json +23 -13
- package/providers/playwright.d.ts +14 -2
- package/providers/webdriverio.d.ts +4 -0
- package/providers.d.ts +5 -5
- package/dist/client/__vitest__/assets/index-TpLatVz2.js +0 -35
- package/dist/client/__vitest__/assets/index-fUmMsp0O.css +0 -1
- package/dist/client/__vitest_browser__/main-v2hiOVax.js +0 -102
package/context.d.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { ResolvedConfig } from 'vitest'
|
|
2
|
+
|
|
3
|
+
export type BufferEncoding =
|
|
4
|
+
| 'ascii'
|
|
5
|
+
| 'utf8'
|
|
6
|
+
| 'utf-8'
|
|
7
|
+
| 'utf16le'
|
|
8
|
+
| 'utf-16le'
|
|
9
|
+
| 'ucs2'
|
|
10
|
+
| 'ucs-2'
|
|
11
|
+
| 'base64'
|
|
12
|
+
| 'base64url'
|
|
13
|
+
| 'latin1'
|
|
14
|
+
| 'binary'
|
|
15
|
+
| 'hex'
|
|
16
|
+
|
|
17
|
+
export interface FsOptions {
|
|
18
|
+
encoding?: BufferEncoding
|
|
19
|
+
flag?: string | number
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface TypePayload { type: string }
|
|
23
|
+
export interface PressPayload { press: string }
|
|
24
|
+
export interface DownPayload { down: string }
|
|
25
|
+
export interface UpPayload { up: string }
|
|
26
|
+
|
|
27
|
+
export type SendKeysPayload = TypePayload | PressPayload | DownPayload | UpPayload
|
|
28
|
+
|
|
29
|
+
export interface ScreenshotOptions {
|
|
30
|
+
element?: Element
|
|
31
|
+
/**
|
|
32
|
+
* Path relative to the `screenshotDirectory` in the test config.
|
|
33
|
+
*/
|
|
34
|
+
path?: string
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface BrowserCommands {
|
|
38
|
+
readFile: (path: string, options?: BufferEncoding | FsOptions) => Promise<string>
|
|
39
|
+
writeFile: (path: string, content: string, options?: BufferEncoding | FsOptions & { mode?: number | string }) => Promise<void>
|
|
40
|
+
removeFile: (path: string) => Promise<void>
|
|
41
|
+
sendKeys: (payload: SendKeysPayload) => Promise<void>
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface UserEvent {
|
|
45
|
+
/**
|
|
46
|
+
* Click on an element. Uses provider's API under the hood and supports all its options.
|
|
47
|
+
* @see {@link https://playwright.dev/docs/api/class-locator#locator-click} Playwright API
|
|
48
|
+
* @see {@link https://webdriver.io/docs/api/element/click/} WebdriverIO API
|
|
49
|
+
* @see {@link https://testing-library.com/docs/user-event/convenience/#click} testing-library API
|
|
50
|
+
*/
|
|
51
|
+
click: (element: Element, options?: UserEventClickOptions) => Promise<void>
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface UserEventClickOptions {
|
|
55
|
+
[key: string]: any
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
type Platform =
|
|
59
|
+
| 'aix'
|
|
60
|
+
| 'android'
|
|
61
|
+
| 'darwin'
|
|
62
|
+
| 'freebsd'
|
|
63
|
+
| 'haiku'
|
|
64
|
+
| 'linux'
|
|
65
|
+
| 'openbsd'
|
|
66
|
+
| 'sunos'
|
|
67
|
+
| 'win32'
|
|
68
|
+
| 'cygwin'
|
|
69
|
+
| 'netbsd'
|
|
70
|
+
|
|
71
|
+
export const server: {
|
|
72
|
+
/**
|
|
73
|
+
* Platform the Vitest server is running on.
|
|
74
|
+
* The same as calling `process.platform` on the server.
|
|
75
|
+
*/
|
|
76
|
+
platform: Platform
|
|
77
|
+
/**
|
|
78
|
+
* Runtime version of the Vitest server.
|
|
79
|
+
* The same as calling `process.version` on the server.
|
|
80
|
+
*/
|
|
81
|
+
version: string
|
|
82
|
+
/**
|
|
83
|
+
* Name of the browser provider.
|
|
84
|
+
*/
|
|
85
|
+
provider: string
|
|
86
|
+
/**
|
|
87
|
+
* Name of the current browser.
|
|
88
|
+
*/
|
|
89
|
+
browser: string
|
|
90
|
+
/**
|
|
91
|
+
* Available commands for the browser.
|
|
92
|
+
* @see {@link https://vitest.dev/guide/browser#commands}
|
|
93
|
+
*/
|
|
94
|
+
commands: BrowserCommands
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Handler for user interactions. The support is provided by the browser provider (`playwright` or `webdriverio`).
|
|
99
|
+
* If used with `preview` provider, fallbacks to simulated events via `@testing-library/user-event`.
|
|
100
|
+
* @experimental
|
|
101
|
+
*/
|
|
102
|
+
export const userEvent: UserEvent
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Available commands for the browser.
|
|
106
|
+
* A shortcut to `server.commands`.
|
|
107
|
+
* @see {@link https://vitest.dev/guide/browser#commands}
|
|
108
|
+
*/
|
|
109
|
+
export const commands: BrowserCommands
|
|
110
|
+
|
|
111
|
+
export interface BrowserPage {
|
|
112
|
+
/**
|
|
113
|
+
* Serialized test config.
|
|
114
|
+
*/
|
|
115
|
+
config: ResolvedConfig
|
|
116
|
+
/**
|
|
117
|
+
* Change the size of iframe's viewport.
|
|
118
|
+
*/
|
|
119
|
+
viewport: (width: number, height: number) => Promise<void>
|
|
120
|
+
/**
|
|
121
|
+
* Make a screenshot of the test iframe or a specific element.
|
|
122
|
+
* @returns Path to the screenshot file.
|
|
123
|
+
*/
|
|
124
|
+
screenshot: (options?: ScreenshotOptions) => Promise<string>
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export const page: BrowserPage
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_rpc-CImfI7bO.js": {
|
|
3
|
+
"file": "__vitest_browser__/rpc-CImfI7bO.js",
|
|
4
|
+
"name": "rpc"
|
|
5
|
+
},
|
|
6
|
+
"orchestrator.html": {
|
|
7
|
+
"file": "__vitest_browser__/orchestrator-BCpOi5ot.js",
|
|
8
|
+
"name": "orchestrator",
|
|
9
|
+
"src": "orchestrator.html",
|
|
10
|
+
"isEntry": true,
|
|
11
|
+
"imports": [
|
|
12
|
+
"_rpc-CImfI7bO.js"
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
"tester.html": {
|
|
16
|
+
"file": "__vitest_browser__/tester-e70VCOgC.js",
|
|
17
|
+
"name": "tester",
|
|
18
|
+
"src": "tester.html",
|
|
19
|
+
"isEntry": true,
|
|
20
|
+
"imports": [
|
|
21
|
+
"_rpc-CImfI7bO.js"
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
}
|