@vitest/browser 4.1.0-beta.5 → 4.1.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 +4 -4
- package/context.d.ts +27 -5
- package/dist/client/.vite/manifest.json +1 -1
- package/dist/client/__vitest__/assets/{index-vKQ25zpc.js → index-Di71CKDo.js} +26 -26
- package/dist/client/__vitest__/index.html +1 -1
- package/dist/client/__vitest_browser__/{tester-C0ZOZX6s.js → tester-K5NNxh1O.js} +75 -31
- package/dist/client/tester/tester.html +1 -1
- package/dist/client.js +19 -12
- package/dist/context.js +32 -2
- package/dist/expect-element.js +23 -23
- package/dist/index-5Pe7X7sp.js +7 -0
- package/dist/index.d.ts +19 -1
- package/dist/index.js +5628 -16
- package/dist/locators.d.ts +2 -1
- package/dist/locators.js +1 -1
- package/package.json +14 -8
- package/dist/index-BvKPfXh9.js +0 -7
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
})();
|
|
24
24
|
</script>
|
|
25
25
|
<!-- !LOAD_METADATA! -->
|
|
26
|
-
<script type="module" src="./assets/index-
|
|
26
|
+
<script type="module" src="./assets/index-Di71CKDo.js"></script>
|
|
27
27
|
<link rel="stylesheet" href="./assets/index-Da0hb3oU.css">
|
|
28
28
|
</head>
|
|
29
29
|
<body>
|
|
@@ -66,8 +66,7 @@ const object = "object";
|
|
|
66
66
|
const noop = (_, value) => value;
|
|
67
67
|
const primitives = (value) => value instanceof Primitive ? Primitive(value) : value;
|
|
68
68
|
const Primitives = (_, value) => typeof value === primitive ? new Primitive(value) : value;
|
|
69
|
-
const
|
|
70
|
-
const lazy = [];
|
|
69
|
+
const resolver = (input, lazy, parsed, $) => (output) => {
|
|
71
70
|
for (let ke = keys(output), { length } = ke, y = 0; y < length; y++) {
|
|
72
71
|
const k = ke[y];
|
|
73
72
|
const value = output[k];
|
|
@@ -76,24 +75,29 @@ const revive = (input, parsed, output, $) => {
|
|
|
76
75
|
if (typeof tmp === object && !parsed.has(tmp)) {
|
|
77
76
|
parsed.add(tmp);
|
|
78
77
|
output[k] = ignore;
|
|
79
|
-
lazy.push({
|
|
78
|
+
lazy.push({ o: output, k, r: tmp });
|
|
80
79
|
} else
|
|
81
80
|
output[k] = $.call(output, k, tmp);
|
|
82
81
|
} else if (output[k] !== ignore)
|
|
83
82
|
output[k] = $.call(output, k, value);
|
|
84
83
|
}
|
|
85
|
-
for (let { length } = lazy, i = 0; i < length; i++) {
|
|
86
|
-
const { k, a } = lazy[i];
|
|
87
|
-
output[k] = $.call(output, k, revive.apply(null, a));
|
|
88
|
-
}
|
|
89
84
|
return output;
|
|
90
85
|
};
|
|
91
86
|
const parse = (text, reviver) => {
|
|
92
87
|
const input = $parse(text, Primitives).map(primitives);
|
|
93
|
-
const value = input[0];
|
|
94
88
|
const $ = noop;
|
|
95
|
-
|
|
96
|
-
|
|
89
|
+
let value = input[0];
|
|
90
|
+
if (typeof value === object && value) {
|
|
91
|
+
const lazy = [];
|
|
92
|
+
const revive = resolver(input, lazy, /* @__PURE__ */ new Set(), $);
|
|
93
|
+
value = revive(value);
|
|
94
|
+
let i = 0;
|
|
95
|
+
while (i < lazy.length) {
|
|
96
|
+
const { o, k, r } = lazy[i++];
|
|
97
|
+
o[k] = $.call(o, k, revive(r));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return $.call({ "": value }, "", value);
|
|
97
101
|
};
|
|
98
102
|
function showPopupWarning(name, value, defaultValue) {
|
|
99
103
|
return (...params) => {
|
|
@@ -839,16 +843,13 @@ function createBrowserRunner(runnerClass, mocker, state, coverageModule) {
|
|
|
839
843
|
await ((_a = super.onBeforeTryTask) == null ? void 0 : _a.call(this, ...args));
|
|
840
844
|
const trace = this.config.browser.trace;
|
|
841
845
|
const test = args[0];
|
|
842
|
-
if (trace === "off") {
|
|
843
|
-
return;
|
|
844
|
-
}
|
|
845
846
|
const { retry, repeats } = args[1];
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
if (trace === "on-first-retry" && retry !== 1) {
|
|
847
|
+
const shouldTrace = trace !== "off" && !(trace === "on-all-retries" && retry === 0) && !(trace === "on-first-retry" && retry !== 1);
|
|
848
|
+
if (!shouldTrace) {
|
|
849
|
+
getBrowserState().activeTraceTaskIds.delete(test.id);
|
|
850
850
|
return;
|
|
851
851
|
}
|
|
852
|
+
getBrowserState().activeTraceTaskIds.add(test.id);
|
|
852
853
|
let title = getTestName(test);
|
|
853
854
|
if (retry) {
|
|
854
855
|
title += ` (retry x${retry})`;
|
|
@@ -863,16 +864,14 @@ function createBrowserRunner(runnerClass, mocker, state, coverageModule) {
|
|
|
863
864
|
);
|
|
864
865
|
};
|
|
865
866
|
onAfterRetryTask = async (test, { retry, repeats }) => {
|
|
866
|
-
|
|
867
|
-
if (
|
|
868
|
-
return;
|
|
869
|
-
}
|
|
870
|
-
if (trace === "on-all-retries" && retry === 0) {
|
|
871
|
-
return;
|
|
872
|
-
}
|
|
873
|
-
if (trace === "on-first-retry" && retry !== 1) {
|
|
867
|
+
var _a, _b, _c;
|
|
868
|
+
if (!getBrowserState().activeTraceTaskIds.has(test.id)) {
|
|
874
869
|
return;
|
|
875
870
|
}
|
|
871
|
+
await this.commands.triggerCommand("__vitest_markTrace", [{
|
|
872
|
+
name: `onAfterRetryTask [${(_a = test.result) == null ? void 0 : _a.state}]`,
|
|
873
|
+
stack: (_c = (_b = test.result) == null ? void 0 : _b.errors) == null ? void 0 : _c[0].stack
|
|
874
|
+
}]);
|
|
876
875
|
const name = getTraceName(test, retry, repeats);
|
|
877
876
|
if (!this.traces.has(test.id)) {
|
|
878
877
|
this.traces.set(test.id, []);
|
|
@@ -1989,6 +1988,22 @@ function createModuleMockerInterceptor() {
|
|
|
1989
1988
|
function rpc() {
|
|
1990
1989
|
return getWorkerState().rpc;
|
|
1991
1990
|
}
|
|
1991
|
+
const ACTION_TRACE_COMMANDS = /* @__PURE__ */ new Set([
|
|
1992
|
+
"__vitest_click",
|
|
1993
|
+
"__vitest_dblClick",
|
|
1994
|
+
"__vitest_tripleClick",
|
|
1995
|
+
"__vitest_wheel",
|
|
1996
|
+
"__vitest_type",
|
|
1997
|
+
"__vitest_clear",
|
|
1998
|
+
"__vitest_fill",
|
|
1999
|
+
"__vitest_selectOptions",
|
|
2000
|
+
"__vitest_dragAndDrop",
|
|
2001
|
+
"__vitest_hover",
|
|
2002
|
+
"__vitest_upload",
|
|
2003
|
+
"__vitest_tab",
|
|
2004
|
+
"__vitest_keyboard",
|
|
2005
|
+
"__vitest_takeScreenshot"
|
|
2006
|
+
]);
|
|
1992
2007
|
class CommandsManager {
|
|
1993
2008
|
_listeners = [];
|
|
1994
2009
|
onCommand(listener) {
|
|
@@ -2001,6 +2016,9 @@ class CommandsManager {
|
|
|
2001
2016
|
const { sessionId, traces: traces2 } = getBrowserState();
|
|
2002
2017
|
const filepath = state.filepath || ((_b = (_a = state.current) == null ? void 0 : _a.file) == null ? void 0 : _b.filepath);
|
|
2003
2018
|
args = args.filter((arg) => arg !== void 0);
|
|
2019
|
+
const actionTraceGroupName = ACTION_TRACE_COMMANDS.has(command) ? command : void 0;
|
|
2020
|
+
const currentTest = getWorkerState().current;
|
|
2021
|
+
const shouldMarkTrace = actionTraceGroupName && !!currentTest && getBrowserState().activeTraceTaskIds.has(currentTest.id);
|
|
2004
2022
|
if (this._listeners.length) {
|
|
2005
2023
|
await Promise.all(this._listeners.map((listener) => listener(command, args)));
|
|
2006
2024
|
}
|
|
@@ -2012,16 +2030,41 @@ class CommandsManager {
|
|
|
2012
2030
|
"code.file.path": filepath
|
|
2013
2031
|
}
|
|
2014
2032
|
},
|
|
2015
|
-
|
|
2033
|
+
async () => {
|
|
2016
2034
|
var _a2;
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2035
|
+
if (shouldMarkTrace) {
|
|
2036
|
+
await rpc2.triggerCommand(
|
|
2037
|
+
sessionId,
|
|
2038
|
+
"__vitest_groupTraceStart",
|
|
2039
|
+
filepath,
|
|
2040
|
+
[{
|
|
2041
|
+
name: actionTraceGroupName,
|
|
2042
|
+
stack: clientError.stack
|
|
2043
|
+
}]
|
|
2044
|
+
);
|
|
2045
|
+
}
|
|
2046
|
+
try {
|
|
2047
|
+
return await rpc2.triggerCommand(sessionId, command, filepath, args);
|
|
2048
|
+
} catch (err) {
|
|
2049
|
+
clientError.message = err.message;
|
|
2050
|
+
clientError.name = err.name;
|
|
2051
|
+
clientError.stack = (_a2 = clientError.stack) == null ? void 0 : _a2.replace(clientError.message, err.message);
|
|
2052
|
+
throw clientError;
|
|
2053
|
+
} finally {
|
|
2054
|
+
if (shouldMarkTrace) {
|
|
2055
|
+
await rpc2.triggerCommand(
|
|
2056
|
+
sessionId,
|
|
2057
|
+
"__vitest_groupTraceEnd",
|
|
2058
|
+
filepath,
|
|
2059
|
+
[]
|
|
2060
|
+
);
|
|
2061
|
+
}
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2022
2064
|
);
|
|
2023
2065
|
}
|
|
2024
2066
|
}
|
|
2067
|
+
globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
|
|
2025
2068
|
getBrowserState().provider;
|
|
2026
2069
|
const debugVar = getConfig().env.VITEST_BROWSER_DEBUG;
|
|
2027
2070
|
const debug = debugVar && debugVar !== "false" ? (...args) => {
|
|
@@ -2098,6 +2141,7 @@ const url = new URL(location.href);
|
|
|
2098
2141
|
const iframeId = url.searchParams.get("iframeId");
|
|
2099
2142
|
const commands = new CommandsManager();
|
|
2100
2143
|
getBrowserState().commands = commands;
|
|
2144
|
+
getBrowserState().activeTraceTaskIds = /* @__PURE__ */ new Set();
|
|
2101
2145
|
getBrowserState().iframeId = iframeId;
|
|
2102
2146
|
let contextSwitched = false;
|
|
2103
2147
|
async function prepareTestEnvironment(options) {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="icon" href="{__VITEST_FAVICON__}" type="image/svg+xml">
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>Vitest Browser Tester</title>
|
|
8
|
-
<script type="module" crossorigin src="/__vitest_browser__/tester-
|
|
8
|
+
<script type="module" crossorigin src="/__vitest_browser__/tester-K5NNxh1O.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/__vitest_browser__/utils-C2ISqq1C.js">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
package/dist/client.js
CHANGED
|
@@ -226,8 +226,7 @@ const Primitives = (_, value) => (
|
|
|
226
226
|
typeof value === primitive ? new Primitive(value) : value
|
|
227
227
|
);
|
|
228
228
|
|
|
229
|
-
const
|
|
230
|
-
const lazy = [];
|
|
229
|
+
const resolver = (input, lazy, parsed, $) => output => {
|
|
231
230
|
for (let ke = keys(output), {length} = ke, y = 0; y < length; y++) {
|
|
232
231
|
const k = ke[y];
|
|
233
232
|
const value = output[k];
|
|
@@ -236,7 +235,7 @@ const revive = (input, parsed, output, $) => {
|
|
|
236
235
|
if (typeof tmp === object && !parsed.has(tmp)) {
|
|
237
236
|
parsed.add(tmp);
|
|
238
237
|
output[k] = ignore;
|
|
239
|
-
lazy.push({
|
|
238
|
+
lazy.push({ o: output, k, r: tmp });
|
|
240
239
|
}
|
|
241
240
|
else
|
|
242
241
|
output[k] = $.call(output, k, tmp);
|
|
@@ -244,10 +243,6 @@ const revive = (input, parsed, output, $) => {
|
|
|
244
243
|
else if (output[k] !== ignore)
|
|
245
244
|
output[k] = $.call(output, k, value);
|
|
246
245
|
}
|
|
247
|
-
for (let {length} = lazy, i = 0; i < length; i++) {
|
|
248
|
-
const {k, a} = lazy[i];
|
|
249
|
-
output[k] = $.call(output, k, revive.apply(null, a));
|
|
250
|
-
}
|
|
251
246
|
return output;
|
|
252
247
|
};
|
|
253
248
|
|
|
@@ -265,12 +260,24 @@ const set = (known, input, value) => {
|
|
|
265
260
|
*/
|
|
266
261
|
const parse = (text, reviver) => {
|
|
267
262
|
const input = $parse(text, Primitives).map(primitives);
|
|
268
|
-
const value = input[0];
|
|
269
263
|
const $ = reviver || noop;
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
264
|
+
|
|
265
|
+
let value = input[0];
|
|
266
|
+
|
|
267
|
+
if (typeof value === object && value) {
|
|
268
|
+
const lazy = [];
|
|
269
|
+
const revive = resolver(input, lazy, new Set, $);
|
|
270
|
+
value = revive(value);
|
|
271
|
+
|
|
272
|
+
let i = 0;
|
|
273
|
+
while (i < lazy.length) {
|
|
274
|
+
// it could be a lazy.shift() but that's costly
|
|
275
|
+
const {o, k, r} = lazy[i++];
|
|
276
|
+
o[k] = $.call(o, k, revive(r));
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return $.call({'': value}, '', value);
|
|
274
281
|
};
|
|
275
282
|
|
|
276
283
|
/**
|
package/dist/context.js
CHANGED
|
@@ -23,9 +23,11 @@ function ensureAwaited(promise) {
|
|
|
23
23
|
return (promiseResult ||= promise(sourceError)).then(onFulfilled, onRejected);
|
|
24
24
|
},
|
|
25
25
|
catch(onRejected) {
|
|
26
|
+
awaited = true;
|
|
26
27
|
return (promiseResult ||= promise(sourceError)).catch(onRejected);
|
|
27
28
|
},
|
|
28
29
|
finally(onFinally) {
|
|
30
|
+
awaited = true;
|
|
29
31
|
return (promiseResult ||= promise(sourceError)).finally(onFinally);
|
|
30
32
|
},
|
|
31
33
|
[Symbol.toStringTag]: "Promise"
|
|
@@ -118,7 +120,7 @@ function getParent(el) {
|
|
|
118
120
|
}
|
|
119
121
|
return parent;
|
|
120
122
|
}
|
|
121
|
-
const now = Date.now;
|
|
123
|
+
const now = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
|
|
122
124
|
function processTimeoutOptions(options_) {
|
|
123
125
|
if (options_ && options_.timeout != null) {
|
|
124
126
|
return options_;
|
|
@@ -140,7 +142,7 @@ function processTimeoutOptions(options_) {
|
|
|
140
142
|
options_ = options_ || {};
|
|
141
143
|
const currentTime = now();
|
|
142
144
|
const endTime = startTime + timeout;
|
|
143
|
-
const remainingTime = endTime - currentTime;
|
|
145
|
+
const remainingTime = Math.floor(endTime - currentTime);
|
|
144
146
|
if (remainingTime <= 0) {
|
|
145
147
|
return options_;
|
|
146
148
|
}
|
|
@@ -461,6 +463,34 @@ const page = {
|
|
|
461
463
|
/** TODO */
|
|
462
464
|
)], error));
|
|
463
465
|
},
|
|
466
|
+
mark(name, bodyOrOptions, options) {
|
|
467
|
+
const currentTest = getWorkerState().current;
|
|
468
|
+
const hasActiveTrace = !!currentTest && getBrowserState().activeTraceTaskIds.has(currentTest.id);
|
|
469
|
+
if (typeof bodyOrOptions === "function") {
|
|
470
|
+
return ensureAwaited(async (error) => {
|
|
471
|
+
if (hasActiveTrace) {
|
|
472
|
+
await triggerCommand("__vitest_groupTraceStart", [{
|
|
473
|
+
name,
|
|
474
|
+
stack: options?.stack ?? error?.stack
|
|
475
|
+
}], error);
|
|
476
|
+
}
|
|
477
|
+
try {
|
|
478
|
+
return await bodyOrOptions();
|
|
479
|
+
} finally {
|
|
480
|
+
if (hasActiveTrace) {
|
|
481
|
+
await triggerCommand("__vitest_groupTraceEnd", [], error);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
if (!hasActiveTrace) {
|
|
487
|
+
return Promise.resolve();
|
|
488
|
+
}
|
|
489
|
+
return ensureAwaited((error) => triggerCommand("__vitest_markTrace", [{
|
|
490
|
+
name,
|
|
491
|
+
stack: bodyOrOptions?.stack ?? error?.stack
|
|
492
|
+
}], error));
|
|
493
|
+
},
|
|
464
494
|
getByRole() {
|
|
465
495
|
throw new Error(`Method "getByRole" is not supported by the "${provider}" provider.`);
|
|
466
496
|
},
|
package/dist/expect-element.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import{recordArtifact,expect,chai}from"vitest";import{getType}from"vitest/internal/browser";import{k as
|
|
2
|
-
`)}function
|
|
3
|
-
`)}}class
|
|
4
|
-
`)}}}function
|
|
5
|
-
`)}}function
|
|
6
|
-
`)}}}function
|
|
7
|
-
`)}}}function
|
|
8
|
-
`)}}const
|
|
9
|
-
`)}}}function
|
|
10
|
-
`)}}}function
|
|
11
|
-
`)}}))}async function
|
|
12
|
-
`)}}}function
|
|
13
|
-
`)}}}function
|
|
14
|
-
`)}}}function
|
|
1
|
+
import{recordArtifact as e,expect as t,chai as n}from"vitest";import{getType as r}from"vitest/internal/browser";import{k as i,L as a,g as o,a as s,b as c,c as l,e as u,i as ee,d as te,f as ne,h as re,j as ie,l as d,m as f,p as ae,n as oe}from"./index-5Pe7X7sp.js";import{server as p}from"vitest/browser";function se(){return[...i]}function ce(e,t,n){return e instanceof a&&(e=e.query()),e==null?null:m(e,t,n)}function m(e,t,n){e instanceof a&&(e=e.element());let r=e?.ownerDocument?.defaultView||window;if(e instanceof r.HTMLElement||e instanceof r.SVGElement)return e;throw new me(e,t,n)}function le(e,t,n){e instanceof a&&(e=e.element());let r=e.ownerDocument?.defaultView||window;if(e instanceof r.Node)return e;throw new he(e,t,n)}function h(e,t,n,r,i,a){return[`${t}\n`,`${n}:\n${e.utils.EXPECTED_COLOR(g(_(e,r),2))}`,`${i}:\n${e.utils.RECEIVED_COLOR(g(_(e,a),2))}`].join(`
|
|
2
|
+
`)}function g(e,t){return ue(fe(e),t)}function ue(e,t){return e.replace(/^(?!\s*$)/gm,` `.repeat(t))}function de(e){let t=e.match(/^[ \t]*(?=\S)/gm);return t?t.reduce((e,t)=>Math.min(e,t.length),1/0):0}function fe(e){let t=de(e);if(t===0)return e;let n=RegExp(`^[ \\t]{${t}}`,`gm`);return e.replace(n,``)}function _(e,t){return typeof t==`string`?t:e.utils.stringify(t)}function pe(e,{wordConnector:t=`, `,lastWordConnector:n=` and `}={}){return[e.slice(0,-1).join(t),e.at(-1)].join(e.length>1?n:``)}class v extends Error{constructor(e,t,n,r){super(),Error.captureStackTrace&&Error.captureStackTrace(this,n);let i=``;try{i=r.utils.printWithType(`Received`,t,r.utils.printReceived)}catch{}this.message=[r.utils.matcherHint(`${r.isNot?`.not`:``}.${n.name}`,`received`,``),``,`${r.utils.RECEIVED_COLOR(`received`)} value must ${e} or a Locator that returns ${e}.`,i].join(`
|
|
3
|
+
`)}}class me extends v{constructor(e,t,n){super(`an HTMLElement or an SVGElement`,e,t,n)}}class he extends v{constructor(e,t,n){super(`a Node`,e,t,n)}}function y(e){return e instanceof HTMLFormElement?`FORM`:e.tagName.toUpperCase()}function b(e){return y(e)===`INPUT`}function x(e){if(e)switch(y(e)){case`INPUT`:return _e(e);case`SELECT`:return ge(e);default:return e.value??ye(e)}}function ge({multiple:e,options:t}){let n=[...t].filter(e=>e.selected);if(e)return[...n].map(e=>e.value);if(n.length!==0)return n[0].value}function _e(e){switch(e.type){case`number`:return e.value===``?null:Number(e.value);case`checkbox`:return e.checked;default:return e.value}}const ve=[`meter`,`progressbar`,`slider`,`spinbutton`];function ye(e){if(ve.includes(e.getAttribute(`role`)||``))return Number(e.getAttribute(`aria-valuenow`))}function be(e){return e.replace(/\s+/g,` `).trim()}function xe(e,t){return t instanceof RegExp?t.test(e):e.includes(String(t))}function S(e,t){if(Array.isArray(e)&&Array.isArray(t)){let n=new Set(t);for(let t of new Set(e))if(!n.has(t))return!1;return!0}}const C=se();function w(e){let t=m(e,w,this);if(!(b(t)&&[`checkbox`,`radio`].includes(t.type))&&!(C.includes(s(t)||``)&&[`true`,`false`].includes(t.getAttribute(`aria-checked`)||``)))return{pass:!1,message:()=>`only inputs with type="checkbox" or type="radio" or elements with ${Se()} and a valid aria-checked attribute can be used with .toBeChecked(). Use .toHaveValue() instead`};let n=o(t)===!0;return{pass:n,message:()=>{let e=n?`is`:`is not`;return[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeChecked`,`element`,``),``,`Received element ${e} checked:`,` ${this.utils.printReceived(t.cloneNode(!1))}`].join(`
|
|
4
|
+
`)}}}function Se(){return pe(C.map(e=>`role="${e}"`),{lastWordConnector:` or `})}function T(e){let t=m(e,T,this);return{pass:Ce(t),message:()=>[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeEmptyDOMElement`,`element`,``),``,`Received:`,` ${this.utils.printReceived(t.innerHTML)}`].join(`
|
|
5
|
+
`)}}function Ce(e){return[...e.childNodes].filter(e=>e.nodeType!==Node.COMMENT_NODE).length===0}function E(e){let t=m(e,E,this),n=O(t);return{pass:n,message:()=>{let e=n?`is`:`is not`;return[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeDisabled`,`element`,``),``,`Received element ${e} disabled:`,` ${this.utils.printReceived(t.cloneNode(!1))}`].join(`
|
|
6
|
+
`)}}}function D(e){let t=m(e,D,this),n=O(t);return{pass:!n,message:()=>{let e=n?`is not`:`is`;return[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeEnabled`,`element`,``),``,`Received element ${e} enabled:`,` ${this.utils.printReceived(t.cloneNode(!1))}`].join(`
|
|
7
|
+
`)}}}function O(e){return y(e).includes(`-`)?e.hasAttribute(`disabled`):c(e)}function k(e){let t=null;(e!==null||!this.isNot)&&(t=ce(e,k,this));let n=t===null?!1:t.ownerDocument===t.getRootNode({composed:!0}),r=()=>`expected document not to contain element, found ${this.utils.stringify(t?.cloneNode(!0))} instead`,i=()=>`element could not be found in the document`;return{pass:n,message:()=>[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeInTheDocument`,`element`,``),``,this.utils.RECEIVED_COLOR(this.isNot?r():i())].join(`
|
|
8
|
+
`)}}const we=[`FORM`,`INPUT`,`SELECT`,`TEXTAREA`];function Te(e){return e.hasAttribute(`aria-invalid`)&&e.getAttribute(`aria-invalid`)!==`false`}function Ee(e){return we.includes(y(e))}function A(e){let t=Te(e);return Ee(e)?t||!e.checkValidity():t}function j(e){let t=m(e,j,this),n=A(t);return{pass:n,message:()=>{let e=n?`is`:`is not`;return[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeInvalid`,`element`,``),``,`Received element ${e} currently invalid:`,` ${this.utils.printReceived(t.cloneNode(!1))}`].join(`
|
|
9
|
+
`)}}}function De(e){let t=m(e,j,this),n=!A(t);return{pass:n,message:()=>{let e=n?`is`:`is not`;return[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeValid`,`element`,``),``,`Received element ${e} currently valid:`,` ${this.utils.printReceived(t.cloneNode(!1))}`].join(`
|
|
10
|
+
`)}}}function M(e,t){let n=m(e,M,this),r=t?.ratio??0;return Oe(n,r).then(({pass:e,ratio:t})=>({pass:e,message:()=>{let i=e?`is`:`is not`,a=r>0?` with ratio ${r}`:``,o=t===void 0?``:` (actual ratio: ${t.toFixed(3)})`;return[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeInViewport`,`element`,``),``,`Received element ${i} in viewport${a}${o}:`,` ${this.utils.printReceived(n.cloneNode(!1))}`].join(`
|
|
11
|
+
`)}}))}async function Oe(e,t){let n=await new Promise(t=>{let n=new IntersectionObserver(e=>{e.length>0?t(e[0].intersectionRatio):t(0),n.disconnect()});n.observe(e),requestAnimationFrame(()=>{})});return{pass:n>0&&n>t-1e-9,ratio:n}}function N(e){let t=m(e,N,this);if(!(b(t)&&t.type===`checkbox`)&&t.getAttribute(`role`)!==`checkbox`)return{pass:!1,message:()=>`only inputs with type="checkbox" or elements with role="checkbox" and a valid aria-checked attribute can be used with .toBePartiallyChecked(). Use .toHaveValue() instead`};let n=ke(t);return{pass:n,message:()=>{let e=n?`is`:`is not`;return[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBePartiallyChecked`,`element`,``),``,`Received element ${e} partially checked:`,` ${this.utils.printReceived(t.cloneNode(!1))}`].join(`
|
|
12
|
+
`)}}}function ke(e){let t=o(e)===`mixed`;return!t&&b(e)&&[`checkbox`,`radio`].includes(e.type)&&e.getAttribute(`aria-checked`)===`mixed`?!0:t}const Ae=[`SELECT`,`TEXTAREA`],je=[`INPUT`,`SELECT`,`TEXTAREA`],Me=[`color`,`hidden`,`range`,`submit`,`image`,`reset`],Ne=[`checkbox`,`combobox`,`gridcell`,`listbox`,`radiogroup`,`spinbutton`,`textbox`,`tree`];function Pe(e){return Ae.includes(y(e))&&e.hasAttribute(`required`)}function Fe(e){return y(e)===`INPUT`&&e.hasAttribute(`required`)&&(e.hasAttribute(`type`)&&!Me.includes(e.getAttribute(`type`)||``)||!e.hasAttribute(`type`))}function Ie(e){return e.hasAttribute(`aria-required`)&&e.getAttribute(`aria-required`)===`true`&&(je.includes(y(e))||e.hasAttribute(`role`)&&Ne.includes(e.getAttribute(`role`)||``))}function P(e){let t=m(e,P,this),n=Pe(t)||Fe(t)||Ie(t);return{pass:n,message:()=>{let e=n?`is`:`is not`;return[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeRequired`,`element`,``),``,`Received element ${e} required:`,` ${this.utils.printReceived(t.cloneNode(!1))}`].join(`
|
|
13
|
+
`)}}}function Le(e){let t=m(e,Le,this),n=t.ownerDocument===t.getRootNode({composed:!0});l();let r=n&&Re(t);return u(),{pass:r,message:()=>{let e=r?`is`:`is not`;return[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeVisible`,`element`,``),``,`Received element ${e} visible${n?``:` (element is not in the document)`}:`,` ${this.utils.printReceived(t.cloneNode(!1))}`].join(`
|
|
14
|
+
`)}}}function Re(e){let t=ee(e);if(p.browser!==`webkit`)return t;let n=e.closest(`details`);return!n||e===n?t:ze(e)}function ze(e){let t=e;for(;t;){if(t.tagName===`DETAILS`){let n=t.querySelector(`summary`)===e;if(!t.open&&!n)return!1}t=t.parentElement}return e.offsetParent!==null}function F(e,t){let n=m(e,F,this),r=t===null?null:m(t,F,this);return{pass:n.contains(r),message:()=>[this.utils.matcherHint(`${this.isNot?`.not`:``}.toContainElement`,`element`,`element`),``,this.utils.RECEIVED_COLOR(`${this.utils.stringify(n.cloneNode(!1))} ${this.isNot?`contains:`:`does not contain:`} ${this.utils.stringify(r?r.cloneNode(!1):null)}
|
|
15
15
|
`)].join(`
|
|
16
|
-
`)}}function
|
|
17
|
-
`)}}function
|
|
16
|
+
`)}}function Be(e,t){let n=e.ownerDocument.createElement(`div`);return n.innerHTML=t,n.innerHTML}function I(e,t){let n=m(e,I,this);if(typeof t!=`string`)throw TypeError(`.toContainHTML() expects a string value, got ${t}`);return{pass:n.outerHTML.includes(Be(n,t)),message:()=>[this.utils.matcherHint(`${this.isNot?`.not`:``}.toContainHTML`,`element`,``),`Expected:`,` ${this.utils.EXPECTED_COLOR(t)}`,`Received:`,` ${this.utils.printReceived(n.cloneNode(!0))}`].join(`
|
|
17
|
+
`)}}function L(e,t){let n=m(e,L,this),r=te(n,!1),i=n.ownerDocument.defaultView||window,a=arguments.length===1,o=!1;return o=a?r!==``:t instanceof i.RegExp?t.test(r):this.equals(r,t,this.customTesters),{pass:o,message:()=>{let e=this.isNot?`not to`:`to`;return h(this,this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveAccessibleDescription`,`element`,``),`Expected element ${e} have accessible description`,t,`Received`,r)}}}function R(e,t){let n=m(e,R,this),r=ne(n)??``,i=n.ownerDocument.defaultView||window,a=arguments.length===1,o=!1;return o=a?r!==``:t instanceof i.RegExp?t.test(r):this.equals(r,t,this.customTesters),{pass:o,message:()=>{let e=this.isNot?`not to`:`to`;return t==null?[this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveAccessibleErrorMessage`,`element`,``),`Expected element ${e} have accessible error message, but got${this.isNot?``:` nothing`}`,this.isNot?this.utils.RECEIVED_COLOR(g(r,2)):``].filter(Boolean).join(`
|
|
18
18
|
|
|
19
|
-
`):
|
|
20
|
-
`)}}function
|
|
21
|
-
`)}}function
|
|
19
|
+
`):h(this,this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveAccessibleErrorMessage`,`element`,``),`Expected element ${e} have accessible error message`,t,`Received`,r)}}}function z(e,t){let n=m(e,z,this),r=re(n,!1),i=arguments.length===1,a=n.ownerDocument.defaultView||window,o=!1;return o=i?r!==``:t instanceof a.RegExp?t.test(r):this.equals(r,t,this.customTesters),{pass:o,message:()=>{let e=this.isNot?`not to`:`to`;return h(this,this.utils.matcherHint(`${this.isNot?`.not`:``}.${z.name}`,`element`,``),`Expected element ${e} have accessible name`,t,`Received`,r)}}}function B(e,t,n){let r=m(e,B,this),i=n!==void 0,a=r.hasAttribute(t),o=r.getAttribute(t);return{pass:i?a&&this.equals(o,n,this.customTesters):a,message:()=>{let e=this.isNot?`not to`:`to`,r=a?V(this.utils.stringify,t,o):null,s=this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveAttribute`,`element`,this.utils.printExpected(t),{secondArgument:i?this.utils.printExpected(n):void 0,comment:Ve(this.utils.stringify,t,n)});return h(this,s,`Expected the element ${e} have attribute`,V(this.utils.stringify,t,n),`Received`,r)}}}function V(e,t,n){return n===void 0?t:`${t}=${e(n)}`}function Ve(e,t,n){return n===void 0?`element.hasAttribute(${e(t)})`:`element.getAttribute(${e(t)}) === ${e(n)}`}function H(e,...t){let n=m(e,H,this),{expectedClassNames:r,options:i}=He(t),a=U(n.getAttribute(`class`)),o=r.reduce((e,t)=>e.concat(typeof t==`string`||!t?U(t):t),[]),s=o.some(e=>e instanceof RegExp);if(i.exact&&s)throw Error(`Exact option does not support RegExp expected class names`);return i.exact?{pass:W(o,a)&&o.length===a.length,message:()=>{let e=this.isNot?`not to`:`to`;return h(this,this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveClass`,`element`,this.utils.printExpected(o.join(` `))),`Expected the element ${e} have EXACTLY defined classes`,o.join(` `),`Received`,a.join(` `))}}:o.length>0?{pass:W(o,a),message:()=>{let e=this.isNot?`not to`:`to`;return h(this,this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveClass`,`element`,this.utils.printExpected(o.join(` `))),`Expected the element ${e} have class`,o.join(` `),`Received`,a.join(` `))}}:{pass:this.isNot?a.length>0:!1,message:()=>this.isNot?h(this,this.utils.matcherHint(`.not.toHaveClass`,`element`,``),`Expected the element to have classes`,`(none)`,`Received`,a.join(` `)):[this.utils.matcherHint(`.toHaveClass`,`element`),`At least one expected class must be provided.`].join(`
|
|
20
|
+
`)}}function He(e){let t=e.pop(),n,r;return typeof t==`object`&&!(t instanceof RegExp)?(n=e,r=t):(n=e.concat(t),r={exact:!1}),{expectedClassNames:n,options:r}}function U(e){return e?e.split(/\s+/).filter(e=>e.length>0):[]}function W(e,t){return e.every(e=>typeof e==`string`?t.includes(e):t.some(t=>e.test(t)))}function G(e,t){let n=m(e,G,this),r=y(n);if(![`SELECT`,`INPUT`,`TEXTAREA`].includes(r))throw Error(`.toHaveDisplayValue() currently supports only input, textarea or select elements, try with another matcher instead.`);if(b(n)&&[`radio`,`checkbox`].includes(n.type))throw Error(`.toHaveDisplayValue() currently does not support input[type="${n.type}"], try with another matcher instead.`);let i=Ue(r,n),a=We(t),o=a.filter(e=>i.some(t=>e instanceof RegExp?e.test(t):this.equals(t,String(e),this.customTesters))).length,s=o===i.length,c=o===a.length;return{pass:s&&c,message:()=>h(this,this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveDisplayValue`,`element`,``),`Expected element ${this.isNot?`not `:``}to have display value`,t,`Received`,i)}}function Ue(e,t){return e===`SELECT`?Array.from(t).filter(e=>e.selected).map(e=>e.textContent||``):[t.value]}function We(e){return Array.isArray(e)?e:[e]}function K(e){let t=m(e,K,this);return{pass:t.ownerDocument.activeElement===t,message:()=>[this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveFocus`,`element`,``),``,...this.isNot?[`Received element is focused:`,` ${this.utils.printReceived(t)}`]:[`Expected element with focus:`,` ${this.utils.printExpected(t)}`,`Received element with focus:`,` ${this.utils.printReceived(t.ownerDocument.activeElement)}`]].join(`
|
|
21
|
+
`)}}function q(e,t){let n=m(e,q,this),r=n.ownerDocument.defaultView||window;if(!(n instanceof r.HTMLFieldSetElement)&&!(n instanceof r.HTMLFormElement))throw TypeError(`toHaveFormValues must be called on a form or a fieldset, instead got ${y(n)}`);if(!t||typeof t!=`object`)throw TypeError(`toHaveFormValues must be called with an object of expected form values. Got ${t}`);let i=Je(n);return{pass:Object.entries(t).every(([e,t])=>this.equals(i[e],t,[S,...this.customTesters])),message:()=>{let e=this.isNot?`not to`:`to`,n=`${this.isNot?`.not`:``}.toHaveFormValues`,r={};for(let e in i)Object.hasOwn(t,e)&&(r[e]=i[e]);return[this.utils.matcherHint(n,`element`,``),`Expected the element ${e} have form values`,this.utils.diff(t,r)].join(`
|
|
22
22
|
|
|
23
|
-
`)}}}function
|
|
23
|
+
`)}}}function Ge(e){let t=``;for(let n of e){if(t&&t!==n.type)throw Error(`Multiple form elements with the same name must be of the same type`);t=n.type}switch(t){case`radio`:{let t=e.find(e=>e.checked);return t?t.value:void 0}case`checkbox`:return e.filter(e=>e.checked).map(e=>e.value);default:return e.map(e=>e.value)}}function Ke(e,t){let n=[...e.querySelectorAll(`[name="${ie(t)}"]`)];if(n.length!==0)switch(n.length){case 1:return x(n[0]);default:return Ge(n)}}function qe(e){return/\[\]$/.test(e)?e.slice(0,-2):e}function Je(e){let t={};for(let n of e.elements){if(!(`name`in n))continue;let r=n.name;t[qe(r)]=Ke(e,r)}return t}function J(e,t){let n=m(e,J,this);l();let r=s(n);return u(),{pass:r===t,message:()=>{let e=this.isNot?`not to`:`to`;return h(this,this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveRole`,`element`,``),`Expected element ${e} have role`,t,`Received`,r)}}}function Y(e,t){let n=m(e,Y,this),r=t!==void 0;if(r&&typeof t!=`string`)throw Error(`expected selection must be a string or undefined`);let i=Ye(n);return{pass:r?this.equals(i,t,[S,...this.customTesters]):!!i,message:()=>{let e=this.isNot?`not to`:`to`,n=this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveSelection`,`element`,t);return h(this,n,`Expected the element ${e} have selection`,r?t:`(any)`,`Received`,i)}}}function Ye(e){let t=e.ownerDocument.getSelection();if(!t)return``;if([`INPUT`,`TEXTAREA`].includes(y(e))){let t=e;return[`radio`,`checkbox`].includes(t.type)||t.selectionStart==null||t.selectionEnd==null?``:t.value.toString().substring(t.selectionStart,t.selectionEnd)}if(t.anchorNode===null||t.focusNode===null)return``;let n=t.getRangeAt(0),r=e.ownerDocument.createRange();if(t.containsNode(e,!1))r.selectNodeContents(e),t.removeAllRanges(),t.addRange(r);else if(!(e.contains(t.anchorNode)&&e.contains(t.focusNode))){let i=e===n.startContainer||e.contains(n.startContainer),a=e===n.endContainer||e.contains(n.endContainer);t.removeAllRanges(),(i||a)&&(r.selectNodeContents(e),i&&r.setStart(n.startContainer,n.startOffset),a&&r.setEnd(n.endContainer,n.endOffset),t.addRange(r))}let i=t.toString();return t.removeAllRanges(),t.addRange(n),i}const X=p.config.browser.name,Z=new Set(`backgroundPosition.background-position.bottom.left.right.top.height.width.margin-bottom.marginBottom.margin-left.marginLeft.margin-right.marginRight.margin-top.marginTop.min-height.minHeight.min-width.minWidth.padding-bottom.padding-left.padding-right.padding-top.text-indent.paddingBottom.paddingLeft.paddingRight.paddingTop.textIndent`.split(`.`));function Q(e,t){let n=m(e,Q,this),{getComputedStyle:r}=n.ownerDocument.defaultView,i=typeof t==`object`?Xe(t):Ze(t),a=r(n),o=new Set(Array.from(n.style));return{pass:$e(i,n,a,o),message:()=>{let e=`${this.isNot?`.not`:``}.toHaveStyle`,t=new Set(Object.keys(i)),r=Qe(Array.from(a).filter(e=>t.has(e)).reduce((e,t)=>(e[t]=(o.has(t)&&Z.has(t)?n.style:a)[t],e),{})),s=r===``?`Expected styles could not be parsed by the browser. Did you make a typo?`:this.utils.diff(Qe(i),r);return[this.utils.matcherHint(e,`element`,``),s].join(`
|
|
24
24
|
|
|
25
|
-
`)}}}function
|
|
26
|
-
`)}function
|
|
27
|
-
`)}}const
|
|
25
|
+
`)}}}function Xe(e){let t=X===`chrome`||X===`chromium`?document:document.implementation.createHTMLDocument(``),n=t.createElement(`div`);t.body.appendChild(n);let r=Object.keys(e);r.forEach(t=>{n.style[t]=e[t]});let i={},a=window.getComputedStyle(n);return r.forEach(e=>{let t=(Z.has(e)?n.style:a)[e];t!=null&&(i[e]=t)}),n.remove(),i}function Ze(e){let t=X===`chrome`||X===`chromium`||X===`webkit`?document:document.implementation.createHTMLDocument(``),n=t.createElement(`div`);n.setAttribute(`style`,e.replace(/\n/g,``)),t.body.appendChild(n);let r=window.getComputedStyle(n),i=Array.from(n.style).reduce((e,t)=>(e[t]=Z.has(t)?n.style.getPropertyValue(t):r.getPropertyValue(t),e),{});return n.remove(),i}function Qe(e){return Object.keys(e).sort().map(t=>`${t}: ${e[t]};`).join(`
|
|
26
|
+
`)}function $e(e,t,n,r){let i=Object.keys(e);return i.length?i.every(i=>{let a=e[i],o=i.startsWith(`--`),s=[i];return o||s.push(i.toLowerCase()),s.some(e=>{let o=r.has(i)&&Z.has(i)?t.style:n;return o[e]===a||o.getPropertyValue(e)===a})}):!1}function et(e,t,n={normalizeWhitespace:!0}){let r=le(e,et,this),i=n.normalizeWhitespace?be(r.textContent||``):(r.textContent||``).replace(/\u00A0/g,` `),a=i!==``&&t===``;return{pass:!a&&xe(i,t),message:()=>{let e=this.isNot?`not to`:`to`;return h(this,this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveTextContent`,`element`,``),a?`Checking with empty string will always match, use .toBeEmptyDOMElement() instead`:`Expected element ${e} have text content`,t,`Received`,i)}}}function tt(e,t){let n=m(e,tt,this);if(b(n)&&[`checkbox`,`radio`].includes(n.type))throw Error(`input with type=checkbox or type=radio cannot be used with .toHaveValue(). Use .toBeChecked() for type=checkbox or .toHaveFormValues() instead`);let r=x(n),i=t!==void 0,a=t,o=r;return t==r&&t!==r&&(a=`${t} (${typeof t})`,o=`${r} (${typeof r})`),{pass:i?this.equals(r,t,[S,...this.customTesters]):!!r,message:()=>{let e=this.isNot?`not to`:`to`,n=this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveValue`,`element`,t);return h(this,n,`Expected the element ${e} have value`,i?a:`(any)`,`Received`,o)}}}const $=new Map([]);async function nt(t,n,r=typeof n==`object`?n:{}){if(this.isNot)throw Error(`'toMatchScreenshot' cannot be used with "not"`);if(this.task===void 0||this.currentTestName===void 0)throw Error(`'toMatchScreenshot' cannot be used without test context`);let i=`${this.task.result?.repeatCount??0}${this.testPath}${this.currentTestName}`,a=$.get(i);a===void 0&&(a={current:0},$.set(i,a)),a.current+=1;let o=typeof n==`string`?n:`${this.currentTestName} ${a.current}`,[s,...c]=await Promise.all([d(t,r),...r.screenshotOptions&&`mask`in r.screenshotOptions?r.screenshotOptions.mask.map(e=>d(e,r)):[]]),l=r.screenshotOptions&&`mask`in r.screenshotOptions?{...r,screenshotOptions:{...r.screenshotOptions,mask:c}}:r,u=await f().commands.triggerCommand(`__vitest_screenshotMatcher`,[o,this.currentTestName,{element:s,...l}]);if(u.pass===!1){let t=[];u.reference&&t.push({name:`reference`,...u.reference}),u.actual&&t.push({name:`actual`,...u.actual}),u.diff&&t.push({name:`diff`,...u.diff}),t.length>0&&await e(this.task,{type:`internal:toMatchScreenshot`,kind:`visual-regression`,message:u.message,attachments:t})}return{pass:u.pass,message:()=>u.pass?``:[this.utils.matcherHint(`toMatchScreenshot`,`element`,``),``,u.message,u.reference?`\nReference screenshot:\n ${this.utils.EXPECTED_COLOR(u.reference.path)}`:null,u.actual?`\nActual screenshot:\n ${this.utils.RECEIVED_COLOR(u.actual.path)}`:null,u.diff?this.utils.DIM_COLOR(`\nDiff image:\n ${u.diff.path}`):null,``].filter(e=>e!==null).join(`
|
|
27
|
+
`)}}const rt={toBeDisabled:E,toBeEnabled:D,toBeEmptyDOMElement:T,toBeInTheDocument:k,toBeInViewport:M,toBeInvalid:j,toBeRequired:P,toBeValid:De,toBeVisible:Le,toContainElement:F,toContainHTML:I,toHaveAccessibleDescription:L,toHaveAccessibleErrorMessage:R,toHaveAccessibleName:z,toHaveAttribute:B,toHaveClass:H,toHaveFocus:K,toHaveFormValues:q,toHaveStyle:Q,toHaveTextContent:et,toHaveValue:tt,toHaveDisplayValue:G,toBeChecked:w,toBePartiallyChecked:N,toHaveRole:J,toHaveSelection:Y,toMatchScreenshot:nt},it=Symbol.for(`$$vitest:locator`);function at(e,i){if(e!=null&&!(e instanceof HTMLElement)&&!(e instanceof SVGElement)&&!(it in e))throw Error(`Invalid element or locator: ${e}. Expected an instance of HTMLElement, SVGElement or Locator, received ${r(e)}`);let a=t.poll(function(){if(e instanceof Element||e==null)return e;let t=n.util.flag(this,`negate`),r=n.util.flag(this,`_name`);if(t&&r===`toBeInTheDocument`)return e.query();if(r===`toHaveLength`)return e.elements();if(r===`toMatchScreenshot`&&!n.util.flag(this,`_poll.assert_once`)&&n.util.flag(this,`_poll.assert_once`,!0),n.util.flag(this,`_isLastPollAttempt`))return e.element();let i=e.query();if(!i)throw Error(`Cannot find element with locator: ${JSON.stringify(e)}`);return i},ae(i));n.util.flag(a,`_poll.element`,!0);let o=oe().current;if(o&&f().activeTraceTaskIds.has(o.id)){let t=Error(`__vitest_mark_trace__`);n.util.flag(a,`_poll.onSettled`,async r=>{let i=n.util.flag(r.assertion,`negate`),a=n.util.flag(r.assertion,`_name`)||`<unknown>`,o=`expect.element().${i?`not.`:``}${a}`,s=r.status===`fail`?`${o} [ERROR]`:o,c=!e||e instanceof Element?void 0:e.selector;await f().commands.triggerCommand(`__vitest_markTrace`,[{name:s,selector:c,stack:t.stack}],t)})}return a}t.extend(rt),t.element=at;
|