@vitest/browser 2.0.0-beta.10 → 2.0.0-beta.11
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 +129 -12
- package/context.js +2 -0
- package/dist/client/.vite/manifest.json +8 -8
- package/dist/client/__vitest__/assets/index-BfnqOMHY.js +51 -0
- package/dist/client/__vitest__/assets/{index-BcFb8Rbc.css → index-qZYZB8Y3.css} +1 -1
- package/dist/client/__vitest__/index.html +16 -11
- package/dist/client/__vitest_browser__/{orchestrator-BCpOi5ot.js → orchestrator-DQ4hbmZ_.js} +141 -104
- package/dist/client/__vitest_browser__/{rpc-CImfI7bO.js → rpc-D6HtJ5Rb.js} +75 -55
- package/dist/client/__vitest_browser__/{tester-e70VCOgC.js → tester-IF8AbWCS.js} +256 -199
- package/dist/client/esm-client-injector.js +19 -18
- package/dist/client/orchestrator.html +2 -2
- package/dist/client/{tester.html → tester/tester.html} +12 -3
- package/dist/context.js +104 -16
- package/dist/index.d.ts +101 -5
- package/dist/index.js +1745 -270
- package/dist/providers.js +10 -6
- package/dist/state.js +1 -0
- package/dist/{webdriver-CXn0ag9T.js → webdriver-BRud6NtS.js} +22 -12
- package/package.json +9 -7
- package/providers/playwright.d.ts +27 -5
- package/dist/client/__vitest__/assets/index-BMAciMM5.js +0 -51
package/context.d.ts
CHANGED
|
@@ -19,13 +19,6 @@ export interface FsOptions {
|
|
|
19
19
|
flag?: string | number
|
|
20
20
|
}
|
|
21
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
22
|
export interface ScreenshotOptions {
|
|
30
23
|
element?: Element
|
|
31
24
|
/**
|
|
@@ -35,13 +28,20 @@ export interface ScreenshotOptions {
|
|
|
35
28
|
}
|
|
36
29
|
|
|
37
30
|
export interface BrowserCommands {
|
|
38
|
-
readFile: (
|
|
39
|
-
|
|
31
|
+
readFile: (
|
|
32
|
+
path: string,
|
|
33
|
+
options?: BufferEncoding | FsOptions
|
|
34
|
+
) => Promise<string>
|
|
35
|
+
writeFile: (
|
|
36
|
+
path: string,
|
|
37
|
+
content: string,
|
|
38
|
+
options?: BufferEncoding | (FsOptions & { mode?: number | string })
|
|
39
|
+
) => Promise<void>
|
|
40
40
|
removeFile: (path: string) => Promise<void>
|
|
41
|
-
sendKeys: (payload: SendKeysPayload) => Promise<void>
|
|
42
41
|
}
|
|
43
42
|
|
|
44
43
|
export interface UserEvent {
|
|
44
|
+
setup: () => UserEvent
|
|
45
45
|
/**
|
|
46
46
|
* Click on an element. Uses provider's API under the hood and supports all its options.
|
|
47
47
|
* @see {@link https://playwright.dev/docs/api/class-locator#locator-click} Playwright API
|
|
@@ -49,10 +49,127 @@ export interface UserEvent {
|
|
|
49
49
|
* @see {@link https://testing-library.com/docs/user-event/convenience/#click} testing-library API
|
|
50
50
|
*/
|
|
51
51
|
click: (element: Element, options?: UserEventClickOptions) => Promise<void>
|
|
52
|
+
/**
|
|
53
|
+
* Triggers a double click event on an element. Uses provider's API under the hood.
|
|
54
|
+
* @see {@link https://playwright.dev/docs/api/class-locator#locator-dblclick} Playwright API
|
|
55
|
+
* @see {@link https://webdriver.io/docs/api/element/doubleClick/} WebdriverIO API
|
|
56
|
+
* @see {@link https://testing-library.com/docs/user-event/convenience/#dblClick} testing-library API
|
|
57
|
+
*/
|
|
58
|
+
dblClick: (element: Element, options?: UserEventDoubleClickOptions) => Promise<void>
|
|
59
|
+
/**
|
|
60
|
+
* Choose one or more values from a select element. Uses provider's API under the hood.
|
|
61
|
+
* If select doesn't have `multiple` attribute, only the first value will be selected.
|
|
62
|
+
* @example
|
|
63
|
+
* await userEvent.selectOptions(select, 'Option 1')
|
|
64
|
+
* expect(select).toHaveValue('option-1')
|
|
65
|
+
*
|
|
66
|
+
* await userEvent.selectOptions(select, 'option-1')
|
|
67
|
+
* expect(select).toHaveValue('option-1')
|
|
68
|
+
*
|
|
69
|
+
* await userEvent.selectOptions(select, [
|
|
70
|
+
* screen.getByRole('option', { name: 'Option 1' }),
|
|
71
|
+
* screen.getByRole('option', { name: 'Option 2' }),
|
|
72
|
+
* ])
|
|
73
|
+
* expect(select).toHaveValue(['option-1', 'option-2'])
|
|
74
|
+
* @see {@link https://playwright.dev/docs/api/class-locator#locator-select-option} Playwright API
|
|
75
|
+
* @see {@link https://webdriver.io/docs/api/element/doubleClick/} WebdriverIO API
|
|
76
|
+
* @see {@link https://testing-library.com/docs/user-event/utility/#-selectoptions-deselectoptions} testing-library API
|
|
77
|
+
*/
|
|
78
|
+
selectOptions: (
|
|
79
|
+
element: Element,
|
|
80
|
+
values: HTMLElement | HTMLElement[] | string | string[],
|
|
81
|
+
options?: UserEventSelectOptions,
|
|
82
|
+
) => Promise<void>
|
|
83
|
+
/**
|
|
84
|
+
* Type text on the keyboard. If any input is focused, it will receive the text,
|
|
85
|
+
* otherwise it will be typed on the document. Uses provider's API under the hood.
|
|
86
|
+
* **Supports** [user-event `keyboard` syntax](https://testing-library.com/docs/user-event/keyboard) (e.g., `{Shift}`) even with `playwright` and `webdriverio` providers.
|
|
87
|
+
* @example
|
|
88
|
+
* await userEvent.keyboard('foo') // translates to: f, o, o
|
|
89
|
+
* await userEvent.keyboard('{{a[[') // translates to: {, a, [
|
|
90
|
+
* await userEvent.keyboard('{Shift}{f}{o}{o}') // translates to: Shift, f, o, o
|
|
91
|
+
* @see {@link https://playwright.dev/docs/api/class-locator#locator-press} Playwright API
|
|
92
|
+
* @see {@link https://webdriver.io/docs/api/browser/keys} WebdriverIO API
|
|
93
|
+
* @see {@link https://testing-library.com/docs/user-event/keyboard} testing-library API
|
|
94
|
+
*/
|
|
95
|
+
keyboard: (text: string) => Promise<void>
|
|
96
|
+
/**
|
|
97
|
+
* Types text into an element. Uses provider's API under the hood.
|
|
98
|
+
* **Supports** [user-event `keyboard` syntax](https://testing-library.com/docs/user-event/keyboard) (e.g., `{Shift}`) even with `playwright` and `webdriverio` providers.
|
|
99
|
+
* @example
|
|
100
|
+
* await userEvent.type(input, 'foo') // translates to: f, o, o
|
|
101
|
+
* await userEvent.type(input, '{{a[[') // translates to: {, a, [
|
|
102
|
+
* await userEvent.type(input, '{Shift}{f}{o}{o}') // translates to: Shift, f, o, o
|
|
103
|
+
* @see {@link https://playwright.dev/docs/api/class-locator#locator-press} Playwright API
|
|
104
|
+
* @see {@link https://webdriver.io/docs/api/browser/action#key-input-source} WebdriverIO API
|
|
105
|
+
* @see {@link https://testing-library.com/docs/user-event/utility/#type} testing-library API
|
|
106
|
+
*/
|
|
107
|
+
type: (element: Element, text: string, options?: UserEventTypeOptions) => Promise<void>
|
|
108
|
+
/**
|
|
109
|
+
* Removes all text from an element. Uses provider's API under the hood.
|
|
110
|
+
* @see {@link https://playwright.dev/docs/api/class-locator#locator-clear} Playwright API
|
|
111
|
+
* @see {@link https://webdriver.io/docs/api/element/clearValue} WebdriverIO API
|
|
112
|
+
* @see {@link https://testing-library.com/docs/user-event/utility/#clear} testing-library API
|
|
113
|
+
*/
|
|
114
|
+
clear: (element: Element) => Promise<void>
|
|
115
|
+
/**
|
|
116
|
+
* Sends a `Tab` key event. Uses provider's API under the hood.
|
|
117
|
+
* @see {@link https://playwright.dev/docs/api/class-locator#locator-press} Playwright API
|
|
118
|
+
* @see {@link https://webdriver.io/docs/api/element/keys} WebdriverIO API
|
|
119
|
+
* @see {@link https://testing-library.com/docs/user-event/convenience/#tab} testing-library API
|
|
120
|
+
*/
|
|
121
|
+
tab: (options?: UserEventTabOptions) => Promise<void>
|
|
122
|
+
/**
|
|
123
|
+
* Hovers over an element. Uses provider's API under the hood.
|
|
124
|
+
* @see {@link https://playwright.dev/docs/api/class-locator#locator-hover} Playwright API
|
|
125
|
+
* @see {@link https://webdriver.io/docs/api/element/moveTo/} WebdriverIO API
|
|
126
|
+
* @see {@link https://testing-library.com/docs/user-event/convenience/#hover} testing-library API
|
|
127
|
+
*/
|
|
128
|
+
hover: (element: Element, options?: UserEventHoverOptions) => Promise<void>
|
|
129
|
+
/**
|
|
130
|
+
* Moves cursor position to the body element. Uses provider's API under the hood.
|
|
131
|
+
* By default, the cursor position is in the center (in webdriverio) or in some visible place (in playwright)
|
|
132
|
+
* of the body element, so if the current element is already there, this will have no effect.
|
|
133
|
+
* @see {@link https://playwright.dev/docs/api/class-locator#locator-hover} Playwright API
|
|
134
|
+
* @see {@link https://webdriver.io/docs/api/element/moveTo/} WebdriverIO API
|
|
135
|
+
* @see {@link https://testing-library.com/docs/user-event/convenience/#hover} testing-library API
|
|
136
|
+
*/
|
|
137
|
+
unhover: (element: Element, options?: UserEventHoverOptions) => Promise<void>
|
|
138
|
+
/**
|
|
139
|
+
* Fills an input element with text. This will remove any existing text in the input before typing the new text.
|
|
140
|
+
* Uses provider's API under the hood.
|
|
141
|
+
* This API is faster than using `userEvent.type` or `userEvent.keyboard`, but it **doesn't support** [user-event `keyboard` syntax](https://testing-library.com/docs/user-event/keyboard) (e.g., `{Shift}`).
|
|
142
|
+
* @example
|
|
143
|
+
* await userEvent.fill(input, 'foo') // translates to: f, o, o
|
|
144
|
+
* await userEvent.fill(input, '{{a[[') // translates to: {, {, a, [, [
|
|
145
|
+
* await userEvent.fill(input, '{Shift}') // translates to: {, S, h, i, f, t, }
|
|
146
|
+
* @see {@link https://playwright.dev/docs/api/class-locator#locator-fill} Playwright API
|
|
147
|
+
* @see {@link https://webdriver.io/docs/api/element/setValue} WebdriverIO API
|
|
148
|
+
* @see {@link https://testing-library.com/docs/user-event/utility/#type} testing-library API
|
|
149
|
+
*/
|
|
150
|
+
fill: (element: Element, text: string, options?: UserEventFillOptions) => Promise<void>
|
|
151
|
+
/**
|
|
152
|
+
* Drags a source element on top of the target element. This API is not supported by "preview" provider.
|
|
153
|
+
* @see {@link https://playwright.dev/docs/api/class-frame#frame-drag-and-drop} Playwright API
|
|
154
|
+
* @see {@link https://webdriver.io/docs/api/element/dragAndDrop/} WebdriverIO API
|
|
155
|
+
*/
|
|
156
|
+
dragAndDrop: (source: Element, target: Element, options?: UserEventDragAndDropOptions) => Promise<void>
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface UserEventFillOptions {}
|
|
160
|
+
export interface UserEventHoverOptions {}
|
|
161
|
+
export interface UserEventSelectOptions {}
|
|
162
|
+
export interface UserEventClickOptions {}
|
|
163
|
+
export interface UserEventDoubleClickOptions {}
|
|
164
|
+
export interface UserEventDragAndDropOptions {}
|
|
165
|
+
|
|
166
|
+
export interface UserEventTabOptions {
|
|
167
|
+
shift?: boolean
|
|
52
168
|
}
|
|
53
169
|
|
|
54
|
-
export interface
|
|
55
|
-
|
|
170
|
+
export interface UserEventTypeOptions {
|
|
171
|
+
skipClick?: boolean
|
|
172
|
+
skipAutoClose?: boolean
|
|
56
173
|
}
|
|
57
174
|
|
|
58
175
|
type Platform =
|
package/context.js
ADDED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
{
|
|
2
|
-
"_rpc-
|
|
3
|
-
"file": "__vitest_browser__/rpc-
|
|
2
|
+
"_rpc-D6HtJ5Rb.js": {
|
|
3
|
+
"file": "__vitest_browser__/rpc-D6HtJ5Rb.js",
|
|
4
4
|
"name": "rpc"
|
|
5
5
|
},
|
|
6
6
|
"orchestrator.html": {
|
|
7
|
-
"file": "__vitest_browser__/orchestrator-
|
|
7
|
+
"file": "__vitest_browser__/orchestrator-DQ4hbmZ_.js",
|
|
8
8
|
"name": "orchestrator",
|
|
9
9
|
"src": "orchestrator.html",
|
|
10
10
|
"isEntry": true,
|
|
11
11
|
"imports": [
|
|
12
|
-
"_rpc-
|
|
12
|
+
"_rpc-D6HtJ5Rb.js"
|
|
13
13
|
]
|
|
14
14
|
},
|
|
15
|
-
"tester.html": {
|
|
16
|
-
"file": "__vitest_browser__/tester-
|
|
15
|
+
"tester/tester.html": {
|
|
16
|
+
"file": "__vitest_browser__/tester-IF8AbWCS.js",
|
|
17
17
|
"name": "tester",
|
|
18
|
-
"src": "tester.html",
|
|
18
|
+
"src": "tester/tester.html",
|
|
19
19
|
"isEntry": true,
|
|
20
20
|
"imports": [
|
|
21
|
-
"_rpc-
|
|
21
|
+
"_rpc-D6HtJ5Rb.js"
|
|
22
22
|
]
|
|
23
23
|
}
|
|
24
24
|
}
|