@vitest/browser 4.0.0-beta.9 → 4.0.0
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/README.md +6 -14
- package/context.d.ts +86 -29
- package/context.js +3 -2
- package/dist/client/.vite/manifest.json +6 -6
- package/dist/client/__vitest__/assets/index-COTh6lXR.css +1 -0
- package/dist/client/__vitest__/assets/index-DOkKC3NI.js +53 -0
- package/dist/client/__vitest__/index.html +2 -2
- package/dist/client/__vitest_browser__/orchestrator-CFVVvVT1.js +313 -0
- package/dist/client/__vitest_browser__/tester-BNxij3za.js +2133 -0
- package/dist/client/__vitest_browser__/{utils-FY_Qin7d.js → utils-uxqdqUz8.js} +48 -24
- package/dist/client/orchestrator.html +2 -2
- package/dist/client/tester/tester.html +2 -2
- package/dist/client.js +1 -1
- package/dist/context.js +80 -19
- package/dist/expect-element.js +14 -14
- package/dist/index-BnLTaCRv.js +6 -0
- package/dist/index.d.ts +64 -165
- package/dist/index.js +572 -1431
- package/dist/{locators/index.d.ts → locators.d.ts} +27 -3
- package/dist/locators.js +1 -0
- package/dist/state.js +0 -1
- package/dist/types.d.ts +0 -1
- package/jest-dom.d.ts +5 -5
- package/matchers.d.ts +2 -2
- package/package.json +18 -54
- package/utils.d.ts +5 -5
- package/dist/client/__vitest__/assets/index-CBcuRGkf.js +0 -57
- package/dist/client/__vitest__/assets/index-KbpJLW--.css +0 -1
- package/dist/client/__vitest_browser__/orchestrator-C2rrmv36.js +0 -3198
- package/dist/client/__vitest_browser__/tester-mSVktQ7a.js +0 -3282
- package/dist/index-B7Hfmz-h.js +0 -1
- package/dist/locators/index.js +0 -1
- package/dist/locators/playwright.js +0 -1
- package/dist/locators/preview.js +0 -1
- package/dist/locators/webdriverio.js +0 -1
- package/dist/providers.js +0 -47
- package/dist/public-utils-Kx5DUGWa.js +0 -6
- package/dist/utils.js +0 -1
- package/dist/webdriver-AHRa6U3j.js +0 -517
- package/providers/playwright.d.ts +0 -97
- package/providers/webdriverio.d.ts +0 -35
- package/providers.d.ts +0 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UserEventClickOptions, UserEventClearOptions, UserEventHoverOptions, UserEventFillOptions, UserEventUploadOptions, UserEventDragAndDropOptions, UserEventSelectOptions, LocatorScreenshotOptions, LocatorByRoleOptions, LocatorOptions } from '
|
|
1
|
+
import { UserEventClickOptions, UserEventClearOptions, UserEventHoverOptions, UserEventFillOptions, UserEventUploadOptions, UserEventDragAndDropOptions, UserEventSelectOptions, LocatorScreenshotOptions, LocatorByRoleOptions, LocatorOptions } from 'vitest/browser';
|
|
2
2
|
|
|
3
3
|
type ClauseCombinator = '' | '>' | '+' | '~' | '>=';
|
|
4
4
|
type CSSFunctionArgument = CSSComplexSelector | number | string;
|
|
@@ -181,6 +181,23 @@ interface ByRoleOptions {
|
|
|
181
181
|
pressed?: boolean;
|
|
182
182
|
selected?: boolean;
|
|
183
183
|
}
|
|
184
|
+
declare function getByTestIdSelector(testIdAttributeName: string, testId: string | RegExp): string;
|
|
185
|
+
declare function getByLabelSelector(text: string | RegExp, options?: {
|
|
186
|
+
exact?: boolean;
|
|
187
|
+
}): string;
|
|
188
|
+
declare function getByAltTextSelector(text: string | RegExp, options?: {
|
|
189
|
+
exact?: boolean;
|
|
190
|
+
}): string;
|
|
191
|
+
declare function getByTitleSelector(text: string | RegExp, options?: {
|
|
192
|
+
exact?: boolean;
|
|
193
|
+
}): string;
|
|
194
|
+
declare function getByPlaceholderSelector(text: string | RegExp, options?: {
|
|
195
|
+
exact?: boolean;
|
|
196
|
+
}): string;
|
|
197
|
+
declare function getByTextSelector(text: string | RegExp, options?: {
|
|
198
|
+
exact?: boolean;
|
|
199
|
+
}): string;
|
|
200
|
+
declare function getByRoleSelector(role: string, options?: ByRoleOptions): string;
|
|
184
201
|
|
|
185
202
|
/**
|
|
186
203
|
* Copyright (c) Microsoft Corporation.
|
|
@@ -279,13 +296,19 @@ interface SelectorEngine {
|
|
|
279
296
|
queryAll: (root: SelectorRoot, selector: string | any) => Element[];
|
|
280
297
|
}
|
|
281
298
|
|
|
282
|
-
|
|
299
|
+
declare function convertElementToCssSelector(element: Element): string;
|
|
300
|
+
declare function processTimeoutOptions<T extends {
|
|
301
|
+
timeout?: number;
|
|
302
|
+
}>(options_?: T): T | undefined;
|
|
303
|
+
declare function getIframeScale(): number;
|
|
304
|
+
|
|
283
305
|
declare const selectorEngine: Ivya;
|
|
284
306
|
declare abstract class Locator {
|
|
285
307
|
abstract selector: string;
|
|
286
308
|
private _parsedSelector;
|
|
287
309
|
protected _container?: Element | undefined;
|
|
288
310
|
protected _pwSelector?: string | undefined;
|
|
311
|
+
constructor();
|
|
289
312
|
click(options?: UserEventClickOptions): Promise<void>;
|
|
290
313
|
dblClick(options?: UserEventClickOptions): Promise<void>;
|
|
291
314
|
tripleClick(options?: UserEventClickOptions): Promise<void>;
|
|
@@ -318,6 +341,7 @@ declare abstract class Locator {
|
|
|
318
341
|
query(): HTMLElement | SVGElement | null;
|
|
319
342
|
element(): HTMLElement | SVGElement;
|
|
320
343
|
elements(): (HTMLElement | SVGElement)[];
|
|
344
|
+
get length(): number;
|
|
321
345
|
all(): Locator[];
|
|
322
346
|
nth(index: number): Locator;
|
|
323
347
|
first(): Locator;
|
|
@@ -327,4 +351,4 @@ declare abstract class Locator {
|
|
|
327
351
|
protected triggerCommand<T>(command: string, ...args: any[]): Promise<T>;
|
|
328
352
|
}
|
|
329
353
|
|
|
330
|
-
export { Locator, selectorEngine };
|
|
354
|
+
export { Locator, convertElementToCssSelector, getByAltTextSelector, getByLabelSelector, getByPlaceholderSelector, getByRoleSelector, getByTestIdSelector, getByTextSelector, getByTitleSelector, getIframeScale, processTimeoutOptions, selectorEngine };
|
package/dist/locators.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{L as Locator,o as convertElementToCssSelector,r as getByAltTextSelector,t as getByLabelSelector,u as getByPlaceholderSelector,v as getByRoleSelector,w as getByTestIdSelector,x as getByTextSelector,y as getByTitleSelector,q as getIframeScale,p as processTimeoutOptions,s as selectorEngine}from"./index-BnLTaCRv.js";import"vitest/browser";import"vitest/internal/browser";
|
package/dist/state.js
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -32,7 +32,6 @@ export interface WebSocketBrowserHandlers {
|
|
|
32
32
|
registerMock: (sessionId: string, mock: MockedModuleSerialized) => void;
|
|
33
33
|
unregisterMock: (sessionId: string, id: string) => void;
|
|
34
34
|
clearMocks: (sessionId: string) => void;
|
|
35
|
-
// cdp
|
|
36
35
|
sendCdpEvent: (sessionId: string, event: string, payload?: Record<string, unknown>) => unknown;
|
|
37
36
|
trackCdpEvent: (sessionId: string, type: "on" | "once" | "off", event: string, listenerId: string) => void;
|
|
38
37
|
}
|
package/jest-dom.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export interface TestingLibraryMatchers<E, R> {
|
|
|
23
23
|
* This matcher calculates the intersection ratio between the element and the viewport, similar to the
|
|
24
24
|
* IntersectionObserver API.
|
|
25
25
|
*
|
|
26
|
-
* The element must be in the document and have visible dimensions. Elements with display: none or
|
|
26
|
+
* The element must be in the document and have visible dimensions. Elements with display: none or
|
|
27
27
|
* visibility: hidden are considered not in viewport.
|
|
28
28
|
* @example
|
|
29
29
|
* <div
|
|
@@ -34,7 +34,7 @@ export interface TestingLibraryMatchers<E, R> {
|
|
|
34
34
|
* </div>
|
|
35
35
|
*
|
|
36
36
|
* <div
|
|
37
|
-
* data-testid="hidden-element"
|
|
37
|
+
* data-testid="hidden-element"
|
|
38
38
|
* style="position: fixed; top: -100px; left: 10px; width: 50px; height: 50px;"
|
|
39
39
|
* >
|
|
40
40
|
* Hidden Element
|
|
@@ -49,13 +49,13 @@ export interface TestingLibraryMatchers<E, R> {
|
|
|
49
49
|
*
|
|
50
50
|
* // Check if any part of element is in viewport
|
|
51
51
|
* await expect.element(page.getByTestId('visible-element')).toBeInViewport()
|
|
52
|
-
*
|
|
52
|
+
*
|
|
53
53
|
* // Check if element is outside viewport
|
|
54
54
|
* await expect.element(page.getByTestId('hidden-element')).not.toBeInViewport()
|
|
55
|
-
*
|
|
55
|
+
*
|
|
56
56
|
* // Check if at least 50% of element is visible
|
|
57
57
|
* await expect.element(page.getByTestId('large-element')).toBeInViewport({ ratio: 0.5 })
|
|
58
|
-
*
|
|
58
|
+
*
|
|
59
59
|
* // Check if element is completely visible
|
|
60
60
|
* await expect.element(page.getByTestId('visible-element')).toBeInViewport({ ratio: 1 })
|
|
61
61
|
* @see https://vitest.dev/guide/browser/assertion-api#tobeinviewport
|
package/matchers.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Locator } from '
|
|
1
|
+
import type { Locator } from './context.js'
|
|
2
2
|
import type { TestingLibraryMatchers } from './jest-dom.js'
|
|
3
3
|
import type { Assertion, ExpectPollOptions } from 'vitest'
|
|
4
4
|
|
|
@@ -22,7 +22,7 @@ declare module 'vitest' {
|
|
|
22
22
|
* You can set default timeout via `expect.poll.timeout` option in the config.
|
|
23
23
|
* @see {@link https://vitest.dev/api/expect#poll}
|
|
24
24
|
*/
|
|
25
|
-
element: <T extends
|
|
25
|
+
element: <T extends HTMLElement | SVGElement | null | Locator>(element: T, options?: ExpectPollOptions) => PromisifyDomAssertion<Awaited<HTMLElement | SVGElement | null>>
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest/browser",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.0
|
|
4
|
+
"version": "4.0.0",
|
|
5
5
|
"description": "Browser running for Vitest",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
|
@@ -20,10 +20,6 @@
|
|
|
20
20
|
"types": "./dist/index.d.ts",
|
|
21
21
|
"default": "./dist/index.js"
|
|
22
22
|
},
|
|
23
|
-
"./providers": {
|
|
24
|
-
"types": "./providers.d.ts",
|
|
25
|
-
"default": "./dist/providers.js"
|
|
26
|
-
},
|
|
27
23
|
"./context": {
|
|
28
24
|
"types": "./context.d.ts",
|
|
29
25
|
"default": "./context.js"
|
|
@@ -35,23 +31,14 @@
|
|
|
35
31
|
"types": "./matchers.d.ts",
|
|
36
32
|
"default": "./dummy.js"
|
|
37
33
|
},
|
|
38
|
-
"./
|
|
39
|
-
"types": "./
|
|
40
|
-
"default": "./
|
|
41
|
-
},
|
|
42
|
-
"./providers/playwright": {
|
|
43
|
-
"types": "./providers/playwright.d.ts",
|
|
44
|
-
"default": "./dummy.js"
|
|
45
|
-
},
|
|
46
|
-
"./locator": {
|
|
47
|
-
"types": "./dist/locators/index.d.ts",
|
|
48
|
-
"default": "./dist/locators/index.js"
|
|
34
|
+
"./locators": {
|
|
35
|
+
"types": "./dist/locators.d.ts",
|
|
36
|
+
"default": "./dist/locators.js"
|
|
49
37
|
},
|
|
50
38
|
"./utils": {
|
|
51
|
-
"
|
|
52
|
-
"default": "./dist/utils.js"
|
|
39
|
+
"default": "./dummy.js"
|
|
53
40
|
},
|
|
54
|
-
"
|
|
41
|
+
"./package.json": "./package.json"
|
|
55
42
|
},
|
|
56
43
|
"main": "./dist/index.js",
|
|
57
44
|
"module": "./dist/index.js",
|
|
@@ -64,61 +51,38 @@
|
|
|
64
51
|
"providers"
|
|
65
52
|
],
|
|
66
53
|
"peerDependencies": {
|
|
67
|
-
"
|
|
68
|
-
"webdriverio": "^7.0.0 || ^8.0.0 || ^9.0.0",
|
|
69
|
-
"vitest": "4.0.0-beta.9"
|
|
70
|
-
},
|
|
71
|
-
"peerDependenciesMeta": {
|
|
72
|
-
"playwright": {
|
|
73
|
-
"optional": true
|
|
74
|
-
},
|
|
75
|
-
"safaridriver": {
|
|
76
|
-
"optional": true
|
|
77
|
-
},
|
|
78
|
-
"webdriverio": {
|
|
79
|
-
"optional": true
|
|
80
|
-
}
|
|
54
|
+
"vitest": "4.0.0"
|
|
81
55
|
},
|
|
82
56
|
"dependencies": {
|
|
83
|
-
"
|
|
84
|
-
"@testing-library/user-event": "^14.6.1",
|
|
85
|
-
"magic-string": "^0.30.17",
|
|
57
|
+
"magic-string": "^0.30.19",
|
|
86
58
|
"pixelmatch": "7.1.0",
|
|
87
59
|
"pngjs": "^7.0.0",
|
|
88
|
-
"sirv": "^3.0.
|
|
89
|
-
"tinyrainbow": "^
|
|
60
|
+
"sirv": "^3.0.2",
|
|
61
|
+
"tinyrainbow": "^3.0.3",
|
|
90
62
|
"ws": "^8.18.3",
|
|
91
|
-
"@vitest/
|
|
92
|
-
"@vitest/
|
|
63
|
+
"@vitest/mocker": "4.0.0",
|
|
64
|
+
"@vitest/utils": "4.0.0"
|
|
93
65
|
},
|
|
94
66
|
"devDependencies": {
|
|
67
|
+
"@testing-library/user-event": "^14.6.1",
|
|
95
68
|
"@types/pngjs": "^6.0.5",
|
|
96
69
|
"@types/ws": "^8.18.1",
|
|
97
|
-
"@wdio/protocols": "^9.16.2",
|
|
98
|
-
"@wdio/types": "^9.16.2",
|
|
99
70
|
"birpc": "^2.5.0",
|
|
100
71
|
"flatted": "^3.3.3",
|
|
101
72
|
"ivya": "^1.7.0",
|
|
102
|
-
"mime": "^4.0
|
|
73
|
+
"mime": "^4.1.0",
|
|
103
74
|
"pathe": "^2.0.3",
|
|
104
|
-
"
|
|
105
|
-
"
|
|
106
|
-
"playwright-core": "^1.54.1",
|
|
107
|
-
"safaridriver": "^1.0.0",
|
|
108
|
-
"webdriverio": "^9.18.4",
|
|
109
|
-
"@vitest/runner": "4.0.0-beta.9",
|
|
110
|
-
"@vitest/ui": "4.0.0-beta.9",
|
|
111
|
-
"@vitest/ws-client": "4.0.0-beta.9",
|
|
112
|
-
"vitest": "4.0.0-beta.9"
|
|
75
|
+
"@vitest/runner": "4.0.0",
|
|
76
|
+
"vitest": "4.0.0"
|
|
113
77
|
},
|
|
114
78
|
"scripts": {
|
|
115
79
|
"typecheck": "tsc -p ./src/client/tsconfig.json --noEmit",
|
|
116
80
|
"typecheck:why": "tsc -p ./src/client/tsconfig.json --noEmit --explainFiles > explainTypes.txt",
|
|
117
|
-
"build": "
|
|
81
|
+
"build": "premove dist && pnpm build:node && pnpm build:client",
|
|
118
82
|
"build:client": "vite build src/client",
|
|
119
83
|
"build:node": "rollup -c",
|
|
120
84
|
"dev:client": "vite build src/client --watch",
|
|
121
85
|
"dev:node": "rollup -c --watch --watch.include 'src/**'",
|
|
122
|
-
"dev": "
|
|
86
|
+
"dev": "premove dist && pnpm run --stream '/^dev:/'"
|
|
123
87
|
}
|
|
124
88
|
}
|
package/utils.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
// we cannot bundle it because vitest depend on the @vitest/browser and vice versa
|
|
3
|
-
// fortunately, the file is quite small
|
|
4
|
-
|
|
5
|
-
import { LocatorSelectors, Locator } from '@vitest/browser/context'
|
|
1
|
+
import { LocatorSelectors, Locator } from './context'
|
|
6
2
|
import { StringifyOptions } from 'vitest/internal/browser'
|
|
7
3
|
|
|
8
4
|
export type PrettyDOMOptions = Omit<StringifyOptions, 'maxLength'>
|
|
9
5
|
|
|
6
|
+
/** @deprecated use `import('vitest/browser').utils.getElementLocatorSelectors` instead */
|
|
10
7
|
export declare function getElementLocatorSelectors(element: Element): LocatorSelectors
|
|
8
|
+
/** @deprecated use `import('vitest/browser').utils.debug` instead */
|
|
11
9
|
export declare function debug(
|
|
12
10
|
el?: Element | Locator | null | (Element | Locator)[],
|
|
13
11
|
maxLength?: number,
|
|
14
12
|
options?: PrettyDOMOptions,
|
|
15
13
|
): void
|
|
14
|
+
/** @deprecated use `import('vitest/browser').utils.prettyDOM` instead */
|
|
16
15
|
export declare function prettyDOM(
|
|
17
16
|
dom?: Element | Locator | undefined | null,
|
|
18
17
|
maxLength?: number,
|
|
19
18
|
prettyFormatOptions?: PrettyDOMOptions,
|
|
20
19
|
): string
|
|
20
|
+
/** @deprecated use `import('vitest/browser').utils.getElementError` instead */
|
|
21
21
|
export declare function getElementError(selector: string, container?: Element): Error
|