@vitest/browser 3.0.0-beta.3 → 3.0.0-beta.4
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 +36 -0
- package/dist/client/.vite/manifest.json +6 -6
- package/dist/client/__vitest__/assets/index-BC8TFRpg.js +52 -0
- package/dist/client/__vitest__/index.html +1 -1
- package/dist/client/__vitest_browser__/{orchestrator-vOivV83Y.js → orchestrator-Cv-bzUFk.js} +1 -1
- package/dist/client/__vitest_browser__/{tester-CDBn6hqf.js → tester-DreAh6ar.js} +69 -55
- package/dist/client/__vitest_browser__/{utils-Owv5OOOf.js → utils-CaCTRFti.js} +2 -0
- package/dist/client/orchestrator.html +2 -2
- package/dist/client/tester/tester.html +2 -2
- package/dist/client.js +2 -2
- package/dist/context.js +22 -1
- package/dist/{index-VFFcOojA.js → index-Dos_sf7B.js} +9 -0
- package/dist/index.js +32 -22
- package/dist/locators/index.d.ts +3 -0
- package/dist/locators/index.js +1 -1
- package/dist/locators/playwright.js +1 -1
- package/dist/locators/preview.js +1 -1
- package/dist/locators/webdriverio.js +1 -1
- package/jest-dom.d.ts +4 -4
- package/package.json +9 -9
- package/providers/playwright.d.ts +2 -1
- package/providers/webdriverio.d.ts +2 -1
- package/dist/client/__vitest__/assets/index-JmEkKNR0.js +0 -52
|
@@ -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-BC8TFRpg.js"></script>
|
|
27
27
|
<link rel="stylesheet" href="./assets/index-D1v_Nqq1.css">
|
|
28
28
|
</head>
|
|
29
29
|
<body>
|
package/dist/client/__vitest_browser__/{orchestrator-vOivV83Y.js → orchestrator-Cv-bzUFk.js}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { g as getBrowserState, a as getConfig, r as relative } from "./utils-
|
|
4
|
+
import { g as getBrowserState, a as getConfig, r as relative } from "./utils-CaCTRFti.js";
|
|
5
5
|
import { client, channel, globalChannel } from "@vitest/browser/client";
|
|
6
6
|
function generateHash(str) {
|
|
7
7
|
let hash = 0;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
|
|
4
|
+
var _a2;
|
|
5
|
+
import { a as getConfig, g as getBrowserState, b as resolve, e as executor, c as getWorkerState } from "./utils-CaCTRFti.js";
|
|
5
6
|
import { globalChannel, client, onCancel, channel } from "@vitest/browser/client";
|
|
6
7
|
import { userEvent, page } from "@vitest/browser/context";
|
|
7
8
|
import { loadDiffConfig, loadSnapshotSerializers, takeCoverageInsideWorker, setupCommonEnv, startCoverageInsideWorker, startTests, collectTests, stopCoverageInsideWorker, SpyModule } from "vitest/browser";
|
|
@@ -67,16 +68,16 @@ const __vitePreload = function preload(baseModule, deps, importerUrl) {
|
|
|
67
68
|
};
|
|
68
69
|
function showPopupWarning(name, value, defaultValue) {
|
|
69
70
|
return (...params) => {
|
|
70
|
-
const
|
|
71
|
-
console.warn(`Vitest encountered a \`${name}(${
|
|
71
|
+
const formattedParams = params.map((p) => JSON.stringify(p)).join(", ");
|
|
72
|
+
console.warn(`Vitest encountered a \`${name}(${formattedParams})\` call that it cannot handle by default, so it returned \`${value}\`. Read more in https://vitest.dev/guide/browser/#thread-blocking-dialogs.
|
|
72
73
|
If needed, mock the \`${name}\` call manually like:
|
|
73
74
|
|
|
74
75
|
\`\`\`
|
|
75
76
|
import { expect, vi } from "vitest"
|
|
76
77
|
|
|
77
78
|
vi.spyOn(window, "${name}")${defaultValue ? `.mockReturnValue(${JSON.stringify(defaultValue)})` : ""}
|
|
78
|
-
${name}(${
|
|
79
|
-
expect(${name}).toHaveBeenCalledWith(${
|
|
79
|
+
${name}(${formattedParams})
|
|
80
|
+
expect(${name}).toHaveBeenCalledWith(${formattedParams})
|
|
80
81
|
\`\`\``);
|
|
81
82
|
return value;
|
|
82
83
|
};
|
|
@@ -644,7 +645,7 @@ function _defineProperties(target, props) {
|
|
|
644
645
|
}
|
|
645
646
|
}
|
|
646
647
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
647
|
-
|
|
648
|
+
_defineProperties(Constructor.prototype, protoProps);
|
|
648
649
|
Object.defineProperty(Constructor, "prototype", { writable: false });
|
|
649
650
|
return Constructor;
|
|
650
651
|
}
|
|
@@ -1459,7 +1460,7 @@ Object.defineProperty(iterationDecorator$1, "__esModule", {
|
|
|
1459
1460
|
iterationDecorator$1.default = iterationDecorator;
|
|
1460
1461
|
var _iteratorProxy = _interopRequireDefault$a(iteratorProxy$1);
|
|
1461
1462
|
function _interopRequireDefault$a(obj) {
|
|
1462
|
-
return obj
|
|
1463
|
+
return obj.__esModule ? obj : { default: obj };
|
|
1463
1464
|
}
|
|
1464
1465
|
function _typeof(obj) {
|
|
1465
1466
|
"@babel/helpers - typeof";
|
|
@@ -1483,7 +1484,7 @@ Object.defineProperty(ariaPropsMap$1, "__esModule", {
|
|
|
1483
1484
|
ariaPropsMap$1.default = void 0;
|
|
1484
1485
|
var _iterationDecorator$4 = _interopRequireDefault$9(iterationDecorator$1);
|
|
1485
1486
|
function _interopRequireDefault$9(obj) {
|
|
1486
|
-
return obj
|
|
1487
|
+
return obj.__esModule ? obj : { default: obj };
|
|
1487
1488
|
}
|
|
1488
1489
|
function _slicedToArray$4(arr, i) {
|
|
1489
1490
|
return _arrayWithHoles$4(arr) || _iterableToArrayLimit$4(arr, i) || _unsupportedIterableToArray$4(arr, i) || _nonIterableRest$4();
|
|
@@ -1733,7 +1734,7 @@ Object.defineProperty(domMap$1, "__esModule", {
|
|
|
1733
1734
|
domMap$1.default = void 0;
|
|
1734
1735
|
var _iterationDecorator$3 = _interopRequireDefault$8(iterationDecorator$1);
|
|
1735
1736
|
function _interopRequireDefault$8(obj) {
|
|
1736
|
-
return obj
|
|
1737
|
+
return obj.__esModule ? obj : { default: obj };
|
|
1737
1738
|
}
|
|
1738
1739
|
function _slicedToArray$3(arr, i) {
|
|
1739
1740
|
return _arrayWithHoles$3(arr) || _iterableToArrayLimit$3(arr, i) || _unsupportedIterableToArray$3(arr, i) || _nonIterableRest$3();
|
|
@@ -10295,7 +10296,7 @@ function toHaveAccessibleDescription(htmlElement, expectedAccessibleDescription)
|
|
|
10295
10296
|
const ariaInvalidName = "aria-invalid";
|
|
10296
10297
|
const validStates = ["false"];
|
|
10297
10298
|
function toHaveAccessibleErrorMessage(htmlElement, expectedAccessibleErrorMessage) {
|
|
10298
|
-
var
|
|
10299
|
+
var _a3;
|
|
10299
10300
|
checkHtmlElement(htmlElement, toHaveAccessibleErrorMessage, this);
|
|
10300
10301
|
const to = this.isNot ? "not to" : "to";
|
|
10301
10302
|
const method = this.isNot ? ".not.toHaveAccessibleErrorMessage" : ".toHaveAccessibleErrorMessage";
|
|
@@ -10334,7 +10335,7 @@ function toHaveAccessibleErrorMessage(htmlElement, expectedAccessibleErrorMessag
|
|
|
10334
10335
|
};
|
|
10335
10336
|
}
|
|
10336
10337
|
const error = normalize$1(
|
|
10337
|
-
((
|
|
10338
|
+
((_a3 = htmlElement.ownerDocument.getElementById(errormessageId)) == null ? void 0 : _a3.textContent) ?? ""
|
|
10338
10339
|
);
|
|
10339
10340
|
return {
|
|
10340
10341
|
pass: expectedAccessibleErrorMessage === void 0 ? Boolean(error) : expectedAccessibleErrorMessage instanceof RegExp ? expectedAccessibleErrorMessage.test(error) : this.equals(error, expectedAccessibleErrorMessage),
|
|
@@ -11078,8 +11079,8 @@ function supportedRoles() {
|
|
|
11078
11079
|
return roles_1.keys().filter(roleSupportsChecked);
|
|
11079
11080
|
}
|
|
11080
11081
|
function roleSupportsChecked(role) {
|
|
11081
|
-
var
|
|
11082
|
-
return ((
|
|
11082
|
+
var _a3;
|
|
11083
|
+
return ((_a3 = roles_1.get(role)) == null ? void 0 : _a3.props["aria-checked"]) !== void 0;
|
|
11083
11084
|
}
|
|
11084
11085
|
function toBePartiallyChecked(element) {
|
|
11085
11086
|
checkHtmlElement(element, toBePartiallyChecked, this);
|
|
@@ -11316,10 +11317,18 @@ async function setupExpectDom() {
|
|
|
11316
11317
|
chai.util.flag(this, "_poll.element", true);
|
|
11317
11318
|
const isNot = chai.util.flag(this, "negate");
|
|
11318
11319
|
const name = chai.util.flag(this, "_name");
|
|
11320
|
+
const isLastPollAttempt = chai.util.flag(this, "_isLastPollAttempt");
|
|
11319
11321
|
if (isNot && name === "toBeInTheDocument") {
|
|
11320
11322
|
return elementOrLocator.query();
|
|
11321
11323
|
}
|
|
11322
|
-
|
|
11324
|
+
if (isLastPollAttempt) {
|
|
11325
|
+
return elementOrLocator.element();
|
|
11326
|
+
}
|
|
11327
|
+
const result = elementOrLocator.query();
|
|
11328
|
+
if (!result) {
|
|
11329
|
+
throw new Error(`Cannot find element with locator: ${JSON.stringify(elementOrLocator)}`);
|
|
11330
|
+
}
|
|
11331
|
+
return result;
|
|
11323
11332
|
}, options);
|
|
11324
11333
|
};
|
|
11325
11334
|
}
|
|
@@ -11400,11 +11409,11 @@ function setupConsoleLogSpy() {
|
|
|
11400
11409
|
sendLog("stdout", processLog(args));
|
|
11401
11410
|
};
|
|
11402
11411
|
console$1.trace = (...args) => {
|
|
11403
|
-
var
|
|
11412
|
+
var _a3;
|
|
11404
11413
|
trace(...args);
|
|
11405
11414
|
const content = processLog(args);
|
|
11406
11415
|
const error2 = new Error("$$Trace");
|
|
11407
|
-
const processor = ((
|
|
11416
|
+
const processor = ((_a3 = globalThis.__vitest_worker__) == null ? void 0 : _a3.onFilterStackTrace) || ((s) => s || "");
|
|
11408
11417
|
const stack = processor(error2.stack || "");
|
|
11409
11418
|
sendLog("stderr", `${content}
|
|
11410
11419
|
${stack}`, true);
|
|
@@ -11471,12 +11480,12 @@ function processLog(args) {
|
|
|
11471
11480
|
return args.map(formatInput).join(" ");
|
|
11472
11481
|
}
|
|
11473
11482
|
function sendLog(type, content, disableStack) {
|
|
11474
|
-
var
|
|
11483
|
+
var _a3, _b, _c;
|
|
11475
11484
|
if (content.startsWith("[vite]")) {
|
|
11476
11485
|
return;
|
|
11477
11486
|
}
|
|
11478
11487
|
const unknownTestId = "__vitest__unknown_test__";
|
|
11479
|
-
const taskId = ((_b = (
|
|
11488
|
+
const taskId = ((_b = (_a3 = globalThis.__vitest_worker__) == null ? void 0 : _a3.current) == null ? void 0 : _b.id) ?? unknownTestId;
|
|
11480
11489
|
const origin = getConfig().printConsoleTrace && !disableStack ? (_c = new Error("STACK_TRACE").stack) == null ? void 0 : _c.split("\n").slice(1).join("\n") : void 0;
|
|
11481
11490
|
rpc$1().sendLog({
|
|
11482
11491
|
origin,
|
|
@@ -11827,6 +11836,8 @@ function normalizeWindowsPath(input = "") {
|
|
|
11827
11836
|
const _UNC_REGEX = /^[/\\]{2}/;
|
|
11828
11837
|
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
11829
11838
|
const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
11839
|
+
const _EXTNAME_RE = /.(\.[^./]+)$/;
|
|
11840
|
+
((_a2 = globalThis.process) == null ? void 0 : _a2.platform) === "win32" ? ";" : ":";
|
|
11830
11841
|
const normalize = function(path) {
|
|
11831
11842
|
if (path.length === 0) {
|
|
11832
11843
|
return ".";
|
|
@@ -11856,24 +11867,26 @@ const normalize = function(path) {
|
|
|
11856
11867
|
}
|
|
11857
11868
|
return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
|
|
11858
11869
|
};
|
|
11859
|
-
const join = function(...
|
|
11860
|
-
|
|
11861
|
-
|
|
11862
|
-
|
|
11863
|
-
|
|
11864
|
-
|
|
11865
|
-
if (
|
|
11866
|
-
|
|
11867
|
-
|
|
11870
|
+
const join = function(...segments) {
|
|
11871
|
+
let path = "";
|
|
11872
|
+
for (const seg of segments) {
|
|
11873
|
+
if (!seg) {
|
|
11874
|
+
continue;
|
|
11875
|
+
}
|
|
11876
|
+
if (path.length > 0) {
|
|
11877
|
+
const pathTrailing = path[path.length - 1] === "/";
|
|
11878
|
+
const segLeading = seg[0] === "/";
|
|
11879
|
+
const both = pathTrailing && segLeading;
|
|
11880
|
+
if (both) {
|
|
11881
|
+
path += seg.slice(1);
|
|
11868
11882
|
} else {
|
|
11869
|
-
|
|
11883
|
+
path += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
11870
11884
|
}
|
|
11885
|
+
} else {
|
|
11886
|
+
path += seg;
|
|
11871
11887
|
}
|
|
11872
11888
|
}
|
|
11873
|
-
|
|
11874
|
-
return ".";
|
|
11875
|
-
}
|
|
11876
|
-
return normalize(joined.replace(/\/\/+/g, "/"));
|
|
11889
|
+
return normalize(path);
|
|
11877
11890
|
};
|
|
11878
11891
|
function normalizeString(path, allowAboveRoot) {
|
|
11879
11892
|
let res = "";
|
|
@@ -11938,11 +11951,11 @@ function normalizeString(path, allowAboveRoot) {
|
|
|
11938
11951
|
const isAbsolute = function(p) {
|
|
11939
11952
|
return _IS_ABSOLUTE_RE.test(p);
|
|
11940
11953
|
};
|
|
11941
|
-
const _EXTNAME_RE = /.(\.[^./]+)$/;
|
|
11942
11954
|
const extname = function(p) {
|
|
11943
11955
|
const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
|
|
11944
11956
|
return match && match[1] || "";
|
|
11945
11957
|
};
|
|
11958
|
+
var _a;
|
|
11946
11959
|
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
11947
11960
|
const intToChar = new Uint8Array(64);
|
|
11948
11961
|
const charToInt = new Uint8Array(128);
|
|
@@ -11961,6 +11974,7 @@ var UrlType;
|
|
|
11961
11974
|
UrlType2[UrlType2["SchemeRelative"] = 6] = "SchemeRelative";
|
|
11962
11975
|
UrlType2[UrlType2["Absolute"] = 7] = "Absolute";
|
|
11963
11976
|
})(UrlType || (UrlType = {}));
|
|
11977
|
+
((_a = globalThis.process) == null ? void 0 : _a.platform) === "win32" ? ";" : ":";
|
|
11964
11978
|
const { now } = Date;
|
|
11965
11979
|
class ModuleMocker {
|
|
11966
11980
|
constructor(interceptor, rpc2, spyOn, config) {
|
|
@@ -13168,13 +13182,13 @@ function requireResolveUri_umd() {
|
|
|
13168
13182
|
return map;
|
|
13169
13183
|
}
|
|
13170
13184
|
function encodedMappings(map) {
|
|
13171
|
-
var
|
|
13185
|
+
var _a3;
|
|
13172
13186
|
var _b;
|
|
13173
|
-
return (
|
|
13187
|
+
return (_a3 = (_b = cast(map))._encoded) !== null && _a3 !== void 0 ? _a3 : _b._encoded = sourcemapCodec.encode(cast(map)._decoded);
|
|
13174
13188
|
}
|
|
13175
13189
|
function decodedMappings(map) {
|
|
13176
|
-
var
|
|
13177
|
-
return (
|
|
13190
|
+
var _a3;
|
|
13191
|
+
return (_a3 = cast(map))._decoded || (_a3._decoded = sourcemapCodec.decode(cast(map)._encoded));
|
|
13178
13192
|
}
|
|
13179
13193
|
function traceSegment(map, line, column) {
|
|
13180
13194
|
const decoded = decodedMappings(map);
|
|
@@ -13321,7 +13335,7 @@ function requireResolveUri_umd() {
|
|
|
13321
13335
|
return result;
|
|
13322
13336
|
}
|
|
13323
13337
|
function generatedPosition(map, source2, line, column, bias, all) {
|
|
13324
|
-
var
|
|
13338
|
+
var _a3;
|
|
13325
13339
|
line--;
|
|
13326
13340
|
if (line < 0)
|
|
13327
13341
|
throw new Error(LINE_GTR_ZERO);
|
|
@@ -13333,7 +13347,7 @@ function requireResolveUri_umd() {
|
|
|
13333
13347
|
sourceIndex2 = resolvedSources.indexOf(source2);
|
|
13334
13348
|
if (sourceIndex2 === -1)
|
|
13335
13349
|
return all ? [] : GMapping(null, null);
|
|
13336
|
-
const generated = (
|
|
13350
|
+
const generated = (_a3 = cast(map))._bySources || (_a3._bySources = buildBySources(decodedMappings(map), cast(map)._bySourceMemos = sources.map(memoizedState)));
|
|
13337
13351
|
const segments = generated[sourceIndex2][line];
|
|
13338
13352
|
if (segments == null)
|
|
13339
13353
|
return all ? [] : GMapping(null, null);
|
|
@@ -13498,11 +13512,11 @@ function parseStacktrace(stack, options = {}) {
|
|
|
13498
13512
|
);
|
|
13499
13513
|
}
|
|
13500
13514
|
return stacks.map((stack2) => {
|
|
13501
|
-
var
|
|
13515
|
+
var _a3;
|
|
13502
13516
|
if (options.getFileName) {
|
|
13503
13517
|
stack2.file = options.getFileName(stack2.file);
|
|
13504
13518
|
}
|
|
13505
|
-
const map = (
|
|
13519
|
+
const map = (_a3 = options.getSourceMap) == null ? void 0 : _a3.call(options, stack2.file);
|
|
13506
13520
|
if (!map || typeof map !== "object" || !map.version) {
|
|
13507
13521
|
return stack2;
|
|
13508
13522
|
}
|
|
@@ -13578,13 +13592,13 @@ function createBrowserRunner(runnerClass, mocker, state, coverageModule) {
|
|
|
13578
13592
|
__publicField(this, "hashMap", browserHashMap);
|
|
13579
13593
|
__publicField(this, "sourceMapCache", /* @__PURE__ */ new Map());
|
|
13580
13594
|
__publicField(this, "onBeforeTryTask", async (...args) => {
|
|
13581
|
-
var
|
|
13595
|
+
var _a3;
|
|
13582
13596
|
await userEvent.cleanup();
|
|
13583
|
-
await ((
|
|
13597
|
+
await ((_a3 = super.onBeforeTryTask) == null ? void 0 : _a3.call(this, ...args));
|
|
13584
13598
|
});
|
|
13585
13599
|
__publicField(this, "onAfterRunTask", async (task) => {
|
|
13586
|
-
var
|
|
13587
|
-
await ((
|
|
13600
|
+
var _a3, _b;
|
|
13601
|
+
await ((_a3 = super.onAfterRunTask) == null ? void 0 : _a3.call(this, task));
|
|
13588
13602
|
if (this.config.bail && ((_b = task.result) == null ? void 0 : _b.state) === "fail") {
|
|
13589
13603
|
const previousFailures = await rpc$1().getCountOfFailedTests();
|
|
13590
13604
|
const currentFailures = 1 + previousFailures;
|
|
@@ -13595,8 +13609,8 @@ function createBrowserRunner(runnerClass, mocker, state, coverageModule) {
|
|
|
13595
13609
|
}
|
|
13596
13610
|
});
|
|
13597
13611
|
__publicField(this, "onTaskFinished", async (task) => {
|
|
13598
|
-
var
|
|
13599
|
-
if (this.config.browser.screenshotFailures && document.body.clientHeight > 0 && ((
|
|
13612
|
+
var _a3;
|
|
13613
|
+
if (this.config.browser.screenshotFailures && document.body.clientHeight > 0 && ((_a3 = task.result) == null ? void 0 : _a3.state) === "fail") {
|
|
13600
13614
|
const screenshot = await page.screenshot().catch((err) => {
|
|
13601
13615
|
console.error("[vitest] Failed to take a screenshot", err);
|
|
13602
13616
|
});
|
|
@@ -13606,14 +13620,14 @@ function createBrowserRunner(runnerClass, mocker, state, coverageModule) {
|
|
|
13606
13620
|
}
|
|
13607
13621
|
});
|
|
13608
13622
|
__publicField(this, "onCancel", (reason) => {
|
|
13609
|
-
var
|
|
13610
|
-
(
|
|
13623
|
+
var _a3;
|
|
13624
|
+
(_a3 = super.onCancel) == null ? void 0 : _a3.call(this, reason);
|
|
13611
13625
|
globalChannel.postMessage({ type: "cancel", reason });
|
|
13612
13626
|
});
|
|
13613
13627
|
__publicField(this, "onBeforeRunSuite", async (suite) => {
|
|
13614
|
-
var
|
|
13628
|
+
var _a3;
|
|
13615
13629
|
await Promise.all([
|
|
13616
|
-
(
|
|
13630
|
+
(_a3 = super.onBeforeRunSuite) == null ? void 0 : _a3.call(this, suite),
|
|
13617
13631
|
(async () => {
|
|
13618
13632
|
if ("filepath" in suite) {
|
|
13619
13633
|
const map = await rpc$1().getBrowserFileSourceMap(suite.filepath);
|
|
@@ -13627,9 +13641,9 @@ function createBrowserRunner(runnerClass, mocker, state, coverageModule) {
|
|
|
13627
13641
|
]);
|
|
13628
13642
|
});
|
|
13629
13643
|
__publicField(this, "onAfterRunFiles", async (files) => {
|
|
13630
|
-
var
|
|
13644
|
+
var _a3, _b;
|
|
13631
13645
|
const [coverage] = await Promise.all([
|
|
13632
|
-
(
|
|
13646
|
+
(_a3 = coverageModule == null ? void 0 : coverageModule.takeCoverage) == null ? void 0 : _a3.call(coverageModule),
|
|
13633
13647
|
mocker.invalidate(),
|
|
13634
13648
|
(_b = super.onAfterRunFiles) == null ? void 0 : _b.call(this, files)
|
|
13635
13649
|
]);
|
|
@@ -13774,8 +13788,8 @@ async function prepareTestEnvironment(files) {
|
|
|
13774
13788
|
}
|
|
13775
13789
|
});
|
|
13776
13790
|
onCancel.then((reason) => {
|
|
13777
|
-
var
|
|
13778
|
-
(
|
|
13791
|
+
var _a3;
|
|
13792
|
+
(_a3 = runner.onCancel) == null ? void 0 : _a3.call(runner, reason);
|
|
13779
13793
|
});
|
|
13780
13794
|
return {
|
|
13781
13795
|
runner,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
var _a;
|
|
1
2
|
(function polyfill() {
|
|
2
3
|
const relList = document.createElement("link").relList;
|
|
3
4
|
if (relList && relList.supports && relList.supports("modulepreload")) {
|
|
@@ -44,6 +45,7 @@ function normalizeWindowsPath(input = "") {
|
|
|
44
45
|
}
|
|
45
46
|
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
46
47
|
const _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
|
|
48
|
+
((_a = globalThis.process) == null ? void 0 : _a.platform) === "win32" ? ";" : ":";
|
|
47
49
|
function cwd() {
|
|
48
50
|
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
|
49
51
|
return process.cwd().replace(/\\/g, "/");
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
{__VITEST_INJECTOR__}
|
|
27
27
|
{__VITEST_ERROR_CATCHER__}
|
|
28
28
|
{__VITEST_SCRIPTS__}
|
|
29
|
-
<script type="module" crossorigin src="/__vitest_browser__/orchestrator-
|
|
30
|
-
<link rel="modulepreload" crossorigin href="/__vitest_browser__/utils-
|
|
29
|
+
<script type="module" crossorigin src="/__vitest_browser__/orchestrator-Cv-bzUFk.js"></script>
|
|
30
|
+
<link rel="modulepreload" crossorigin href="/__vitest_browser__/utils-CaCTRFti.js">
|
|
31
31
|
</head>
|
|
32
32
|
<body>
|
|
33
33
|
<div id="vitest-tester"></div>
|
|
@@ -5,8 +5,8 @@
|
|
|
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-
|
|
9
|
-
<link rel="modulepreload" crossorigin href="/__vitest_browser__/utils-
|
|
8
|
+
<script type="module" crossorigin src="/__vitest_browser__/tester-DreAh6ar.js"></script>
|
|
9
|
+
<link rel="modulepreload" crossorigin href="/__vitest_browser__/utils-CaCTRFti.js">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
|
12
12
|
</body>
|
package/dist/client.js
CHANGED
|
@@ -201,9 +201,9 @@ const parse = (text, reviver) => {
|
|
|
201
201
|
* @returns {string}
|
|
202
202
|
*/
|
|
203
203
|
const stringify = (value, replacer, space) => {
|
|
204
|
-
const $ =
|
|
204
|
+
const $ = typeof replacer === object ?
|
|
205
205
|
(k, v) => (k === '' || -1 < replacer.indexOf(k) ? v : void 0) :
|
|
206
|
-
(replacer
|
|
206
|
+
(replacer);
|
|
207
207
|
const known = new Map;
|
|
208
208
|
const input = [];
|
|
209
209
|
const output = [];
|
package/dist/context.js
CHANGED
|
@@ -129,7 +129,8 @@ function createUserEvent(__tl_user_event_base__, options) {
|
|
|
129
129
|
const keyboard = {
|
|
130
130
|
unreleased: []
|
|
131
131
|
};
|
|
132
|
-
|
|
132
|
+
const modifier = provider === `playwright` ? "ControlOrMeta" : provider === "webdriverio" ? "Ctrl" : "Control";
|
|
133
|
+
const userEvent = {
|
|
133
134
|
setup() {
|
|
134
135
|
return createUserEvent();
|
|
135
136
|
},
|
|
@@ -199,11 +200,22 @@ function createUserEvent(__tl_user_event_base__, options) {
|
|
|
199
200
|
);
|
|
200
201
|
keyboard.unreleased = unreleased;
|
|
201
202
|
});
|
|
203
|
+
},
|
|
204
|
+
async copy() {
|
|
205
|
+
await userEvent.keyboard(`{${modifier}>}{c}{/${modifier}}`);
|
|
206
|
+
},
|
|
207
|
+
async cut() {
|
|
208
|
+
await userEvent.keyboard(`{${modifier}>}{x}{/${modifier}}`);
|
|
209
|
+
},
|
|
210
|
+
async paste() {
|
|
211
|
+
await userEvent.keyboard(`{${modifier}>}{v}{/${modifier}}`);
|
|
202
212
|
}
|
|
203
213
|
};
|
|
214
|
+
return userEvent;
|
|
204
215
|
}
|
|
205
216
|
function createPreviewUserEvent(userEventBase, options) {
|
|
206
217
|
let userEvent = userEventBase.setup(options);
|
|
218
|
+
let clipboardData;
|
|
207
219
|
function toElement(element) {
|
|
208
220
|
return element instanceof Element ? element : element.element();
|
|
209
221
|
}
|
|
@@ -271,6 +283,15 @@ function createPreviewUserEvent(userEventBase, options) {
|
|
|
271
283
|
},
|
|
272
284
|
async keyboard(text) {
|
|
273
285
|
await userEvent.keyboard(text);
|
|
286
|
+
},
|
|
287
|
+
async copy() {
|
|
288
|
+
clipboardData = await userEvent.copy();
|
|
289
|
+
},
|
|
290
|
+
async cut() {
|
|
291
|
+
clipboardData = await userEvent.cut();
|
|
292
|
+
},
|
|
293
|
+
async paste() {
|
|
294
|
+
await userEvent.paste(clipboardData);
|
|
274
295
|
}
|
|
275
296
|
};
|
|
276
297
|
for (const [name, fn] of Object.entries(vitestUserEvent)) {
|
|
@@ -235,6 +235,15 @@ class Locator {
|
|
|
235
235
|
all() {
|
|
236
236
|
return this.elements().map((element) => this.elementLocator(element));
|
|
237
237
|
}
|
|
238
|
+
nth(index) {
|
|
239
|
+
return this.locator(`nth=${index}`);
|
|
240
|
+
}
|
|
241
|
+
first() {
|
|
242
|
+
return this.nth(0);
|
|
243
|
+
}
|
|
244
|
+
last() {
|
|
245
|
+
return this.nth(-1);
|
|
246
|
+
}
|
|
238
247
|
toString() {
|
|
239
248
|
return this.selector;
|
|
240
249
|
}
|
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@ import { resolve as resolve$1, dirname as dirname$1, basename as basename$1, nor
|
|
|
16
16
|
import { WebSocketServer } from 'ws';
|
|
17
17
|
import * as nodeos from 'node:os';
|
|
18
18
|
|
|
19
|
-
var version = "3.0.0-beta.
|
|
19
|
+
var version = "3.0.0-beta.4";
|
|
20
20
|
|
|
21
21
|
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
22
22
|
function normalizeWindowsPath(input = "") {
|
|
@@ -30,6 +30,8 @@ const _UNC_REGEX = /^[/\\]{2}/;
|
|
|
30
30
|
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
31
31
|
const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
32
32
|
const _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
|
|
33
|
+
const _EXTNAME_RE = /.(\.[^./]+)$/;
|
|
34
|
+
globalThis.process?.platform === "win32" ? ";" : ":";
|
|
33
35
|
const normalize = function(path) {
|
|
34
36
|
if (path.length === 0) {
|
|
35
37
|
return ".";
|
|
@@ -59,24 +61,26 @@ const normalize = function(path) {
|
|
|
59
61
|
}
|
|
60
62
|
return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
|
|
61
63
|
};
|
|
62
|
-
const join = function(...
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
const join = function(...segments) {
|
|
65
|
+
let path = "";
|
|
66
|
+
for (const seg of segments) {
|
|
67
|
+
if (!seg) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (path.length > 0) {
|
|
71
|
+
const pathTrailing = path[path.length - 1] === "/";
|
|
72
|
+
const segLeading = seg[0] === "/";
|
|
73
|
+
const both = pathTrailing && segLeading;
|
|
74
|
+
if (both) {
|
|
75
|
+
path += seg.slice(1);
|
|
71
76
|
} else {
|
|
72
|
-
|
|
77
|
+
path += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
73
78
|
}
|
|
79
|
+
} else {
|
|
80
|
+
path += seg;
|
|
74
81
|
}
|
|
75
82
|
}
|
|
76
|
-
|
|
77
|
-
return ".";
|
|
78
|
-
}
|
|
79
|
-
return normalize(joined.replace(/\/\/+/g, "/"));
|
|
83
|
+
return normalize(path);
|
|
80
84
|
};
|
|
81
85
|
function cwd() {
|
|
82
86
|
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
|
@@ -164,7 +168,6 @@ function normalizeString(path, allowAboveRoot) {
|
|
|
164
168
|
const isAbsolute = function(p) {
|
|
165
169
|
return _IS_ABSOLUTE_RE.test(p);
|
|
166
170
|
};
|
|
167
|
-
const _EXTNAME_RE = /.(\.[^./]+)$/;
|
|
168
171
|
const extname = function(p) {
|
|
169
172
|
const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
|
|
170
173
|
return match && match[1] || "";
|
|
@@ -193,7 +196,15 @@ const dirname = function(p) {
|
|
|
193
196
|
return segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
|
194
197
|
};
|
|
195
198
|
const basename = function(p, extension) {
|
|
196
|
-
const
|
|
199
|
+
const segments = normalizeWindowsPath(p).split("/");
|
|
200
|
+
let lastSegment = "";
|
|
201
|
+
for (let i = segments.length - 1; i >= 0; i--) {
|
|
202
|
+
const val = segments[i];
|
|
203
|
+
if (val) {
|
|
204
|
+
lastSegment = val;
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
197
208
|
return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
|
|
198
209
|
};
|
|
199
210
|
|
|
@@ -688,7 +699,7 @@ var BrowserPlugin = (parentServer, base = "/") => {
|
|
|
688
699
|
name: "vitest:browser:tests",
|
|
689
700
|
enforce: "pre",
|
|
690
701
|
async config() {
|
|
691
|
-
const project = parentServer.
|
|
702
|
+
const project = parentServer.project;
|
|
692
703
|
const { testFiles: allTestFiles } = await project.globTestFiles();
|
|
693
704
|
const browserTestFiles = allTestFiles.filter(
|
|
694
705
|
(file) => getFilePoolName(project, file) === "browser"
|
|
@@ -877,7 +888,7 @@ var BrowserPlugin = (parentServer, base = "/") => {
|
|
|
877
888
|
name: "vitest:browser:in-source-tests",
|
|
878
889
|
transform(code, id) {
|
|
879
890
|
const project = parentServer.vitest.getProjectByName(parentServer.config.name);
|
|
880
|
-
if (!project.
|
|
891
|
+
if (!project._isCachedTestFile(id) || !code.includes("import.meta.vitest")) {
|
|
881
892
|
return;
|
|
882
893
|
}
|
|
883
894
|
const s = new MagicString(code, { filename: cleanUrl(id) });
|
|
@@ -2084,7 +2095,7 @@ const keyboardCleanup = async (context, state) => {
|
|
|
2084
2095
|
throw new TypeError(`Provider "${context.provider.name}" does not support keyboard api`);
|
|
2085
2096
|
}
|
|
2086
2097
|
};
|
|
2087
|
-
const VALID_KEYS = /* @__PURE__ */ new Set(["Escape", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "Backquote", "`", "~", "Digit1", "1", "!", "Digit2", "2", "@", "Digit3", "3", "#", "Digit4", "4", "$", "Digit5", "5", "%", "Digit6", "6", "^", "Digit7", "7", "&", "Digit8", "8", "*", "Digit9", "9", "(", "Digit0", "0", ")", "Minus", "-", "_", "Equal", "=", "+", "Backslash", "\\", "|", "Backspace", "Tab", "KeyQ", "q", "Q", "KeyW", "w", "W", "KeyE", "e", "E", "KeyR", "r", "R", "KeyT", "t", "T", "KeyY", "y", "Y", "KeyU", "u", "U", "KeyI", "i", "I", "KeyO", "o", "O", "KeyP", "p", "P", "BracketLeft", "[", "{", "BracketRight", "]", "}", "CapsLock", "KeyA", "a", "A", "KeyS", "s", "S", "KeyD", "d", "D", "KeyF", "f", "F", "KeyG", "g", "G", "KeyH", "h", "H", "KeyJ", "j", "J", "KeyK", "k", "K", "KeyL", "l", "L", "Semicolon", ";", ":", "Quote", "'", '"', "Enter", "\n", "\r", "ShiftLeft", "Shift", "KeyZ", "z", "Z", "KeyX", "x", "X", "KeyC", "c", "C", "KeyV", "v", "V", "KeyB", "b", "B", "KeyN", "n", "N", "KeyM", "m", "M", "Comma", ",", "<", "Period", ".", ">", "Slash", "/", "?", "ShiftRight", "ControlLeft", "Control", "MetaLeft", "Meta", "AltLeft", "Alt", "Space", " ", "AltRight", "AltGraph", "MetaRight", "ContextMenu", "ControlRight", "PrintScreen", "ScrollLock", "Pause", "PageUp", "PageDown", "Insert", "Delete", "Home", "End", "ArrowLeft", "ArrowUp", "ArrowRight", "ArrowDown", "NumLock", "NumpadDivide", "NumpadMultiply", "NumpadSubtract", "Numpad7", "Numpad8", "Numpad9", "Numpad4", "Numpad5", "Numpad6", "NumpadAdd", "Numpad1", "Numpad2", "Numpad3", "Numpad0", "NumpadDecimal", "NumpadEnter"]);
|
|
2098
|
+
const VALID_KEYS = /* @__PURE__ */ new Set(["Escape", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "Backquote", "`", "~", "Digit1", "1", "!", "Digit2", "2", "@", "Digit3", "3", "#", "Digit4", "4", "$", "Digit5", "5", "%", "Digit6", "6", "^", "Digit7", "7", "&", "Digit8", "8", "*", "Digit9", "9", "(", "Digit0", "0", ")", "Minus", "-", "_", "Equal", "=", "+", "Backslash", "\\", "|", "Backspace", "Tab", "KeyQ", "q", "Q", "KeyW", "w", "W", "KeyE", "e", "E", "KeyR", "r", "R", "KeyT", "t", "T", "KeyY", "y", "Y", "KeyU", "u", "U", "KeyI", "i", "I", "KeyO", "o", "O", "KeyP", "p", "P", "BracketLeft", "[", "{", "BracketRight", "]", "}", "CapsLock", "KeyA", "a", "A", "KeyS", "s", "S", "KeyD", "d", "D", "KeyF", "f", "F", "KeyG", "g", "G", "KeyH", "h", "H", "KeyJ", "j", "J", "KeyK", "k", "K", "KeyL", "l", "L", "Semicolon", ";", ":", "Quote", "'", '"', "Enter", "\n", "\r", "ShiftLeft", "Shift", "KeyZ", "z", "Z", "KeyX", "x", "X", "KeyC", "c", "C", "KeyV", "v", "V", "KeyB", "b", "B", "KeyN", "n", "N", "KeyM", "m", "M", "Comma", ",", "<", "Period", ".", ">", "Slash", "/", "?", "ShiftRight", "ControlLeft", "Control", "MetaLeft", "Meta", "AltLeft", "Alt", "Space", " ", "AltRight", "AltGraph", "MetaRight", "ContextMenu", "ControlRight", "PrintScreen", "ScrollLock", "Pause", "PageUp", "PageDown", "Insert", "Delete", "Home", "End", "ArrowLeft", "ArrowUp", "ArrowRight", "ArrowDown", "NumLock", "NumpadDivide", "NumpadMultiply", "NumpadSubtract", "Numpad7", "Numpad8", "Numpad9", "Numpad4", "Numpad5", "Numpad6", "NumpadAdd", "Numpad1", "Numpad2", "Numpad3", "Numpad0", "NumpadDecimal", "NumpadEnter", "ControlOrMeta"]);
|
|
2088
2099
|
async function keyboardImplementation(pressed, provider, sessionId, text, selectAll2, skipRelease) {
|
|
2089
2100
|
if (provider instanceof PlaywrightBrowserProvider) {
|
|
2090
2101
|
const page = provider.getPage(sessionId);
|
|
@@ -2132,8 +2143,7 @@ async function keyboardImplementation(pressed, provider, sessionId, text, select
|
|
|
2132
2143
|
let keyboard2 = browser.action("key");
|
|
2133
2144
|
for (const { releasePrevious, releaseSelf, repeat, keyDef } of actions) {
|
|
2134
2145
|
let key = keyDef.key;
|
|
2135
|
-
const
|
|
2136
|
-
const special = Key[code];
|
|
2146
|
+
const special = Key[key];
|
|
2137
2147
|
if (special) {
|
|
2138
2148
|
key = special;
|
|
2139
2149
|
}
|
package/dist/locators/index.d.ts
CHANGED
|
@@ -253,6 +253,9 @@ declare abstract class Locator {
|
|
|
253
253
|
element(): Element;
|
|
254
254
|
elements(): Element[];
|
|
255
255
|
all(): Locator[];
|
|
256
|
+
nth(index: number): Locator;
|
|
257
|
+
first(): Locator;
|
|
258
|
+
last(): Locator;
|
|
256
259
|
toString(): string;
|
|
257
260
|
toJSON(): string;
|
|
258
261
|
private get state();
|
package/dist/locators/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { page, server } from '@vitest/browser/context';
|
|
2
2
|
import { g as getByLabelSelector, a as getByRoleSelector, b as getByTestIdSelector, c as getByAltTextSelector, d as getByPlaceholderSelector, e as getByTextSelector, f as getByTitleSelector } from '../public-utils-D6S2-5kI.js';
|
|
3
|
-
import { s as selectorEngine, L as Locator } from '../index-
|
|
3
|
+
import { s as selectorEngine, L as Locator } from '../index-Dos_sf7B.js';
|
|
4
4
|
import 'vitest/utils';
|
|
5
5
|
|
|
6
6
|
page.extend({
|
package/dist/locators/preview.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { page, server, userEvent } from '@vitest/browser/context';
|
|
2
2
|
import { g as getByLabelSelector, a as getByRoleSelector, b as getByTestIdSelector, c as getByAltTextSelector, d as getByPlaceholderSelector, e as getByTextSelector, f as getByTitleSelector, h as getElementError } from '../public-utils-D6S2-5kI.js';
|
|
3
|
-
import { s as selectorEngine, L as Locator, c as convertElementToCssSelector } from '../index-
|
|
3
|
+
import { s as selectorEngine, L as Locator, c as convertElementToCssSelector } from '../index-Dos_sf7B.js';
|
|
4
4
|
import 'vitest/utils';
|
|
5
5
|
|
|
6
6
|
page.extend({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { page, server } from '@vitest/browser/context';
|
|
2
2
|
import { g as getByLabelSelector, a as getByRoleSelector, b as getByTestIdSelector, c as getByAltTextSelector, d as getByPlaceholderSelector, e as getByTextSelector, f as getByTitleSelector, h as getElementError } from '../public-utils-D6S2-5kI.js';
|
|
3
|
-
import { s as selectorEngine, L as Locator, c as convertElementToCssSelector } from '../index-
|
|
3
|
+
import { s as selectorEngine, L as Locator, c as convertElementToCssSelector } from '../index-Dos_sf7B.js';
|
|
4
4
|
import 'vitest/utils';
|
|
5
5
|
|
|
6
6
|
page.extend({
|