@vitest/browser 3.0.9 → 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.
@@ -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[];
@@ -1,4 +1,4 @@
1
1
  import '@vitest/browser/context';
2
- import '../public-utils-J4vwTaki.js';
3
- export { L as Locator, s as selectorEngine } from '../index-DrTP5i7N.js';
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-J4vwTaki.js';
3
- import { s as selectorEngine, L as Locator, g as getBrowserState } from '../index-DrTP5i7N.js';
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
- getByLabelText(text, options) {
9
- return new PlaywrightLocator(getByLabelSelector(text, options));
10
- },
11
- getByRole(role, options) {
12
- return new PlaywrightLocator(getByRoleSelector(role, options));
13
- },
14
- getByTestId(testId) {
15
- return new PlaywrightLocator(getByTestIdSelector(server.config.browser.locators.testIdAttribute, testId));
16
- },
17
- getByAltText(text, options) {
18
- return new PlaywrightLocator(getByAltTextSelector(text, options));
19
- },
20
- getByPlaceholder(text, options) {
21
- return new PlaywrightLocator(getByPlaceholderSelector(text, options));
22
- },
23
- getByText(text, options) {
24
- return new PlaywrightLocator(getByTextSelector(text, options));
25
- },
26
- getByTitle(title, options) {
27
- return new PlaywrightLocator(getByTitleSelector(title, options));
28
- },
29
- elementLocator(element) {
30
- return new PlaywrightLocator(
31
- selectorEngine.generateSelectorSimple(element),
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
- constructor(selector, _container) {
38
- super();
39
- this.selector = selector;
40
- this._container = _container;
41
- }
42
- click(options) {
43
- return super.click(processTimeoutOptions(processClickOptions(options)));
44
- }
45
- dblClick(options) {
46
- return super.dblClick(processTimeoutOptions(processClickOptions(options)));
47
- }
48
- tripleClick(options) {
49
- return super.tripleClick(processTimeoutOptions(processClickOptions(options)));
50
- }
51
- selectOptions(value, options) {
52
- return super.selectOptions(value, processTimeoutOptions(options));
53
- }
54
- clear(options) {
55
- return super.clear(processTimeoutOptions(options));
56
- }
57
- hover(options) {
58
- return super.hover(processTimeoutOptions(processHoverOptions(options)));
59
- }
60
- upload(files, options) {
61
- return super.upload(files, processTimeoutOptions(options));
62
- }
63
- fill(text, options) {
64
- return super.fill(text, processTimeoutOptions(options));
65
- }
66
- dropTo(target, options) {
67
- return super.dropTo(target, processTimeoutOptions(
68
- processDragAndDropOptions(options)
69
- ));
70
- }
71
- locator(selector) {
72
- return new PlaywrightLocator(`${this.selector} >> ${selector}`, this._container);
73
- }
74
- elementLocator(element) {
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
- if (!options_ || !getBrowserState().config.browser.ui) {
83
- return options_;
84
- }
85
- const options = options_;
86
- if (options.sourcePosition) {
87
- options.sourcePosition = processPlaywrightPosition(options.sourcePosition);
88
- }
89
- if (options.targetPosition) {
90
- options.targetPosition = processPlaywrightPosition(options.targetPosition);
91
- }
92
- return options_;
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
- if (!options_ || !getBrowserState().config.browser.ui) {
96
- return options_;
97
- }
98
- const options = options_;
99
- if (options.position) {
100
- options.position = processPlaywrightPosition(options.position);
101
- }
102
- return options_;
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
- if (!options_ || !getBrowserState().config.browser.ui) {
106
- return options_;
107
- }
108
- const options = options_;
109
- if (options.position) {
110
- options.position = processPlaywrightPosition(options.position);
111
- }
112
- return options;
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
- const scale = getIframeScale();
116
- if (position.x != null) {
117
- position.x *= scale;
118
- }
119
- if (position.y != null) {
120
- position.y *= scale;
121
- }
122
- return position;
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
  }
@@ -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-J4vwTaki.js';
3
- import { c as convertElementToCssSelector } from '../utils-VCysLhWp.js';
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
- getByLabelText(text, options) {
9
- return new PreviewLocator(getByLabelSelector(text, options));
10
- },
11
- getByRole(role, options) {
12
- return new PreviewLocator(getByRoleSelector(role, options));
13
- },
14
- getByTestId(testId) {
15
- return new PreviewLocator(getByTestIdSelector(server.config.browser.locators.testIdAttribute, testId));
16
- },
17
- getByAltText(text, options) {
18
- return new PreviewLocator(getByAltTextSelector(text, options));
19
- },
20
- getByPlaceholder(text, options) {
21
- return new PreviewLocator(getByPlaceholderSelector(text, options));
22
- },
23
- getByText(text, options) {
24
- return new PreviewLocator(getByTextSelector(text, options));
25
- },
26
- getByTitle(title, options) {
27
- return new PreviewLocator(getByTitleSelector(title, options));
28
- },
29
- elementLocator(element) {
30
- return new PreviewLocator(
31
- selectorEngine.generateSelectorSimple(element),
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
- constructor(_pwSelector, _container) {
38
- super();
39
- this._pwSelector = _pwSelector;
40
- this._container = _container;
41
- }
42
- get selector() {
43
- const selectors = this.elements().map((element) => convertElementToCssSelector(element));
44
- if (!selectors.length) {
45
- throw getElementError(this._pwSelector, this._container || document.body);
46
- }
47
- return selectors.join(", ");
48
- }
49
- click() {
50
- return userEvent.click(this.element());
51
- }
52
- dblClick() {
53
- return userEvent.dblClick(this.element());
54
- }
55
- tripleClick() {
56
- return userEvent.tripleClick(this.element());
57
- }
58
- hover() {
59
- return userEvent.hover(this.element());
60
- }
61
- unhover() {
62
- return userEvent.unhover(this.element());
63
- }
64
- async fill(text) {
65
- return userEvent.fill(this.element(), text);
66
- }
67
- async upload(file) {
68
- return userEvent.upload(this.element(), file);
69
- }
70
- selectOptions(options_) {
71
- return userEvent.selectOptions(this.element(), options_);
72
- }
73
- clear() {
74
- return userEvent.clear(this.element());
75
- }
76
- locator(selector) {
77
- return new PreviewLocator(`${this._pwSelector} >> ${selector}`, this._container);
78
- }
79
- elementLocator(element) {
80
- return new PreviewLocator(
81
- selectorEngine.generateSelectorSimple(element),
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
  }