@vitest/browser 3.2.2 → 3.2.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.
@@ -475,8 +475,18 @@ function inspectAttribute([key, value], options) {
475
475
  }
476
476
  return `${options.stylize(String(key), "yellow")}=${options.stylize(`"${value}"`, "string")}`;
477
477
  }
478
- function inspectHTMLCollection(collection, options) {
479
- return inspectList(collection, options, inspectHTML, "\n");
478
+ function inspectNodeCollection(collection, options) {
479
+ return inspectList(collection, options, inspectNode, "\n");
480
+ }
481
+ function inspectNode(node, options) {
482
+ switch (node.nodeType) {
483
+ case 1:
484
+ return inspectHTML(node, options);
485
+ case 3:
486
+ return options.inspect(node.data, options);
487
+ default:
488
+ return options.inspect(node, options);
489
+ }
480
490
  }
481
491
  function inspectHTML(element, options) {
482
492
  const properties = element.getAttributeNames();
@@ -492,7 +502,7 @@ function inspectHTML(element, options) {
492
502
  }
493
503
  options.truncate -= propertyContents.length;
494
504
  const truncate2 = options.truncate;
495
- let children = inspectHTMLCollection(element.children, options);
505
+ let children = inspectNodeCollection(element.children, options);
496
506
  if (children && children.length > truncate2) {
497
507
  children = `${truncator}(${element.children.length})`;
498
508
  }
@@ -500,13 +510,7 @@ function inspectHTML(element, options) {
500
510
  }
501
511
  const symbolsSupported = typeof Symbol === "function" && typeof Symbol.for === "function";
502
512
  const chaiInspect = symbolsSupported ? Symbol.for("chai/inspect") : "@@chai/inspect";
503
- let nodeInspect = false;
504
- try {
505
- const nodeUtil = require("util");
506
- nodeInspect = nodeUtil.inspect ? nodeUtil.inspect.custom : false;
507
- } catch (noNodeInspect) {
508
- nodeInspect = false;
509
- }
513
+ const nodeInspect = Symbol.for("nodejs.util.inspect.custom");
510
514
  const constructorMap = /* @__PURE__ */ new WeakMap();
511
515
  const stringTagMap = {};
512
516
  const baseTypesMap = {
@@ -548,14 +552,14 @@ const baseTypesMap = {
548
552
  DataView: () => "",
549
553
  ArrayBuffer: () => "",
550
554
  Error: inspectObject,
551
- HTMLCollection: inspectHTMLCollection,
552
- NodeList: inspectHTMLCollection
555
+ HTMLCollection: inspectNodeCollection,
556
+ NodeList: inspectNodeCollection
553
557
  };
554
558
  const inspectCustom = (value, options, type) => {
555
559
  if (chaiInspect in value && typeof value[chaiInspect] === "function") {
556
560
  return value[chaiInspect](options);
557
561
  }
558
- if (nodeInspect && nodeInspect in value && typeof value[nodeInspect] === "function") {
562
+ if (nodeInspect in value && typeof value[nodeInspect] === "function") {
559
563
  return value[nodeInspect](options.depth, options);
560
564
  }
561
565
  if ("inspect" in value && typeof value.inspect === "function") {
@@ -770,11 +774,11 @@ function isNegativeNaN(val) {
770
774
  const isNegative = u32[1] >>> 31 === 1;
771
775
  return isNegative;
772
776
  }
773
- var jsTokens_1;
774
- var hasRequiredJsTokens;
775
- function requireJsTokens() {
776
- if (hasRequiredJsTokens) return jsTokens_1;
777
- hasRequiredJsTokens = 1;
777
+ var jsTokens_1$1;
778
+ var hasRequiredJsTokens$1;
779
+ function requireJsTokens$1() {
780
+ if (hasRequiredJsTokens$1) return jsTokens_1$1;
781
+ hasRequiredJsTokens$1 = 1;
778
782
  var Identifier, JSXIdentifier, JSXPunctuator, JSXString, JSXText, KeywordsWithExpressionAfter, KeywordsWithNoLineTerminatorAfter, LineTerminatorSequence, MultiLineComment, Newline, NumericLiteral, Punctuator, RegularExpressionLiteral, SingleLineComment, StringLiteral, Template, TokensNotPrecedingObjectLiteral, TokensPrecedingExpression, WhiteSpace;
779
783
  RegularExpressionLiteral = /\/(?![*\/])(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\\]).|\\.)*(\/[$_\u200C\u200D\p{ID_Continue}]*|\\)?/yu;
780
784
  Punctuator = /--|\+\+|=>|\.{3}|\??\.(?!\d)|(?:&&|\|\||\?\?|[+\-%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2}|\/(?![\/*]))=?|[?~,:;[\](){}]/y;
@@ -795,7 +799,7 @@ function requireJsTokens() {
795
799
  KeywordsWithExpressionAfter = /^(?:await|case|default|delete|do|else|instanceof|new|return|throw|typeof|void|yield)$/;
796
800
  KeywordsWithNoLineTerminatorAfter = /^(?:return|throw|yield)$/;
797
801
  Newline = RegExp(LineTerminatorSequence.source);
798
- jsTokens_1 = function* (input, { jsx = false } = {}) {
802
+ jsTokens_1$1 = function* (input, { jsx = false } = {}) {
799
803
  var braces, firstCodePoint, isExpression, lastIndex, lastSignificantToken, length, match, mode, nextLastIndex, nextLastSignificantToken, parenNesting, postfixIncDec, punctuator, stack;
800
804
  ({ length } = input);
801
805
  lastIndex = 0;
@@ -1161,9 +1165,9 @@ function requireJsTokens() {
1161
1165
  }
1162
1166
  return void 0;
1163
1167
  };
1164
- return jsTokens_1;
1168
+ return jsTokens_1$1;
1165
1169
  }
1166
- requireJsTokens();
1170
+ requireJsTokens$1();
1167
1171
  var reservedWords = {
1168
1172
  keyword: [
1169
1173
  "break",
@@ -1355,22 +1359,22 @@ function extractLocation(urlLike) {
1355
1359
  if (!parts) {
1356
1360
  return [urlLike];
1357
1361
  }
1358
- let url2 = parts[1];
1359
- if (url2.startsWith("async ")) {
1360
- url2 = url2.slice(6);
1362
+ let url = parts[1];
1363
+ if (url.startsWith("async ")) {
1364
+ url = url.slice(6);
1361
1365
  }
1362
- if (url2.startsWith("http:") || url2.startsWith("https:")) {
1363
- const urlObj = new URL(url2);
1366
+ if (url.startsWith("http:") || url.startsWith("https:")) {
1367
+ const urlObj = new URL(url);
1364
1368
  urlObj.searchParams.delete("import");
1365
1369
  urlObj.searchParams.delete("browserv");
1366
- url2 = urlObj.pathname + urlObj.hash + urlObj.search;
1370
+ url = urlObj.pathname + urlObj.hash + urlObj.search;
1367
1371
  }
1368
- if (url2.startsWith("/@fs/")) {
1369
- const isWindows = /^\/@fs\/[a-zA-Z]:\//.test(url2);
1370
- url2 = url2.slice(isWindows ? 5 : 4);
1372
+ if (url.startsWith("/@fs/")) {
1373
+ const isWindows = /^\/@fs\/[a-zA-Z]:\//.test(url);
1374
+ url = url.slice(isWindows ? 5 : 4);
1371
1375
  }
1372
1376
  return [
1373
- url2,
1377
+ url,
1374
1378
  parts[2] || void 0,
1375
1379
  parts[3] || void 0
1376
1380
  ];
@@ -1389,12 +1393,12 @@ function parseSingleFFOrSafariStack(raw) {
1389
1393
  const functionNameRegex = /((.*".+"[^@]*)?[^@]*)(@)/;
1390
1394
  const matches = line.match(functionNameRegex);
1391
1395
  const functionName = matches && matches[1] ? matches[1] : void 0;
1392
- const [url2, lineNumber, columnNumber] = extractLocation(line.replace(functionNameRegex, ""));
1393
- if (!url2 || !lineNumber || !columnNumber) {
1396
+ const [url, lineNumber, columnNumber] = extractLocation(line.replace(functionNameRegex, ""));
1397
+ if (!url || !lineNumber || !columnNumber) {
1394
1398
  return null;
1395
1399
  }
1396
1400
  return {
1397
- file: url2,
1401
+ file: url,
1398
1402
  method: functionName || "",
1399
1403
  line: Number.parseInt(lineNumber),
1400
1404
  column: Number.parseInt(columnNumber)
@@ -1416,11 +1420,11 @@ function parseSingleV8Stack(raw) {
1416
1420
  line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, "");
1417
1421
  }
1418
1422
  let sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, "");
1419
- const location2 = sanitizedLine.match(/ (\(.+\)$)/);
1420
- sanitizedLine = location2 ? sanitizedLine.replace(location2[0], "") : sanitizedLine;
1421
- const [url2, lineNumber, columnNumber] = extractLocation(location2 ? location2[1] : sanitizedLine);
1422
- let method = location2 && sanitizedLine || "";
1423
- let file = url2 && ["eval", "<anonymous>"].includes(url2) ? void 0 : url2;
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;
1424
1428
  if (!file || !lineNumber || !columnNumber) {
1425
1429
  return null;
1426
1430
  }
@@ -1441,6 +1445,486 @@ function parseSingleV8Stack(raw) {
1441
1445
  column: Number.parseInt(columnNumber)
1442
1446
  };
1443
1447
  }
1448
+ function getDefaultExportFromCjs(x) {
1449
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
1450
+ }
1451
+ var jsTokens_1;
1452
+ var hasRequiredJsTokens;
1453
+ function requireJsTokens() {
1454
+ if (hasRequiredJsTokens) return jsTokens_1;
1455
+ hasRequiredJsTokens = 1;
1456
+ var HashbangComment, Identifier, JSXIdentifier, JSXPunctuator, JSXString, JSXText, KeywordsWithExpressionAfter, KeywordsWithNoLineTerminatorAfter, LineTerminatorSequence, MultiLineComment, Newline, NumericLiteral, Punctuator, RegularExpressionLiteral, SingleLineComment, StringLiteral, Template, TokensNotPrecedingObjectLiteral, TokensPrecedingExpression, WhiteSpace;
1457
+ RegularExpressionLiteral = /\/(?![*\/])(?:\[(?:[^\]\\\n\r\u2028\u2029]+|\\.)*\]?|[^\/[\\\n\r\u2028\u2029]+|\\.)*(\/[$_\u200C\u200D\p{ID_Continue}]*|\\)?/yu;
1458
+ Punctuator = /--|\+\+|=>|\.{3}|\??\.(?!\d)|(?:&&|\|\||\?\?|[+\-%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2}|\/(?![\/*]))=?|[?~,:;[\](){}]/y;
1459
+ Identifier = /(\x23?)(?=[$_\p{ID_Start}\\])(?:[$_\u200C\u200D\p{ID_Continue}]+|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+/yu;
1460
+ StringLiteral = /(['"])(?:[^'"\\\n\r]+|(?!\1)['"]|\\(?:\r\n|[^]))*(\1)?/y;
1461
+ NumericLiteral = /(?:0[xX][\da-fA-F](?:_?[\da-fA-F])*|0[oO][0-7](?:_?[0-7])*|0[bB][01](?:_?[01])*)n?|0n|[1-9](?:_?\d)*n|(?:(?:0(?!\d)|0\d*[89]\d*|[1-9](?:_?\d)*)(?:\.(?:\d(?:_?\d)*)?)?|\.\d(?:_?\d)*)(?:[eE][+-]?\d(?:_?\d)*)?|0[0-7]+/y;
1462
+ Template = /[`}](?:[^`\\$]+|\\[^]|\$(?!\{))*(`|\$\{)?/y;
1463
+ WhiteSpace = /[\t\v\f\ufeff\p{Zs}]+/yu;
1464
+ LineTerminatorSequence = /\r?\n|[\r\u2028\u2029]/y;
1465
+ MultiLineComment = /\/\*(?:[^*]+|\*(?!\/))*(\*\/)?/y;
1466
+ SingleLineComment = /\/\/.*/y;
1467
+ HashbangComment = /^#!.*/;
1468
+ JSXPunctuator = /[<>.:={}]|\/(?![\/*])/y;
1469
+ JSXIdentifier = /[$_\p{ID_Start}][$_\u200C\u200D\p{ID_Continue}-]*/yu;
1470
+ JSXString = /(['"])(?:[^'"]+|(?!\1)['"])*(\1)?/y;
1471
+ JSXText = /[^<>{}]+/y;
1472
+ TokensPrecedingExpression = /^(?:[\/+-]|\.{3}|\?(?:InterpolationIn(?:JSX|Template)|NoLineTerminatorHere|NonExpressionParenEnd|UnaryIncDec))?$|[{}([,;<>=*%&|^!~?:]$/;
1473
+ TokensNotPrecedingObjectLiteral = /^(?:=>|[;\]){}]|else|\?(?:NoLineTerminatorHere|NonExpressionParenEnd))?$/;
1474
+ KeywordsWithExpressionAfter = /^(?:await|case|default|delete|do|else|instanceof|new|return|throw|typeof|void|yield)$/;
1475
+ KeywordsWithNoLineTerminatorAfter = /^(?:return|throw|yield)$/;
1476
+ Newline = RegExp(LineTerminatorSequence.source);
1477
+ jsTokens_1 = function* (input, { jsx = false } = {}) {
1478
+ var braces, firstCodePoint, isExpression, lastIndex, lastSignificantToken, length, match, mode, nextLastIndex, nextLastSignificantToken, parenNesting, postfixIncDec, punctuator, stack;
1479
+ ({ length } = input);
1480
+ lastIndex = 0;
1481
+ lastSignificantToken = "";
1482
+ stack = [
1483
+ { tag: "JS" }
1484
+ ];
1485
+ braces = [];
1486
+ parenNesting = 0;
1487
+ postfixIncDec = false;
1488
+ if (match = HashbangComment.exec(input)) {
1489
+ yield {
1490
+ type: "HashbangComment",
1491
+ value: match[0]
1492
+ };
1493
+ lastIndex = match[0].length;
1494
+ }
1495
+ while (lastIndex < length) {
1496
+ mode = stack[stack.length - 1];
1497
+ switch (mode.tag) {
1498
+ case "JS":
1499
+ case "JSNonExpressionParen":
1500
+ case "InterpolationInTemplate":
1501
+ case "InterpolationInJSX":
1502
+ if (input[lastIndex] === "/" && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken))) {
1503
+ RegularExpressionLiteral.lastIndex = lastIndex;
1504
+ if (match = RegularExpressionLiteral.exec(input)) {
1505
+ lastIndex = RegularExpressionLiteral.lastIndex;
1506
+ lastSignificantToken = match[0];
1507
+ postfixIncDec = true;
1508
+ yield {
1509
+ type: "RegularExpressionLiteral",
1510
+ value: match[0],
1511
+ closed: match[1] !== void 0 && match[1] !== "\\"
1512
+ };
1513
+ continue;
1514
+ }
1515
+ }
1516
+ Punctuator.lastIndex = lastIndex;
1517
+ if (match = Punctuator.exec(input)) {
1518
+ punctuator = match[0];
1519
+ nextLastIndex = Punctuator.lastIndex;
1520
+ nextLastSignificantToken = punctuator;
1521
+ switch (punctuator) {
1522
+ case "(":
1523
+ if (lastSignificantToken === "?NonExpressionParenKeyword") {
1524
+ stack.push({
1525
+ tag: "JSNonExpressionParen",
1526
+ nesting: parenNesting
1527
+ });
1528
+ }
1529
+ parenNesting++;
1530
+ postfixIncDec = false;
1531
+ break;
1532
+ case ")":
1533
+ parenNesting--;
1534
+ postfixIncDec = true;
1535
+ if (mode.tag === "JSNonExpressionParen" && parenNesting === mode.nesting) {
1536
+ stack.pop();
1537
+ nextLastSignificantToken = "?NonExpressionParenEnd";
1538
+ postfixIncDec = false;
1539
+ }
1540
+ break;
1541
+ case "{":
1542
+ Punctuator.lastIndex = 0;
1543
+ isExpression = !TokensNotPrecedingObjectLiteral.test(lastSignificantToken) && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken));
1544
+ braces.push(isExpression);
1545
+ postfixIncDec = false;
1546
+ break;
1547
+ case "}":
1548
+ switch (mode.tag) {
1549
+ case "InterpolationInTemplate":
1550
+ if (braces.length === mode.nesting) {
1551
+ Template.lastIndex = lastIndex;
1552
+ match = Template.exec(input);
1553
+ lastIndex = Template.lastIndex;
1554
+ lastSignificantToken = match[0];
1555
+ if (match[1] === "${") {
1556
+ lastSignificantToken = "?InterpolationInTemplate";
1557
+ postfixIncDec = false;
1558
+ yield {
1559
+ type: "TemplateMiddle",
1560
+ value: match[0]
1561
+ };
1562
+ } else {
1563
+ stack.pop();
1564
+ postfixIncDec = true;
1565
+ yield {
1566
+ type: "TemplateTail",
1567
+ value: match[0],
1568
+ closed: match[1] === "`"
1569
+ };
1570
+ }
1571
+ continue;
1572
+ }
1573
+ break;
1574
+ case "InterpolationInJSX":
1575
+ if (braces.length === mode.nesting) {
1576
+ stack.pop();
1577
+ lastIndex += 1;
1578
+ lastSignificantToken = "}";
1579
+ yield {
1580
+ type: "JSXPunctuator",
1581
+ value: "}"
1582
+ };
1583
+ continue;
1584
+ }
1585
+ }
1586
+ postfixIncDec = braces.pop();
1587
+ nextLastSignificantToken = postfixIncDec ? "?ExpressionBraceEnd" : "}";
1588
+ break;
1589
+ case "]":
1590
+ postfixIncDec = true;
1591
+ break;
1592
+ case "++":
1593
+ case "--":
1594
+ nextLastSignificantToken = postfixIncDec ? "?PostfixIncDec" : "?UnaryIncDec";
1595
+ break;
1596
+ case "<":
1597
+ if (jsx && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken))) {
1598
+ stack.push({ tag: "JSXTag" });
1599
+ lastIndex += 1;
1600
+ lastSignificantToken = "<";
1601
+ yield {
1602
+ type: "JSXPunctuator",
1603
+ value: punctuator
1604
+ };
1605
+ continue;
1606
+ }
1607
+ postfixIncDec = false;
1608
+ break;
1609
+ default:
1610
+ postfixIncDec = false;
1611
+ }
1612
+ lastIndex = nextLastIndex;
1613
+ lastSignificantToken = nextLastSignificantToken;
1614
+ yield {
1615
+ type: "Punctuator",
1616
+ value: punctuator
1617
+ };
1618
+ continue;
1619
+ }
1620
+ Identifier.lastIndex = lastIndex;
1621
+ if (match = Identifier.exec(input)) {
1622
+ lastIndex = Identifier.lastIndex;
1623
+ nextLastSignificantToken = match[0];
1624
+ switch (match[0]) {
1625
+ case "for":
1626
+ case "if":
1627
+ case "while":
1628
+ case "with":
1629
+ if (lastSignificantToken !== "." && lastSignificantToken !== "?.") {
1630
+ nextLastSignificantToken = "?NonExpressionParenKeyword";
1631
+ }
1632
+ }
1633
+ lastSignificantToken = nextLastSignificantToken;
1634
+ postfixIncDec = !KeywordsWithExpressionAfter.test(match[0]);
1635
+ yield {
1636
+ type: match[1] === "#" ? "PrivateIdentifier" : "IdentifierName",
1637
+ value: match[0]
1638
+ };
1639
+ continue;
1640
+ }
1641
+ StringLiteral.lastIndex = lastIndex;
1642
+ if (match = StringLiteral.exec(input)) {
1643
+ lastIndex = StringLiteral.lastIndex;
1644
+ lastSignificantToken = match[0];
1645
+ postfixIncDec = true;
1646
+ yield {
1647
+ type: "StringLiteral",
1648
+ value: match[0],
1649
+ closed: match[2] !== void 0
1650
+ };
1651
+ continue;
1652
+ }
1653
+ NumericLiteral.lastIndex = lastIndex;
1654
+ if (match = NumericLiteral.exec(input)) {
1655
+ lastIndex = NumericLiteral.lastIndex;
1656
+ lastSignificantToken = match[0];
1657
+ postfixIncDec = true;
1658
+ yield {
1659
+ type: "NumericLiteral",
1660
+ value: match[0]
1661
+ };
1662
+ continue;
1663
+ }
1664
+ Template.lastIndex = lastIndex;
1665
+ if (match = Template.exec(input)) {
1666
+ lastIndex = Template.lastIndex;
1667
+ lastSignificantToken = match[0];
1668
+ if (match[1] === "${") {
1669
+ lastSignificantToken = "?InterpolationInTemplate";
1670
+ stack.push({
1671
+ tag: "InterpolationInTemplate",
1672
+ nesting: braces.length
1673
+ });
1674
+ postfixIncDec = false;
1675
+ yield {
1676
+ type: "TemplateHead",
1677
+ value: match[0]
1678
+ };
1679
+ } else {
1680
+ postfixIncDec = true;
1681
+ yield {
1682
+ type: "NoSubstitutionTemplate",
1683
+ value: match[0],
1684
+ closed: match[1] === "`"
1685
+ };
1686
+ }
1687
+ continue;
1688
+ }
1689
+ break;
1690
+ case "JSXTag":
1691
+ case "JSXTagEnd":
1692
+ JSXPunctuator.lastIndex = lastIndex;
1693
+ if (match = JSXPunctuator.exec(input)) {
1694
+ lastIndex = JSXPunctuator.lastIndex;
1695
+ nextLastSignificantToken = match[0];
1696
+ switch (match[0]) {
1697
+ case "<":
1698
+ stack.push({ tag: "JSXTag" });
1699
+ break;
1700
+ case ">":
1701
+ stack.pop();
1702
+ if (lastSignificantToken === "/" || mode.tag === "JSXTagEnd") {
1703
+ nextLastSignificantToken = "?JSX";
1704
+ postfixIncDec = true;
1705
+ } else {
1706
+ stack.push({ tag: "JSXChildren" });
1707
+ }
1708
+ break;
1709
+ case "{":
1710
+ stack.push({
1711
+ tag: "InterpolationInJSX",
1712
+ nesting: braces.length
1713
+ });
1714
+ nextLastSignificantToken = "?InterpolationInJSX";
1715
+ postfixIncDec = false;
1716
+ break;
1717
+ case "/":
1718
+ if (lastSignificantToken === "<") {
1719
+ stack.pop();
1720
+ if (stack[stack.length - 1].tag === "JSXChildren") {
1721
+ stack.pop();
1722
+ }
1723
+ stack.push({ tag: "JSXTagEnd" });
1724
+ }
1725
+ }
1726
+ lastSignificantToken = nextLastSignificantToken;
1727
+ yield {
1728
+ type: "JSXPunctuator",
1729
+ value: match[0]
1730
+ };
1731
+ continue;
1732
+ }
1733
+ JSXIdentifier.lastIndex = lastIndex;
1734
+ if (match = JSXIdentifier.exec(input)) {
1735
+ lastIndex = JSXIdentifier.lastIndex;
1736
+ lastSignificantToken = match[0];
1737
+ yield {
1738
+ type: "JSXIdentifier",
1739
+ value: match[0]
1740
+ };
1741
+ continue;
1742
+ }
1743
+ JSXString.lastIndex = lastIndex;
1744
+ if (match = JSXString.exec(input)) {
1745
+ lastIndex = JSXString.lastIndex;
1746
+ lastSignificantToken = match[0];
1747
+ yield {
1748
+ type: "JSXString",
1749
+ value: match[0],
1750
+ closed: match[2] !== void 0
1751
+ };
1752
+ continue;
1753
+ }
1754
+ break;
1755
+ case "JSXChildren":
1756
+ JSXText.lastIndex = lastIndex;
1757
+ if (match = JSXText.exec(input)) {
1758
+ lastIndex = JSXText.lastIndex;
1759
+ lastSignificantToken = match[0];
1760
+ yield {
1761
+ type: "JSXText",
1762
+ value: match[0]
1763
+ };
1764
+ continue;
1765
+ }
1766
+ switch (input[lastIndex]) {
1767
+ case "<":
1768
+ stack.push({ tag: "JSXTag" });
1769
+ lastIndex++;
1770
+ lastSignificantToken = "<";
1771
+ yield {
1772
+ type: "JSXPunctuator",
1773
+ value: "<"
1774
+ };
1775
+ continue;
1776
+ case "{":
1777
+ stack.push({
1778
+ tag: "InterpolationInJSX",
1779
+ nesting: braces.length
1780
+ });
1781
+ lastIndex++;
1782
+ lastSignificantToken = "?InterpolationInJSX";
1783
+ postfixIncDec = false;
1784
+ yield {
1785
+ type: "JSXPunctuator",
1786
+ value: "{"
1787
+ };
1788
+ continue;
1789
+ }
1790
+ }
1791
+ WhiteSpace.lastIndex = lastIndex;
1792
+ if (match = WhiteSpace.exec(input)) {
1793
+ lastIndex = WhiteSpace.lastIndex;
1794
+ yield {
1795
+ type: "WhiteSpace",
1796
+ value: match[0]
1797
+ };
1798
+ continue;
1799
+ }
1800
+ LineTerminatorSequence.lastIndex = lastIndex;
1801
+ if (match = LineTerminatorSequence.exec(input)) {
1802
+ lastIndex = LineTerminatorSequence.lastIndex;
1803
+ postfixIncDec = false;
1804
+ if (KeywordsWithNoLineTerminatorAfter.test(lastSignificantToken)) {
1805
+ lastSignificantToken = "?NoLineTerminatorHere";
1806
+ }
1807
+ yield {
1808
+ type: "LineTerminatorSequence",
1809
+ value: match[0]
1810
+ };
1811
+ continue;
1812
+ }
1813
+ MultiLineComment.lastIndex = lastIndex;
1814
+ if (match = MultiLineComment.exec(input)) {
1815
+ lastIndex = MultiLineComment.lastIndex;
1816
+ if (Newline.test(match[0])) {
1817
+ postfixIncDec = false;
1818
+ if (KeywordsWithNoLineTerminatorAfter.test(lastSignificantToken)) {
1819
+ lastSignificantToken = "?NoLineTerminatorHere";
1820
+ }
1821
+ }
1822
+ yield {
1823
+ type: "MultiLineComment",
1824
+ value: match[0],
1825
+ closed: match[1] !== void 0
1826
+ };
1827
+ continue;
1828
+ }
1829
+ SingleLineComment.lastIndex = lastIndex;
1830
+ if (match = SingleLineComment.exec(input)) {
1831
+ lastIndex = SingleLineComment.lastIndex;
1832
+ postfixIncDec = false;
1833
+ yield {
1834
+ type: "SingleLineComment",
1835
+ value: match[0]
1836
+ };
1837
+ continue;
1838
+ }
1839
+ firstCodePoint = String.fromCodePoint(input.codePointAt(lastIndex));
1840
+ lastIndex += firstCodePoint.length;
1841
+ lastSignificantToken = firstCodePoint;
1842
+ postfixIncDec = false;
1843
+ yield {
1844
+ type: mode.tag.startsWith("JSX") ? "JSXInvalid" : "Invalid",
1845
+ value: firstCodePoint
1846
+ };
1847
+ }
1848
+ return void 0;
1849
+ };
1850
+ return jsTokens_1;
1851
+ }
1852
+ var jsTokensExports = requireJsTokens();
1853
+ const jsTokens = /* @__PURE__ */ getDefaultExportFromCjs(jsTokensExports);
1854
+ function stripLiteralJsTokens(code, options) {
1855
+ const FILL = " ";
1856
+ const FILL_COMMENT = " ";
1857
+ let result = "";
1858
+ const tokens = [];
1859
+ for (const token of jsTokens(code, { jsx: false })) {
1860
+ tokens.push(token);
1861
+ if (token.type === "SingleLineComment") {
1862
+ result += FILL_COMMENT.repeat(token.value.length);
1863
+ continue;
1864
+ }
1865
+ if (token.type === "MultiLineComment") {
1866
+ result += token.value.replace(/[^\n]/g, FILL_COMMENT);
1867
+ continue;
1868
+ }
1869
+ if (token.type === "StringLiteral") {
1870
+ if (!token.closed) {
1871
+ result += token.value;
1872
+ continue;
1873
+ }
1874
+ const body = token.value.slice(1, -1);
1875
+ {
1876
+ result += token.value[0] + FILL.repeat(body.length) + token.value[token.value.length - 1];
1877
+ continue;
1878
+ }
1879
+ }
1880
+ if (token.type === "NoSubstitutionTemplate") {
1881
+ const body = token.value.slice(1, -1);
1882
+ {
1883
+ result += `\`${body.replace(/[^\n]/g, FILL)}\``;
1884
+ continue;
1885
+ }
1886
+ }
1887
+ if (token.type === "RegularExpressionLiteral") {
1888
+ const body = token.value;
1889
+ {
1890
+ result += body.replace(/\/(.*)\/(\w?)$/g, (_, $1, $2) => `/${FILL.repeat($1.length)}/${$2}`);
1891
+ continue;
1892
+ }
1893
+ }
1894
+ if (token.type === "TemplateHead") {
1895
+ const body = token.value.slice(1, -2);
1896
+ {
1897
+ result += `\`${body.replace(/[^\n]/g, FILL)}\${`;
1898
+ continue;
1899
+ }
1900
+ }
1901
+ if (token.type === "TemplateTail") {
1902
+ const body = token.value.slice(0, -2);
1903
+ {
1904
+ result += `}${body.replace(/[^\n]/g, FILL)}\``;
1905
+ continue;
1906
+ }
1907
+ }
1908
+ if (token.type === "TemplateMiddle") {
1909
+ const body = token.value.slice(1, -2);
1910
+ {
1911
+ result += `}${body.replace(/[^\n]/g, FILL)}\${`;
1912
+ continue;
1913
+ }
1914
+ }
1915
+ result += token.value;
1916
+ }
1917
+ return {
1918
+ result,
1919
+ tokens
1920
+ };
1921
+ }
1922
+ function stripLiteral(code, options) {
1923
+ return stripLiteralDetailed(code).result;
1924
+ }
1925
+ function stripLiteralDetailed(code, options) {
1926
+ return stripLiteralJsTokens(code);
1927
+ }
1444
1928
  class PendingError extends Error {
1445
1929
  constructor(message, task, note) {
1446
1930
  super(message);
@@ -1671,7 +2155,7 @@ function resolveDeps(fixtures, depSet = /* @__PURE__ */ new Set(), pendingFixtur
1671
2155
  return pendingFixtures;
1672
2156
  }
1673
2157
  function getUsedProps(fn) {
1674
- let fnString = fn.toString();
2158
+ let fnString = stripLiteral(fn.toString());
1675
2159
  if (/__async\((?:this|null), (?:null|arguments|\[[_0-9, ]*\]), function\*/.test(fnString)) {
1676
2160
  fnString = fnString.split(/__async\((?:this|null),/)[1];
1677
2161
  }
@@ -2095,14 +2579,17 @@ function createTaskCollector(fn, context) {
2095
2579
  };
2096
2580
  taskFn.extend = function(fixtures) {
2097
2581
  const _context = mergeContextFixtures(fixtures, context || {}, runner);
2098
- return createTest(function fn2(name, optionsOrFn, optionsOrTest) {
2582
+ const originalWrapper = fn;
2583
+ return createTest(function(name, optionsOrFn, optionsOrTest) {
2099
2584
  const collector = getCurrentSuite();
2100
2585
  const scopedFixtures = collector.fixtures();
2101
2586
  const context2 = { ...this };
2102
2587
  if (scopedFixtures) {
2103
2588
  context2.fixtures = mergeScopedFixtures(context2.fixtures || [], scopedFixtures);
2104
2589
  }
2105
- collector.test.fn.call(context2, formatName(name), optionsOrFn, optionsOrTest);
2590
+ const { handler, options } = parseArguments(optionsOrFn, optionsOrTest);
2591
+ const timeout = options.timeout ?? void 0;
2592
+ originalWrapper.call(context2, formatName(name), handler, timeout);
2106
2593
  }, _context);
2107
2594
  };
2108
2595
  const _test = createChainable([
@@ -2193,6 +2680,7 @@ function generateHash(str) {
2193
2680
  }
2194
2681
  globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
2195
2682
  globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
2683
+ getSafeTimers();
2196
2684
  const packs = /* @__PURE__ */ new Map();
2197
2685
  const eventsPacks = [];
2198
2686
  const pendingTasksUpdates = [];
@@ -2315,7 +2803,7 @@ function createTestContext(test, runner2) {
2315
2803
  test.result.pending = true;
2316
2804
  throw new PendingError("test is skipped; abort execution", test, typeof condition === "string" ? condition : note);
2317
2805
  };
2318
- async function annotate(message, location2, type, attachment) {
2806
+ async function annotate(message, location, type, attachment) {
2319
2807
  const annotation = {
2320
2808
  message,
2321
2809
  type: type || "notice"
@@ -2332,8 +2820,8 @@ function createTestContext(test, runner2) {
2332
2820
  attachment.body = encodeUint8Array(attachment.body);
2333
2821
  }
2334
2822
  }
2335
- if (location2) {
2336
- annotation.location = location2;
2823
+ if (location) {
2824
+ annotation.location = location;
2337
2825
  }
2338
2826
  if (!runner2.onTestAnnotate) {
2339
2827
  throw new Error(`Test runner doesn't support test annotations.`);
@@ -2347,22 +2835,22 @@ function createTestContext(test, runner2) {
2347
2835
  if (test.result && test.result.state !== "run") {
2348
2836
  throw new Error(`Cannot annotate tests outside of the test run. The test "${test.name}" finished running with the "${test.result.state}" state already.`);
2349
2837
  }
2350
- let location2;
2838
+ let location;
2351
2839
  const stack = new Error("STACK_TRACE").stack;
2352
2840
  const index = stack.includes("STACK_TRACE") ? 2 : 1;
2353
2841
  const stackLine = stack.split("\n")[index];
2354
2842
  const parsed = parseSingleStack(stackLine);
2355
2843
  if (parsed) {
2356
- location2 = {
2844
+ location = {
2357
2845
  file: parsed.file,
2358
2846
  line: parsed.line,
2359
2847
  column: parsed.column
2360
2848
  };
2361
2849
  }
2362
2850
  if (typeof type === "object") {
2363
- return recordAsyncAnnotation(test, annotate(message, location2, void 0, type));
2851
+ return recordAsyncAnnotation(test, annotate(message, location, void 0, type));
2364
2852
  } else {
2365
- return recordAsyncAnnotation(test, annotate(message, location2, type, attachment));
2853
+ return recordAsyncAnnotation(test, annotate(message, location, type, attachment));
2366
2854
  }
2367
2855
  };
2368
2856
  context.onTestFailed = (handler, timeout) => {
@@ -2452,7 +2940,6 @@ function recordAsyncAnnotation(test, promise) {
2452
2940
  function getUiAPI() {
2453
2941
  return window.__vitest_ui_api__;
2454
2942
  }
2455
- const url = new URL(location.href);
2456
2943
  const ID_ALL = "__vitest_all__";
2457
2944
  class IframeOrchestrator {
2458
2945
  constructor() {
@@ -2592,7 +3079,7 @@ class IframeOrchestrator {
2592
3079
  }
2593
3080
  createTestIframe(iframeId) {
2594
3081
  const iframe = document.createElement("iframe");
2595
- const src = `${url.pathname}__vitest_test__/__test__/?sessionId=${getBrowserState().sessionId}&iframeId=${iframeId}`;
3082
+ const src = `/?sessionId=${getBrowserState().sessionId}&iframeId=${iframeId}`;
2596
3083
  iframe.setAttribute("loading", "eager");
2597
3084
  iframe.setAttribute("src", src);
2598
3085
  iframe.setAttribute("data-vitest", "true");