@vitest/browser 3.1.0-beta.1 → 3.1.0-beta.2
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 +22 -0
- package/dist/client/.vite/manifest.json +1 -1
- package/dist/client/__vitest__/assets/{index-CsZqQx26.js → index-C3wX9Cb1.js} +1 -1
- package/dist/client/__vitest__/index.html +1 -1
- package/dist/client/__vitest_browser__/{tester-lo_P6U-u.js → tester-DRF-LncV.js} +1112 -324
- package/dist/client/tester/tester.html +1 -1
- package/dist/client.js +91 -105
- package/dist/context.js +374 -390
- package/dist/index-VvsEiykv.js +327 -0
- package/dist/index.js +1914 -1885
- package/dist/locators/index.d.ts +3 -0
- package/dist/locators/index.js +2 -2
- package/dist/locators/playwright.js +99 -108
- package/dist/locators/preview.js +71 -78
- package/dist/locators/webdriverio.js +135 -138
- package/dist/providers.js +34 -37
- package/dist/{public-utils-J4vwTaki.js → public-utils-4WiYB3_6.js} +38 -40
- package/dist/state.js +170 -1
- package/dist/utils.js +1 -1
- package/dist/webdriver-BP2w_ajA.js +271 -0
- package/package.json +8 -8
- package/dist/index-DrTP5i7N.js +0 -195
- package/dist/utils-VCysLhWp.js +0 -115
- package/dist/webdriver-C5-VI7VH.js +0 -275
package/dist/locators/index.d.ts
CHANGED
|
@@ -249,6 +249,9 @@ declare abstract class Locator {
|
|
|
249
249
|
getByTestId(testId: string | RegExp): Locator;
|
|
250
250
|
getByText(text: string | RegExp, options?: LocatorOptions): Locator;
|
|
251
251
|
getByTitle(title: string | RegExp, options?: LocatorOptions): Locator;
|
|
252
|
+
filter(filter: LocatorOptions): Locator;
|
|
253
|
+
and(locator: Locator): Locator;
|
|
254
|
+
or(locator: Locator): Locator;
|
|
252
255
|
query(): Element | null;
|
|
253
256
|
element(): Element;
|
|
254
257
|
elements(): Element[];
|
package/dist/locators/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '@vitest/browser/context';
|
|
2
|
-
import '../public-utils-
|
|
3
|
-
export { L as Locator, s as selectorEngine } from '../index-
|
|
2
|
+
import '../public-utils-4WiYB3_6.js';
|
|
3
|
+
export { L as Locator, s as selectorEngine } from '../index-VvsEiykv.js';
|
|
4
4
|
import 'vitest/utils';
|
|
@@ -1,123 +1,114 @@
|
|
|
1
1
|
import { page, server } from '@vitest/browser/context';
|
|
2
|
-
import { g as getByTitleSelector, a as getByTextSelector, b as getByPlaceholderSelector, c as getByAltTextSelector, d as getByTestIdSelector, e as getByRoleSelector, f as getByLabelSelector } from '../public-utils-
|
|
3
|
-
import { s as selectorEngine, L as Locator, g as getBrowserState } from '../index-
|
|
4
|
-
import { p as processTimeoutOptions, g as getIframeScale } from '../utils-VCysLhWp.js';
|
|
2
|
+
import { g as getByTitleSelector, a as getByTextSelector, b as getByPlaceholderSelector, c as getByAltTextSelector, d as getByTestIdSelector, e as getByRoleSelector, f as getByLabelSelector } from '../public-utils-4WiYB3_6.js';
|
|
3
|
+
import { s as selectorEngine, L as Locator, p as processTimeoutOptions, g as getBrowserState, a as getIframeScale } from '../index-VvsEiykv.js';
|
|
5
4
|
import 'vitest/utils';
|
|
6
5
|
|
|
7
6
|
page.extend({
|
|
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
|
-
element
|
|
33
|
-
);
|
|
34
|
-
}
|
|
7
|
+
getByLabelText(text, options) {
|
|
8
|
+
return new PlaywrightLocator(getByLabelSelector(text, options));
|
|
9
|
+
},
|
|
10
|
+
getByRole(role, options) {
|
|
11
|
+
return new PlaywrightLocator(getByRoleSelector(role, options));
|
|
12
|
+
},
|
|
13
|
+
getByTestId(testId) {
|
|
14
|
+
return new PlaywrightLocator(getByTestIdSelector(server.config.browser.locators.testIdAttribute, testId));
|
|
15
|
+
},
|
|
16
|
+
getByAltText(text, options) {
|
|
17
|
+
return new PlaywrightLocator(getByAltTextSelector(text, options));
|
|
18
|
+
},
|
|
19
|
+
getByPlaceholder(text, options) {
|
|
20
|
+
return new PlaywrightLocator(getByPlaceholderSelector(text, options));
|
|
21
|
+
},
|
|
22
|
+
getByText(text, options) {
|
|
23
|
+
return new PlaywrightLocator(getByTextSelector(text, options));
|
|
24
|
+
},
|
|
25
|
+
getByTitle(title, options) {
|
|
26
|
+
return new PlaywrightLocator(getByTitleSelector(title, options));
|
|
27
|
+
},
|
|
28
|
+
elementLocator(element) {
|
|
29
|
+
return new PlaywrightLocator(selectorEngine.generateSelectorSimple(element), element);
|
|
30
|
+
}
|
|
35
31
|
});
|
|
36
32
|
class PlaywrightLocator extends Locator {
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return new PlaywrightLocator(
|
|
76
|
-
selectorEngine.generateSelectorSimple(element),
|
|
77
|
-
element
|
|
78
|
-
);
|
|
79
|
-
}
|
|
33
|
+
constructor(selector, _container) {
|
|
34
|
+
super();
|
|
35
|
+
this.selector = selector;
|
|
36
|
+
this._container = _container;
|
|
37
|
+
}
|
|
38
|
+
click(options) {
|
|
39
|
+
return super.click(processTimeoutOptions(processClickOptions(options)));
|
|
40
|
+
}
|
|
41
|
+
dblClick(options) {
|
|
42
|
+
return super.dblClick(processTimeoutOptions(processClickOptions(options)));
|
|
43
|
+
}
|
|
44
|
+
tripleClick(options) {
|
|
45
|
+
return super.tripleClick(processTimeoutOptions(processClickOptions(options)));
|
|
46
|
+
}
|
|
47
|
+
selectOptions(value, options) {
|
|
48
|
+
return super.selectOptions(value, processTimeoutOptions(options));
|
|
49
|
+
}
|
|
50
|
+
clear(options) {
|
|
51
|
+
return super.clear(processTimeoutOptions(options));
|
|
52
|
+
}
|
|
53
|
+
hover(options) {
|
|
54
|
+
return super.hover(processTimeoutOptions(processHoverOptions(options)));
|
|
55
|
+
}
|
|
56
|
+
upload(files, options) {
|
|
57
|
+
return super.upload(files, processTimeoutOptions(options));
|
|
58
|
+
}
|
|
59
|
+
fill(text, options) {
|
|
60
|
+
return super.fill(text, processTimeoutOptions(options));
|
|
61
|
+
}
|
|
62
|
+
dropTo(target, options) {
|
|
63
|
+
return super.dropTo(target, processTimeoutOptions(processDragAndDropOptions(options)));
|
|
64
|
+
}
|
|
65
|
+
locator(selector) {
|
|
66
|
+
return new PlaywrightLocator(`${this.selector} >> ${selector}`, this._container);
|
|
67
|
+
}
|
|
68
|
+
elementLocator(element) {
|
|
69
|
+
return new PlaywrightLocator(selectorEngine.generateSelectorSimple(element), element);
|
|
70
|
+
}
|
|
80
71
|
}
|
|
81
72
|
function processDragAndDropOptions(options_) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
73
|
+
if (!options_ || !getBrowserState().config.browser.ui) {
|
|
74
|
+
return options_;
|
|
75
|
+
}
|
|
76
|
+
const options = options_;
|
|
77
|
+
if (options.sourcePosition) {
|
|
78
|
+
options.sourcePosition = processPlaywrightPosition(options.sourcePosition);
|
|
79
|
+
}
|
|
80
|
+
if (options.targetPosition) {
|
|
81
|
+
options.targetPosition = processPlaywrightPosition(options.targetPosition);
|
|
82
|
+
}
|
|
83
|
+
return options_;
|
|
93
84
|
}
|
|
94
85
|
function processHoverOptions(options_) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
86
|
+
if (!options_ || !getBrowserState().config.browser.ui) {
|
|
87
|
+
return options_;
|
|
88
|
+
}
|
|
89
|
+
const options = options_;
|
|
90
|
+
if (options.position) {
|
|
91
|
+
options.position = processPlaywrightPosition(options.position);
|
|
92
|
+
}
|
|
93
|
+
return options_;
|
|
103
94
|
}
|
|
104
95
|
function processClickOptions(options_) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
96
|
+
if (!options_ || !getBrowserState().config.browser.ui) {
|
|
97
|
+
return options_;
|
|
98
|
+
}
|
|
99
|
+
const options = options_;
|
|
100
|
+
if (options.position) {
|
|
101
|
+
options.position = processPlaywrightPosition(options.position);
|
|
102
|
+
}
|
|
103
|
+
return options;
|
|
113
104
|
}
|
|
114
105
|
function processPlaywrightPosition(position) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
106
|
+
const scale = getIframeScale();
|
|
107
|
+
if (position.x != null) {
|
|
108
|
+
position.x *= scale;
|
|
109
|
+
}
|
|
110
|
+
if (position.y != null) {
|
|
111
|
+
position.y *= scale;
|
|
112
|
+
}
|
|
113
|
+
return position;
|
|
123
114
|
}
|
package/dist/locators/preview.js
CHANGED
|
@@ -1,85 +1,78 @@
|
|
|
1
1
|
import { page, server, userEvent } from '@vitest/browser/context';
|
|
2
|
-
import { g as getByTitleSelector, a as getByTextSelector, b as getByPlaceholderSelector, c as getByAltTextSelector, d as getByTestIdSelector, e as getByRoleSelector, f as getByLabelSelector, h as getElementError } from '../public-utils-
|
|
3
|
-
import { c as convertElementToCssSelector } from '../
|
|
4
|
-
import { s as selectorEngine, L as Locator } from '../index-DrTP5i7N.js';
|
|
2
|
+
import { g as getByTitleSelector, a as getByTextSelector, b as getByPlaceholderSelector, c as getByAltTextSelector, d as getByTestIdSelector, e as getByRoleSelector, f as getByLabelSelector, h as getElementError } from '../public-utils-4WiYB3_6.js';
|
|
3
|
+
import { s as selectorEngine, L as Locator, c as convertElementToCssSelector } from '../index-VvsEiykv.js';
|
|
5
4
|
import 'vitest/utils';
|
|
6
5
|
|
|
7
6
|
page.extend({
|
|
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
|
-
element
|
|
33
|
-
);
|
|
34
|
-
}
|
|
7
|
+
getByLabelText(text, options) {
|
|
8
|
+
return new PreviewLocator(getByLabelSelector(text, options));
|
|
9
|
+
},
|
|
10
|
+
getByRole(role, options) {
|
|
11
|
+
return new PreviewLocator(getByRoleSelector(role, options));
|
|
12
|
+
},
|
|
13
|
+
getByTestId(testId) {
|
|
14
|
+
return new PreviewLocator(getByTestIdSelector(server.config.browser.locators.testIdAttribute, testId));
|
|
15
|
+
},
|
|
16
|
+
getByAltText(text, options) {
|
|
17
|
+
return new PreviewLocator(getByAltTextSelector(text, options));
|
|
18
|
+
},
|
|
19
|
+
getByPlaceholder(text, options) {
|
|
20
|
+
return new PreviewLocator(getByPlaceholderSelector(text, options));
|
|
21
|
+
},
|
|
22
|
+
getByText(text, options) {
|
|
23
|
+
return new PreviewLocator(getByTextSelector(text, options));
|
|
24
|
+
},
|
|
25
|
+
getByTitle(title, options) {
|
|
26
|
+
return new PreviewLocator(getByTitleSelector(title, options));
|
|
27
|
+
},
|
|
28
|
+
elementLocator(element) {
|
|
29
|
+
return new PreviewLocator(selectorEngine.generateSelectorSimple(element), element);
|
|
30
|
+
}
|
|
35
31
|
});
|
|
36
32
|
class PreviewLocator extends Locator {
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
element
|
|
83
|
-
);
|
|
84
|
-
}
|
|
33
|
+
constructor(_pwSelector, _container) {
|
|
34
|
+
super();
|
|
35
|
+
this._pwSelector = _pwSelector;
|
|
36
|
+
this._container = _container;
|
|
37
|
+
}
|
|
38
|
+
get selector() {
|
|
39
|
+
const selectors = this.elements().map((element) => convertElementToCssSelector(element));
|
|
40
|
+
if (!selectors.length) {
|
|
41
|
+
throw getElementError(this._pwSelector, this._container || document.body);
|
|
42
|
+
}
|
|
43
|
+
return selectors.join(", ");
|
|
44
|
+
}
|
|
45
|
+
click() {
|
|
46
|
+
return userEvent.click(this.element());
|
|
47
|
+
}
|
|
48
|
+
dblClick() {
|
|
49
|
+
return userEvent.dblClick(this.element());
|
|
50
|
+
}
|
|
51
|
+
tripleClick() {
|
|
52
|
+
return userEvent.tripleClick(this.element());
|
|
53
|
+
}
|
|
54
|
+
hover() {
|
|
55
|
+
return userEvent.hover(this.element());
|
|
56
|
+
}
|
|
57
|
+
unhover() {
|
|
58
|
+
return userEvent.unhover(this.element());
|
|
59
|
+
}
|
|
60
|
+
async fill(text) {
|
|
61
|
+
return userEvent.fill(this.element(), text);
|
|
62
|
+
}
|
|
63
|
+
async upload(file) {
|
|
64
|
+
return userEvent.upload(this.element(), file);
|
|
65
|
+
}
|
|
66
|
+
selectOptions(options_) {
|
|
67
|
+
return userEvent.selectOptions(this.element(), options_);
|
|
68
|
+
}
|
|
69
|
+
clear() {
|
|
70
|
+
return userEvent.clear(this.element());
|
|
71
|
+
}
|
|
72
|
+
locator(selector) {
|
|
73
|
+
return new PreviewLocator(`${this._pwSelector} >> ${selector}`, this._container);
|
|
74
|
+
}
|
|
75
|
+
elementLocator(element) {
|
|
76
|
+
return new PreviewLocator(selectorEngine.generateSelectorSimple(element), element);
|
|
77
|
+
}
|
|
85
78
|
}
|