@vitest/browser 4.0.0-beta.2 → 4.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 +123 -0
- package/dist/client/.vite/manifest.json +6 -6
- package/dist/client/__vitest__/assets/index-YGltZS-e.js +57 -0
- package/dist/client/__vitest__/index.html +1 -1
- package/dist/client/__vitest_browser__/{orchestrator-CQgVbcQq.js → orchestrator-BXzaDpYw.js} +244 -253
- package/dist/client/__vitest_browser__/{tester-BScMoGFI.js → tester-DabNvcOf.js} +200 -493
- package/dist/client/__vitest_browser__/{utils-Owv5OOOf.js → utils-BNwnRrZR.js} +8 -4
- package/dist/client/orchestrator.html +2 -2
- package/dist/client/tester/tester.html +2 -2
- package/dist/client.js +24 -8
- package/dist/expect-element.js +5 -3
- package/dist/{index-W1MM53zC.js → index-D_g_FMM5.js} +1 -1
- package/dist/index.d.ts +16 -7
- package/dist/index.js +511 -43
- package/dist/locators/index.d.ts +3 -3
- 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/dist/providers.js +1 -1
- package/dist/shared/screenshotMatcher/types.d.ts +13 -0
- package/dist/types.d.ts +5 -5
- package/dist/{webdriver-KA1WiV0q.js → webdriver-AHRa6U3j.js} +21 -11
- package/jest-dom.d.ts +94 -0
- package/package.json +18 -15
- package/providers/playwright.d.ts +13 -0
- package/providers/webdriverio.d.ts +13 -0
- package/dist/client/__vitest__/assets/index-Cil7RPEC.js +0 -58
|
@@ -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-YGltZS-e.js"></script>
|
|
27
27
|
<link rel="stylesheet" href="./assets/index-KbpJLW--.css">
|
|
28
28
|
</head>
|
|
29
29
|
<body>
|
package/dist/client/__vitest_browser__/{orchestrator-CQgVbcQq.js → orchestrator-BXzaDpYw.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
|
|
4
|
+
import { g as getDefaultExportFromCjs, a as getBrowserState, b as getConfig, r as relative } from "./utils-BNwnRrZR.js";
|
|
5
5
|
import { channel, globalChannel, client } from "@vitest/browser/client";
|
|
6
6
|
var f = {
|
|
7
7
|
reset: [0, 0],
|
|
@@ -1235,219 +1235,6 @@ function getSafeTimers() {
|
|
|
1235
1235
|
queueMicrotask: safeQueueMicrotask
|
|
1236
1236
|
};
|
|
1237
1237
|
}
|
|
1238
|
-
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
1239
|
-
const intToChar = new Uint8Array(64);
|
|
1240
|
-
const charToInt = new Uint8Array(128);
|
|
1241
|
-
for (let i = 0; i < chars.length; i++) {
|
|
1242
|
-
const c = chars.charCodeAt(i);
|
|
1243
|
-
intToChar[i] = c;
|
|
1244
|
-
charToInt[c] = i;
|
|
1245
|
-
}
|
|
1246
|
-
var UrlType;
|
|
1247
|
-
(function(UrlType2) {
|
|
1248
|
-
UrlType2[UrlType2["Empty"] = 1] = "Empty";
|
|
1249
|
-
UrlType2[UrlType2["Hash"] = 2] = "Hash";
|
|
1250
|
-
UrlType2[UrlType2["Query"] = 3] = "Query";
|
|
1251
|
-
UrlType2[UrlType2["RelativePath"] = 4] = "RelativePath";
|
|
1252
|
-
UrlType2[UrlType2["AbsolutePath"] = 5] = "AbsolutePath";
|
|
1253
|
-
UrlType2[UrlType2["SchemeRelative"] = 6] = "SchemeRelative";
|
|
1254
|
-
UrlType2[UrlType2["Absolute"] = 7] = "Absolute";
|
|
1255
|
-
})(UrlType || (UrlType = {}));
|
|
1256
|
-
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
1257
|
-
function normalizeWindowsPath(input = "") {
|
|
1258
|
-
if (!input) {
|
|
1259
|
-
return input;
|
|
1260
|
-
}
|
|
1261
|
-
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
1262
|
-
}
|
|
1263
|
-
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
1264
|
-
function cwd() {
|
|
1265
|
-
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
|
1266
|
-
return process.cwd().replace(/\\/g, "/");
|
|
1267
|
-
}
|
|
1268
|
-
return "/";
|
|
1269
|
-
}
|
|
1270
|
-
const resolve = function(...arguments_) {
|
|
1271
|
-
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
1272
|
-
let resolvedPath = "";
|
|
1273
|
-
let resolvedAbsolute = false;
|
|
1274
|
-
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
1275
|
-
const path = index >= 0 ? arguments_[index] : cwd();
|
|
1276
|
-
if (!path || path.length === 0) {
|
|
1277
|
-
continue;
|
|
1278
|
-
}
|
|
1279
|
-
resolvedPath = `${path}/${resolvedPath}`;
|
|
1280
|
-
resolvedAbsolute = isAbsolute(path);
|
|
1281
|
-
}
|
|
1282
|
-
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
1283
|
-
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
|
|
1284
|
-
return `/${resolvedPath}`;
|
|
1285
|
-
}
|
|
1286
|
-
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
1287
|
-
};
|
|
1288
|
-
function normalizeString(path, allowAboveRoot) {
|
|
1289
|
-
let res = "";
|
|
1290
|
-
let lastSegmentLength = 0;
|
|
1291
|
-
let lastSlash = -1;
|
|
1292
|
-
let dots = 0;
|
|
1293
|
-
let char = null;
|
|
1294
|
-
for (let index = 0; index <= path.length; ++index) {
|
|
1295
|
-
if (index < path.length) {
|
|
1296
|
-
char = path[index];
|
|
1297
|
-
} else if (char === "/") {
|
|
1298
|
-
break;
|
|
1299
|
-
} else {
|
|
1300
|
-
char = "/";
|
|
1301
|
-
}
|
|
1302
|
-
if (char === "/") {
|
|
1303
|
-
if (lastSlash === index - 1 || dots === 1) ;
|
|
1304
|
-
else if (dots === 2) {
|
|
1305
|
-
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
1306
|
-
if (res.length > 2) {
|
|
1307
|
-
const lastSlashIndex = res.lastIndexOf("/");
|
|
1308
|
-
if (lastSlashIndex === -1) {
|
|
1309
|
-
res = "";
|
|
1310
|
-
lastSegmentLength = 0;
|
|
1311
|
-
} else {
|
|
1312
|
-
res = res.slice(0, lastSlashIndex);
|
|
1313
|
-
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
1314
|
-
}
|
|
1315
|
-
lastSlash = index;
|
|
1316
|
-
dots = 0;
|
|
1317
|
-
continue;
|
|
1318
|
-
} else if (res.length > 0) {
|
|
1319
|
-
res = "";
|
|
1320
|
-
lastSegmentLength = 0;
|
|
1321
|
-
lastSlash = index;
|
|
1322
|
-
dots = 0;
|
|
1323
|
-
continue;
|
|
1324
|
-
}
|
|
1325
|
-
}
|
|
1326
|
-
if (allowAboveRoot) {
|
|
1327
|
-
res += res.length > 0 ? "/.." : "..";
|
|
1328
|
-
lastSegmentLength = 2;
|
|
1329
|
-
}
|
|
1330
|
-
} else {
|
|
1331
|
-
if (res.length > 0) {
|
|
1332
|
-
res += `/${path.slice(lastSlash + 1, index)}`;
|
|
1333
|
-
} else {
|
|
1334
|
-
res = path.slice(lastSlash + 1, index);
|
|
1335
|
-
}
|
|
1336
|
-
lastSegmentLength = index - lastSlash - 1;
|
|
1337
|
-
}
|
|
1338
|
-
lastSlash = index;
|
|
1339
|
-
dots = 0;
|
|
1340
|
-
} else if (char === "." && dots !== -1) {
|
|
1341
|
-
++dots;
|
|
1342
|
-
} else {
|
|
1343
|
-
dots = -1;
|
|
1344
|
-
}
|
|
1345
|
-
}
|
|
1346
|
-
return res;
|
|
1347
|
-
}
|
|
1348
|
-
const isAbsolute = function(p2) {
|
|
1349
|
-
return _IS_ABSOLUTE_RE.test(p2);
|
|
1350
|
-
};
|
|
1351
|
-
const CHROME_IE_STACK_REGEXP = /^\s*at .*(?:\S:\d+|\(native\))/m;
|
|
1352
|
-
const SAFARI_NATIVE_CODE_REGEXP = /^(?:eval@)?(?:\[native code\])?$/;
|
|
1353
|
-
function extractLocation(urlLike) {
|
|
1354
|
-
if (!urlLike.includes(":")) {
|
|
1355
|
-
return [urlLike];
|
|
1356
|
-
}
|
|
1357
|
-
const regExp = /(.+?)(?::(\d+))?(?::(\d+))?$/;
|
|
1358
|
-
const parts = regExp.exec(urlLike.replace(/^\(|\)$/g, ""));
|
|
1359
|
-
if (!parts) {
|
|
1360
|
-
return [urlLike];
|
|
1361
|
-
}
|
|
1362
|
-
let url = parts[1];
|
|
1363
|
-
if (url.startsWith("async ")) {
|
|
1364
|
-
url = url.slice(6);
|
|
1365
|
-
}
|
|
1366
|
-
if (url.startsWith("http:") || url.startsWith("https:")) {
|
|
1367
|
-
const urlObj = new URL(url);
|
|
1368
|
-
urlObj.searchParams.delete("import");
|
|
1369
|
-
urlObj.searchParams.delete("browserv");
|
|
1370
|
-
url = urlObj.pathname + urlObj.hash + urlObj.search;
|
|
1371
|
-
}
|
|
1372
|
-
if (url.startsWith("/@fs/")) {
|
|
1373
|
-
const isWindows = /^\/@fs\/[a-zA-Z]:\//.test(url);
|
|
1374
|
-
url = url.slice(isWindows ? 5 : 4);
|
|
1375
|
-
}
|
|
1376
|
-
return [
|
|
1377
|
-
url,
|
|
1378
|
-
parts[2] || void 0,
|
|
1379
|
-
parts[3] || void 0
|
|
1380
|
-
];
|
|
1381
|
-
}
|
|
1382
|
-
function parseSingleFFOrSafariStack(raw) {
|
|
1383
|
-
let line = raw.trim();
|
|
1384
|
-
if (SAFARI_NATIVE_CODE_REGEXP.test(line)) {
|
|
1385
|
-
return null;
|
|
1386
|
-
}
|
|
1387
|
-
if (line.includes(" > eval")) {
|
|
1388
|
-
line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ":$1");
|
|
1389
|
-
}
|
|
1390
|
-
if (!line.includes("@") && !line.includes(":")) {
|
|
1391
|
-
return null;
|
|
1392
|
-
}
|
|
1393
|
-
const functionNameRegex = /((.*".+"[^@]*)?[^@]*)(@)/;
|
|
1394
|
-
const matches = line.match(functionNameRegex);
|
|
1395
|
-
const functionName = matches && matches[1] ? matches[1] : void 0;
|
|
1396
|
-
const [url, lineNumber, columnNumber] = extractLocation(line.replace(functionNameRegex, ""));
|
|
1397
|
-
if (!url || !lineNumber || !columnNumber) {
|
|
1398
|
-
return null;
|
|
1399
|
-
}
|
|
1400
|
-
return {
|
|
1401
|
-
file: url,
|
|
1402
|
-
method: functionName || "",
|
|
1403
|
-
line: Number.parseInt(lineNumber),
|
|
1404
|
-
column: Number.parseInt(columnNumber)
|
|
1405
|
-
};
|
|
1406
|
-
}
|
|
1407
|
-
function parseSingleStack(raw) {
|
|
1408
|
-
const line = raw.trim();
|
|
1409
|
-
if (!CHROME_IE_STACK_REGEXP.test(line)) {
|
|
1410
|
-
return parseSingleFFOrSafariStack(line);
|
|
1411
|
-
}
|
|
1412
|
-
return parseSingleV8Stack(line);
|
|
1413
|
-
}
|
|
1414
|
-
function parseSingleV8Stack(raw) {
|
|
1415
|
-
let line = raw.trim();
|
|
1416
|
-
if (!CHROME_IE_STACK_REGEXP.test(line)) {
|
|
1417
|
-
return null;
|
|
1418
|
-
}
|
|
1419
|
-
if (line.includes("(eval ")) {
|
|
1420
|
-
line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, "");
|
|
1421
|
-
}
|
|
1422
|
-
let sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, "");
|
|
1423
|
-
const location = sanitizedLine.match(/ (\(.+\)$)/);
|
|
1424
|
-
sanitizedLine = location ? sanitizedLine.replace(location[0], "") : sanitizedLine;
|
|
1425
|
-
const [url, lineNumber, columnNumber] = extractLocation(location ? location[1] : sanitizedLine);
|
|
1426
|
-
let method = location && sanitizedLine || "";
|
|
1427
|
-
let file = url && ["eval", "<anonymous>"].includes(url) ? void 0 : url;
|
|
1428
|
-
if (!file || !lineNumber || !columnNumber) {
|
|
1429
|
-
return null;
|
|
1430
|
-
}
|
|
1431
|
-
if (method.startsWith("async ")) {
|
|
1432
|
-
method = method.slice(6);
|
|
1433
|
-
}
|
|
1434
|
-
if (file.startsWith("file://")) {
|
|
1435
|
-
file = file.slice(7);
|
|
1436
|
-
}
|
|
1437
|
-
file = file.startsWith("node:") || file.startsWith("internal:") ? file : resolve(file);
|
|
1438
|
-
if (method) {
|
|
1439
|
-
method = method.replace(/__vite_ssr_import_\d+__\./g, "");
|
|
1440
|
-
}
|
|
1441
|
-
return {
|
|
1442
|
-
method,
|
|
1443
|
-
file,
|
|
1444
|
-
line: Number.parseInt(lineNumber),
|
|
1445
|
-
column: Number.parseInt(columnNumber)
|
|
1446
|
-
};
|
|
1447
|
-
}
|
|
1448
|
-
function getDefaultExportFromCjs(x) {
|
|
1449
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
1450
|
-
}
|
|
1451
1238
|
var jsTokens_1;
|
|
1452
1239
|
var hasRequiredJsTokens;
|
|
1453
1240
|
function requireJsTokens() {
|
|
@@ -1925,6 +1712,216 @@ function stripLiteral(code, options) {
|
|
|
1925
1712
|
function stripLiteralDetailed(code, options) {
|
|
1926
1713
|
return stripLiteralJsTokens(code);
|
|
1927
1714
|
}
|
|
1715
|
+
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
1716
|
+
const intToChar = new Uint8Array(64);
|
|
1717
|
+
const charToInt = new Uint8Array(128);
|
|
1718
|
+
for (let i = 0; i < chars.length; i++) {
|
|
1719
|
+
const c = chars.charCodeAt(i);
|
|
1720
|
+
intToChar[i] = c;
|
|
1721
|
+
charToInt[c] = i;
|
|
1722
|
+
}
|
|
1723
|
+
var UrlType;
|
|
1724
|
+
(function(UrlType2) {
|
|
1725
|
+
UrlType2[UrlType2["Empty"] = 1] = "Empty";
|
|
1726
|
+
UrlType2[UrlType2["Hash"] = 2] = "Hash";
|
|
1727
|
+
UrlType2[UrlType2["Query"] = 3] = "Query";
|
|
1728
|
+
UrlType2[UrlType2["RelativePath"] = 4] = "RelativePath";
|
|
1729
|
+
UrlType2[UrlType2["AbsolutePath"] = 5] = "AbsolutePath";
|
|
1730
|
+
UrlType2[UrlType2["SchemeRelative"] = 6] = "SchemeRelative";
|
|
1731
|
+
UrlType2[UrlType2["Absolute"] = 7] = "Absolute";
|
|
1732
|
+
})(UrlType || (UrlType = {}));
|
|
1733
|
+
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
1734
|
+
function normalizeWindowsPath(input = "") {
|
|
1735
|
+
if (!input) {
|
|
1736
|
+
return input;
|
|
1737
|
+
}
|
|
1738
|
+
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
1739
|
+
}
|
|
1740
|
+
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
1741
|
+
function cwd() {
|
|
1742
|
+
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
|
1743
|
+
return process.cwd().replace(/\\/g, "/");
|
|
1744
|
+
}
|
|
1745
|
+
return "/";
|
|
1746
|
+
}
|
|
1747
|
+
const resolve = function(...arguments_) {
|
|
1748
|
+
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
1749
|
+
let resolvedPath = "";
|
|
1750
|
+
let resolvedAbsolute = false;
|
|
1751
|
+
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
1752
|
+
const path = index >= 0 ? arguments_[index] : cwd();
|
|
1753
|
+
if (!path || path.length === 0) {
|
|
1754
|
+
continue;
|
|
1755
|
+
}
|
|
1756
|
+
resolvedPath = `${path}/${resolvedPath}`;
|
|
1757
|
+
resolvedAbsolute = isAbsolute(path);
|
|
1758
|
+
}
|
|
1759
|
+
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
1760
|
+
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
|
|
1761
|
+
return `/${resolvedPath}`;
|
|
1762
|
+
}
|
|
1763
|
+
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
1764
|
+
};
|
|
1765
|
+
function normalizeString(path, allowAboveRoot) {
|
|
1766
|
+
let res = "";
|
|
1767
|
+
let lastSegmentLength = 0;
|
|
1768
|
+
let lastSlash = -1;
|
|
1769
|
+
let dots = 0;
|
|
1770
|
+
let char = null;
|
|
1771
|
+
for (let index = 0; index <= path.length; ++index) {
|
|
1772
|
+
if (index < path.length) {
|
|
1773
|
+
char = path[index];
|
|
1774
|
+
} else if (char === "/") {
|
|
1775
|
+
break;
|
|
1776
|
+
} else {
|
|
1777
|
+
char = "/";
|
|
1778
|
+
}
|
|
1779
|
+
if (char === "/") {
|
|
1780
|
+
if (lastSlash === index - 1 || dots === 1) ;
|
|
1781
|
+
else if (dots === 2) {
|
|
1782
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
1783
|
+
if (res.length > 2) {
|
|
1784
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
1785
|
+
if (lastSlashIndex === -1) {
|
|
1786
|
+
res = "";
|
|
1787
|
+
lastSegmentLength = 0;
|
|
1788
|
+
} else {
|
|
1789
|
+
res = res.slice(0, lastSlashIndex);
|
|
1790
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
1791
|
+
}
|
|
1792
|
+
lastSlash = index;
|
|
1793
|
+
dots = 0;
|
|
1794
|
+
continue;
|
|
1795
|
+
} else if (res.length > 0) {
|
|
1796
|
+
res = "";
|
|
1797
|
+
lastSegmentLength = 0;
|
|
1798
|
+
lastSlash = index;
|
|
1799
|
+
dots = 0;
|
|
1800
|
+
continue;
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
if (allowAboveRoot) {
|
|
1804
|
+
res += res.length > 0 ? "/.." : "..";
|
|
1805
|
+
lastSegmentLength = 2;
|
|
1806
|
+
}
|
|
1807
|
+
} else {
|
|
1808
|
+
if (res.length > 0) {
|
|
1809
|
+
res += `/${path.slice(lastSlash + 1, index)}`;
|
|
1810
|
+
} else {
|
|
1811
|
+
res = path.slice(lastSlash + 1, index);
|
|
1812
|
+
}
|
|
1813
|
+
lastSegmentLength = index - lastSlash - 1;
|
|
1814
|
+
}
|
|
1815
|
+
lastSlash = index;
|
|
1816
|
+
dots = 0;
|
|
1817
|
+
} else if (char === "." && dots !== -1) {
|
|
1818
|
+
++dots;
|
|
1819
|
+
} else {
|
|
1820
|
+
dots = -1;
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
return res;
|
|
1824
|
+
}
|
|
1825
|
+
const isAbsolute = function(p2) {
|
|
1826
|
+
return _IS_ABSOLUTE_RE.test(p2);
|
|
1827
|
+
};
|
|
1828
|
+
const CHROME_IE_STACK_REGEXP = /^\s*at .*(?:\S:\d+|\(native\))/m;
|
|
1829
|
+
const SAFARI_NATIVE_CODE_REGEXP = /^(?:eval@)?(?:\[native code\])?$/;
|
|
1830
|
+
function extractLocation(urlLike) {
|
|
1831
|
+
if (!urlLike.includes(":")) {
|
|
1832
|
+
return [urlLike];
|
|
1833
|
+
}
|
|
1834
|
+
const regExp = /(.+?)(?::(\d+))?(?::(\d+))?$/;
|
|
1835
|
+
const parts = regExp.exec(urlLike.replace(/^\(|\)$/g, ""));
|
|
1836
|
+
if (!parts) {
|
|
1837
|
+
return [urlLike];
|
|
1838
|
+
}
|
|
1839
|
+
let url = parts[1];
|
|
1840
|
+
if (url.startsWith("async ")) {
|
|
1841
|
+
url = url.slice(6);
|
|
1842
|
+
}
|
|
1843
|
+
if (url.startsWith("http:") || url.startsWith("https:")) {
|
|
1844
|
+
const urlObj = new URL(url);
|
|
1845
|
+
urlObj.searchParams.delete("import");
|
|
1846
|
+
urlObj.searchParams.delete("browserv");
|
|
1847
|
+
url = urlObj.pathname + urlObj.hash + urlObj.search;
|
|
1848
|
+
}
|
|
1849
|
+
if (url.startsWith("/@fs/")) {
|
|
1850
|
+
const isWindows = /^\/@fs\/[a-zA-Z]:\//.test(url);
|
|
1851
|
+
url = url.slice(isWindows ? 5 : 4);
|
|
1852
|
+
}
|
|
1853
|
+
return [
|
|
1854
|
+
url,
|
|
1855
|
+
parts[2] || void 0,
|
|
1856
|
+
parts[3] || void 0
|
|
1857
|
+
];
|
|
1858
|
+
}
|
|
1859
|
+
function parseSingleFFOrSafariStack(raw) {
|
|
1860
|
+
let line = raw.trim();
|
|
1861
|
+
if (SAFARI_NATIVE_CODE_REGEXP.test(line)) {
|
|
1862
|
+
return null;
|
|
1863
|
+
}
|
|
1864
|
+
if (line.includes(" > eval")) {
|
|
1865
|
+
line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ":$1");
|
|
1866
|
+
}
|
|
1867
|
+
if (!line.includes("@") && !line.includes(":")) {
|
|
1868
|
+
return null;
|
|
1869
|
+
}
|
|
1870
|
+
const functionNameRegex = /((.*".+"[^@]*)?[^@]*)(@)/;
|
|
1871
|
+
const matches = line.match(functionNameRegex);
|
|
1872
|
+
const functionName = matches && matches[1] ? matches[1] : void 0;
|
|
1873
|
+
const [url, lineNumber, columnNumber] = extractLocation(line.replace(functionNameRegex, ""));
|
|
1874
|
+
if (!url || !lineNumber || !columnNumber) {
|
|
1875
|
+
return null;
|
|
1876
|
+
}
|
|
1877
|
+
return {
|
|
1878
|
+
file: url,
|
|
1879
|
+
method: functionName || "",
|
|
1880
|
+
line: Number.parseInt(lineNumber),
|
|
1881
|
+
column: Number.parseInt(columnNumber)
|
|
1882
|
+
};
|
|
1883
|
+
}
|
|
1884
|
+
function parseSingleStack(raw) {
|
|
1885
|
+
const line = raw.trim();
|
|
1886
|
+
if (!CHROME_IE_STACK_REGEXP.test(line)) {
|
|
1887
|
+
return parseSingleFFOrSafariStack(line);
|
|
1888
|
+
}
|
|
1889
|
+
return parseSingleV8Stack(line);
|
|
1890
|
+
}
|
|
1891
|
+
function parseSingleV8Stack(raw) {
|
|
1892
|
+
let line = raw.trim();
|
|
1893
|
+
if (!CHROME_IE_STACK_REGEXP.test(line)) {
|
|
1894
|
+
return null;
|
|
1895
|
+
}
|
|
1896
|
+
if (line.includes("(eval ")) {
|
|
1897
|
+
line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, "");
|
|
1898
|
+
}
|
|
1899
|
+
let sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, "");
|
|
1900
|
+
const location = sanitizedLine.match(/ (\(.+\)$)/);
|
|
1901
|
+
sanitizedLine = location ? sanitizedLine.replace(location[0], "") : sanitizedLine;
|
|
1902
|
+
const [url, lineNumber, columnNumber] = extractLocation(location ? location[1] : sanitizedLine);
|
|
1903
|
+
let method = location && sanitizedLine || "";
|
|
1904
|
+
let file = url && ["eval", "<anonymous>"].includes(url) ? void 0 : url;
|
|
1905
|
+
if (!file || !lineNumber || !columnNumber) {
|
|
1906
|
+
return null;
|
|
1907
|
+
}
|
|
1908
|
+
if (method.startsWith("async ")) {
|
|
1909
|
+
method = method.slice(6);
|
|
1910
|
+
}
|
|
1911
|
+
if (file.startsWith("file://")) {
|
|
1912
|
+
file = file.slice(7);
|
|
1913
|
+
}
|
|
1914
|
+
file = file.startsWith("node:") || file.startsWith("internal:") ? file : resolve(file);
|
|
1915
|
+
if (method) {
|
|
1916
|
+
method = method.replace(/__vite_ssr_import_\d+__\./g, "");
|
|
1917
|
+
}
|
|
1918
|
+
return {
|
|
1919
|
+
method,
|
|
1920
|
+
file,
|
|
1921
|
+
line: Number.parseInt(lineNumber),
|
|
1922
|
+
column: Number.parseInt(columnNumber)
|
|
1923
|
+
};
|
|
1924
|
+
}
|
|
1928
1925
|
class PendingError extends Error {
|
|
1929
1926
|
constructor(message, task, note) {
|
|
1930
1927
|
super(message);
|
|
@@ -2237,6 +2234,27 @@ function createChainable(keys, fn) {
|
|
|
2237
2234
|
chain.fn = fn;
|
|
2238
2235
|
return chain;
|
|
2239
2236
|
}
|
|
2237
|
+
function generateHash(str) {
|
|
2238
|
+
let hash = 0;
|
|
2239
|
+
if (str.length === 0) {
|
|
2240
|
+
return `${hash}`;
|
|
2241
|
+
}
|
|
2242
|
+
for (let i = 0; i < str.length; i++) {
|
|
2243
|
+
const char = str.charCodeAt(i);
|
|
2244
|
+
hash = (hash << 5) - hash + char;
|
|
2245
|
+
hash = hash & hash;
|
|
2246
|
+
}
|
|
2247
|
+
return `${hash}`;
|
|
2248
|
+
}
|
|
2249
|
+
function findTestFileStackTrace(testFilePath, error) {
|
|
2250
|
+
const lines = error.split("\n").slice(1);
|
|
2251
|
+
for (const line of lines) {
|
|
2252
|
+
const stack = parseSingleStack(line);
|
|
2253
|
+
if (stack && stack.file === testFilePath) {
|
|
2254
|
+
return stack;
|
|
2255
|
+
}
|
|
2256
|
+
}
|
|
2257
|
+
}
|
|
2240
2258
|
const suite = createSuite();
|
|
2241
2259
|
createTest(function(name, optionsOrFn, optionsOrTest) {
|
|
2242
2260
|
getCurrentSuite().test.fn.call(this, formatName(name), optionsOrFn, optionsOrTest);
|
|
@@ -2249,9 +2267,6 @@ function assert(condition, message) {
|
|
|
2249
2267
|
throw new Error(`Vitest failed to find ${message}. This is a bug in Vitest. Please, open an issue with reproduction.`);
|
|
2250
2268
|
}
|
|
2251
2269
|
}
|
|
2252
|
-
function getTestFilepath() {
|
|
2253
|
-
return currentTestFilepath;
|
|
2254
|
-
}
|
|
2255
2270
|
function getRunner() {
|
|
2256
2271
|
assert(runner, "the runner");
|
|
2257
2272
|
return runner;
|
|
@@ -2341,9 +2356,12 @@ function createSuiteCollector(name, factory = () => {
|
|
|
2341
2356
|
}
|
|
2342
2357
|
if (runner.config.includeTaskLocation) {
|
|
2343
2358
|
const error = stackTraceError.stack;
|
|
2344
|
-
const stack = findTestFileStackTrace(error);
|
|
2359
|
+
const stack = findTestFileStackTrace(currentTestFilepath, error);
|
|
2345
2360
|
if (stack) {
|
|
2346
|
-
task2.location =
|
|
2361
|
+
task2.location = {
|
|
2362
|
+
line: stack.line,
|
|
2363
|
+
column: stack.column
|
|
2364
|
+
};
|
|
2347
2365
|
}
|
|
2348
2366
|
}
|
|
2349
2367
|
tasks.push(task2);
|
|
@@ -2581,6 +2599,7 @@ function createTaskCollector(fn, context) {
|
|
|
2581
2599
|
const _context = mergeContextFixtures(fixtures, context || {}, runner);
|
|
2582
2600
|
const originalWrapper = fn;
|
|
2583
2601
|
return createTest(function(name, optionsOrFn, optionsOrTest) {
|
|
2602
|
+
var _collector$options;
|
|
2584
2603
|
const collector = getCurrentSuite();
|
|
2585
2604
|
const scopedFixtures = collector.fixtures();
|
|
2586
2605
|
const context2 = { ...this };
|
|
@@ -2588,7 +2607,7 @@ function createTaskCollector(fn, context) {
|
|
|
2588
2607
|
context2.fixtures = mergeScopedFixtures(context2.fixtures || [], scopedFixtures);
|
|
2589
2608
|
}
|
|
2590
2609
|
const { handler, options } = parseArguments(optionsOrFn, optionsOrTest);
|
|
2591
|
-
const timeout = options.timeout ?? void 0;
|
|
2610
|
+
const timeout = options.timeout ?? ((_collector$options = collector.options) === null || _collector$options === void 0 ? void 0 : _collector$options.timeout) ?? void 0;
|
|
2592
2611
|
originalWrapper.call(context2, formatName(name), handler, timeout);
|
|
2593
2612
|
}, _context);
|
|
2594
2613
|
};
|
|
@@ -2653,31 +2672,6 @@ function formatTemplateString(cases, args) {
|
|
|
2653
2672
|
}
|
|
2654
2673
|
return res;
|
|
2655
2674
|
}
|
|
2656
|
-
function findTestFileStackTrace(error) {
|
|
2657
|
-
const testFilePath = getTestFilepath();
|
|
2658
|
-
const lines = error.split("\n").slice(1);
|
|
2659
|
-
for (const line of lines) {
|
|
2660
|
-
const stack = parseSingleStack(line);
|
|
2661
|
-
if (stack && stack.file === testFilePath) {
|
|
2662
|
-
return {
|
|
2663
|
-
line: stack.line,
|
|
2664
|
-
column: stack.column
|
|
2665
|
-
};
|
|
2666
|
-
}
|
|
2667
|
-
}
|
|
2668
|
-
}
|
|
2669
|
-
function generateHash(str) {
|
|
2670
|
-
let hash = 0;
|
|
2671
|
-
if (str.length === 0) {
|
|
2672
|
-
return `${hash}`;
|
|
2673
|
-
}
|
|
2674
|
-
for (let i = 0; i < str.length; i++) {
|
|
2675
|
-
const char = str.charCodeAt(i);
|
|
2676
|
-
hash = (hash << 5) - hash + char;
|
|
2677
|
-
hash = hash & hash;
|
|
2678
|
-
}
|
|
2679
|
-
return `${hash}`;
|
|
2680
|
-
}
|
|
2681
2675
|
globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
|
|
2682
2676
|
globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
|
|
2683
2677
|
getSafeTimers();
|
|
@@ -2835,16 +2829,13 @@ function createTestContext(test, runner2) {
|
|
|
2835
2829
|
if (test.result && test.result.state !== "run") {
|
|
2836
2830
|
throw new Error(`Cannot annotate tests outside of the test run. The test "${test.name}" finished running with the "${test.result.state}" state already.`);
|
|
2837
2831
|
}
|
|
2832
|
+
const stack = findTestFileStackTrace(test.file.filepath, new Error("STACK_TRACE").stack);
|
|
2838
2833
|
let location;
|
|
2839
|
-
|
|
2840
|
-
const index = stack.includes("STACK_TRACE") ? 2 : 1;
|
|
2841
|
-
const stackLine = stack.split("\n")[index];
|
|
2842
|
-
const parsed = parseSingleStack(stackLine);
|
|
2843
|
-
if (parsed) {
|
|
2834
|
+
if (stack) {
|
|
2844
2835
|
location = {
|
|
2845
|
-
file:
|
|
2846
|
-
line:
|
|
2847
|
-
column:
|
|
2836
|
+
file: stack.file,
|
|
2837
|
+
line: stack.line,
|
|
2838
|
+
column: stack.column
|
|
2848
2839
|
};
|
|
2849
2840
|
}
|
|
2850
2841
|
if (typeof type === "object") {
|