@shware/security 2.2.0 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/index.cjs +1 -1
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.d.cts +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.mjs +1 -1
- package/dist/auth/index.mjs.map +1 -1
- package/dist/oauth2/provider/apple.cjs.map +1 -1
- package/dist/oauth2/provider/apple.mjs.map +1 -1
- package/dist/oauth2/provider/common.cjs.map +1 -1
- package/dist/oauth2/provider/common.mjs.map +1 -1
- package/dist/oauth2/provider/facebook.cjs.map +1 -1
- package/dist/oauth2/provider/facebook.mjs.map +1 -1
- package/dist/oauth2/provider/github.cjs.map +1 -1
- package/dist/oauth2/provider/github.mjs.map +1 -1
- package/dist/oauth2/provider/google.cjs.map +1 -1
- package/dist/oauth2/provider/google.mjs.map +1 -1
- package/dist/oauth2/provider/wechat.cjs.map +1 -1
- package/dist/oauth2/provider/wechat.mjs.map +1 -1
- package/dist/oauth2/provider/x.cjs.map +1 -1
- package/dist/oauth2/provider/x.mjs.map +1 -1
- package/dist/session/__tests__/redis.test.cjs +773 -367
- package/dist/session/__tests__/redis.test.cjs.map +1 -1
- package/dist/session/__tests__/redis.test.mjs +763 -357
- package/dist/session/__tests__/redis.test.mjs.map +1 -1
- package/dist/session/db.cjs.map +1 -1
- package/dist/session/db.d.cts +1 -1
- package/dist/session/db.d.ts +1 -1
- package/dist/session/db.mjs.map +1 -1
- package/dist/session/redis.cjs.map +1 -1
- package/dist/session/redis.d.cts +1 -1
- package/dist/session/redis.d.ts +1 -1
- package/dist/session/redis.mjs.map +1 -1
- package/package.json +5 -5
|
@@ -5,7 +5,7 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
-
get: (
|
|
8
|
+
get: (a4, b4) => (typeof require !== "undefined" ? require : a4)[b4]
|
|
9
9
|
}) : x)(function(x) {
|
|
10
10
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
11
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
@@ -113,12 +113,12 @@ var require_dist = __commonJS({
|
|
|
113
113
|
// src/session/__tests__/redis.test.ts
|
|
114
114
|
import Redis from "ioredis";
|
|
115
115
|
|
|
116
|
-
// ../../node_modules/.pnpm/vitest@4.
|
|
116
|
+
// ../../node_modules/.pnpm/vitest@4.1.0_@opentelemetry+api@1.9.0_@types+node@25.3.0_vite@7.3.1_@types+node@25.3.0__1256cd9683254972294f67b42fe9fd18/node_modules/vitest/dist/index.js
|
|
117
117
|
var import_expect_type = __toESM(require_dist(), 1);
|
|
118
|
-
import {
|
|
119
|
-
import { b as b3 } from "./chunks/benchmark.
|
|
118
|
+
import { N, T, a as a2, c as c2, g as g3, i as i2, s as s2, v as v2, b as b2 } from "./chunks/test.CTcmp4Su.js.mjs";
|
|
119
|
+
import { b as b3 } from "./chunks/benchmark.D0SlKNbZ.js.mjs";
|
|
120
120
|
import { V } from "./chunks/evaluatedModules.Dg1zASAC.js.mjs";
|
|
121
|
-
import { a as
|
|
121
|
+
import { a as a3 } from "./chunks/index.DlDSLQD3.js.mjs";
|
|
122
122
|
|
|
123
123
|
// ../../node_modules/.pnpm/tinyrainbow@3.0.3/node_modules/tinyrainbow/dist/index.js
|
|
124
124
|
var d = {
|
|
@@ -170,20 +170,20 @@ function g(e2) {
|
|
|
170
170
|
g.open = "";
|
|
171
171
|
g.close = "";
|
|
172
172
|
function h() {
|
|
173
|
-
let e2 = typeof process != "undefined" ? process : void 0, n2 = (e2 == null ? void 0 : e2.env) || {},
|
|
174
|
-
return !("NO_COLOR" in n2 || i3.includes("--no-color")) && ("FORCE_COLOR" in n2 || i3.includes("--color") || (e2 == null ? void 0 : e2.platform) === "win32" ||
|
|
173
|
+
let e2 = typeof process != "undefined" ? process : void 0, n2 = (e2 == null ? void 0 : e2.env) || {}, a4 = n2.FORCE_TTY !== "false", i3 = (e2 == null ? void 0 : e2.argv) || [];
|
|
174
|
+
return !("NO_COLOR" in n2 || i3.includes("--no-color")) && ("FORCE_COLOR" in n2 || i3.includes("--color") || (e2 == null ? void 0 : e2.platform) === "win32" || a4 && n2.TERM !== "dumb" || "CI" in n2) || typeof window != "undefined" && !!window.chrome;
|
|
175
175
|
}
|
|
176
176
|
function f() {
|
|
177
|
-
let e2 = h(), n2 = (r2, t2,
|
|
177
|
+
let e2 = h(), n2 = (r2, t2, u2, o2) => {
|
|
178
178
|
let l2 = "", s3 = 0;
|
|
179
179
|
do
|
|
180
|
-
l2 += r2.substring(s3, o2) +
|
|
180
|
+
l2 += r2.substring(s3, o2) + u2, s3 = o2 + t2.length, o2 = r2.indexOf(t2, s3);
|
|
181
181
|
while (~o2);
|
|
182
182
|
return l2 + r2.substring(s3);
|
|
183
|
-
},
|
|
183
|
+
}, a4 = (r2, t2, u2 = r2) => {
|
|
184
184
|
let o2 = (l2) => {
|
|
185
185
|
let s3 = String(l2), b4 = s3.indexOf(t2, r2.length);
|
|
186
|
-
return ~b4 ? r2 + n2(s3, t2,
|
|
186
|
+
return ~b4 ? r2 + n2(s3, t2, u2, b4) + t2 : r2 + s3 + t2;
|
|
187
187
|
};
|
|
188
188
|
return o2.open = r2, o2.close = t2, o2;
|
|
189
189
|
}, i3 = {
|
|
@@ -191,7 +191,7 @@ function f() {
|
|
|
191
191
|
}, c3 = (r2) => `\x1B[${r2}m`;
|
|
192
192
|
for (let r2 in d) {
|
|
193
193
|
let t2 = d[r2];
|
|
194
|
-
i3[r2] = e2 ?
|
|
194
|
+
i3[r2] = e2 ? a4(
|
|
195
195
|
c3(t2[0]),
|
|
196
196
|
c3(t2[1]),
|
|
197
197
|
t2[2]
|
|
@@ -201,13 +201,13 @@ function f() {
|
|
|
201
201
|
}
|
|
202
202
|
var C = f();
|
|
203
203
|
|
|
204
|
-
// ../../node_modules/.pnpm/@vitest+pretty-format@4.0
|
|
204
|
+
// ../../node_modules/.pnpm/@vitest+pretty-format@4.1.0/node_modules/@vitest/pretty-format/dist/index.js
|
|
205
205
|
function _mergeNamespaces(n2, m2) {
|
|
206
206
|
m2.forEach(function(e2) {
|
|
207
207
|
e2 && typeof e2 !== "string" && !Array.isArray(e2) && Object.keys(e2).forEach(function(k2) {
|
|
208
208
|
if (k2 !== "default" && !(k2 in n2)) {
|
|
209
|
-
var
|
|
210
|
-
Object.defineProperty(n2, k2,
|
|
209
|
+
var d3 = Object.getOwnPropertyDescriptor(e2, k2);
|
|
210
|
+
Object.defineProperty(n2, k2, d3.get ? d3 : {
|
|
211
211
|
enumerable: true,
|
|
212
212
|
get: function() {
|
|
213
213
|
return e2[k2];
|
|
@@ -460,7 +460,20 @@ function nodeIsComment(node) {
|
|
|
460
460
|
function nodeIsFragment(node) {
|
|
461
461
|
return node.nodeType === FRAGMENT_NODE;
|
|
462
462
|
}
|
|
463
|
-
|
|
463
|
+
function filterChildren(children, filterNode) {
|
|
464
|
+
let filtered = children.filter((node) => {
|
|
465
|
+
if (node.nodeType === TEXT_NODE) {
|
|
466
|
+
const text = node.data || "";
|
|
467
|
+
return text.trim().length > 0;
|
|
468
|
+
}
|
|
469
|
+
return true;
|
|
470
|
+
});
|
|
471
|
+
if (filterNode) {
|
|
472
|
+
filtered = filtered.filter(filterNode);
|
|
473
|
+
}
|
|
474
|
+
return filtered;
|
|
475
|
+
}
|
|
476
|
+
function serializeDOM(node, config, indentation, depth, refs, printer2, filterNode) {
|
|
464
477
|
if (nodeIsText(node)) {
|
|
465
478
|
return printText(node.data, config);
|
|
466
479
|
}
|
|
@@ -471,11 +484,22 @@ var serialize$3 = (node, config, indentation, depth, refs, printer2) => {
|
|
|
471
484
|
if (++depth > config.maxDepth) {
|
|
472
485
|
return printElementAsLeaf(type, config);
|
|
473
486
|
}
|
|
487
|
+
const children = Array.prototype.slice.call(node.childNodes || node.children);
|
|
488
|
+
const shadowChildren = nodeIsFragment(node) || !node.shadowRoot ? [] : Array.prototype.slice.call(node.shadowRoot.children);
|
|
489
|
+
const resolvedChildren = filterNode ? filterChildren(children, filterNode) : children;
|
|
490
|
+
const resolvedShadowChildren = filterNode ? filterChildren(shadowChildren, filterNode) : shadowChildren;
|
|
474
491
|
return printElement(type, printProps(nodeIsFragment(node) ? [] : Array.from(node.attributes, (attr) => attr.name).sort(), nodeIsFragment(node) ? {} : [...node.attributes].reduce((props, attribute) => {
|
|
475
492
|
props[attribute.name] = attribute.value;
|
|
476
493
|
return props;
|
|
477
|
-
}, {}), config, indentation + config.indent, depth, refs, printer2), (
|
|
478
|
-
}
|
|
494
|
+
}, {}), config, indentation + config.indent, depth, refs, printer2), (resolvedShadowChildren.length > 0 ? printShadowRoot(resolvedShadowChildren, config, indentation + config.indent, depth, refs, printer2) : "") + printChildren(resolvedChildren, config, indentation + config.indent, depth, refs, printer2), config, indentation);
|
|
495
|
+
}
|
|
496
|
+
var serialize$3 = (node, config, indentation, depth, refs, printer2) => serializeDOM(node, config, indentation, depth, refs, printer2);
|
|
497
|
+
function createDOMElementFilter(filterNode) {
|
|
498
|
+
return {
|
|
499
|
+
test: test$3,
|
|
500
|
+
serialize: (node, config, indentation, depth, refs, printer2) => serializeDOM(node, config, indentation, depth, refs, printer2, filterNode)
|
|
501
|
+
};
|
|
502
|
+
}
|
|
479
503
|
var plugin$3 = {
|
|
480
504
|
serialize: serialize$3,
|
|
481
505
|
test: test$3
|
|
@@ -668,29 +692,29 @@ var hasRequiredReactIs_production_min;
|
|
|
668
692
|
function requireReactIs_production_min() {
|
|
669
693
|
if (hasRequiredReactIs_production_min) return reactIs_production_min;
|
|
670
694
|
hasRequiredReactIs_production_min = 1;
|
|
671
|
-
var b4 = /* @__PURE__ */ Symbol.for("react.element"), c3 = /* @__PURE__ */ Symbol.for("react.portal"),
|
|
672
|
-
|
|
673
|
-
function
|
|
674
|
-
if ("object" === typeof
|
|
675
|
-
var r2 =
|
|
695
|
+
var b4 = /* @__PURE__ */ Symbol.for("react.element"), c3 = /* @__PURE__ */ Symbol.for("react.portal"), d3 = /* @__PURE__ */ Symbol.for("react.fragment"), e2 = /* @__PURE__ */ Symbol.for("react.strict_mode"), f3 = /* @__PURE__ */ Symbol.for("react.profiler"), g4 = /* @__PURE__ */ Symbol.for("react.provider"), h3 = /* @__PURE__ */ Symbol.for("react.context"), k2 = /* @__PURE__ */ Symbol.for("react.server_context"), l2 = /* @__PURE__ */ Symbol.for("react.forward_ref"), m2 = /* @__PURE__ */ Symbol.for("react.suspense"), n2 = /* @__PURE__ */ Symbol.for("react.suspense_list"), p2 = /* @__PURE__ */ Symbol.for("react.memo"), q2 = /* @__PURE__ */ Symbol.for("react.lazy"), t2 = /* @__PURE__ */ Symbol.for("react.offscreen"), u2;
|
|
696
|
+
u2 = /* @__PURE__ */ Symbol.for("react.module.reference");
|
|
697
|
+
function v3(a4) {
|
|
698
|
+
if ("object" === typeof a4 && null !== a4) {
|
|
699
|
+
var r2 = a4.$$typeof;
|
|
676
700
|
switch (r2) {
|
|
677
701
|
case b4:
|
|
678
|
-
switch (
|
|
679
|
-
case
|
|
702
|
+
switch (a4 = a4.type, a4) {
|
|
703
|
+
case d3:
|
|
680
704
|
case f3:
|
|
681
705
|
case e2:
|
|
682
706
|
case m2:
|
|
683
707
|
case n2:
|
|
684
|
-
return
|
|
708
|
+
return a4;
|
|
685
709
|
default:
|
|
686
|
-
switch (
|
|
710
|
+
switch (a4 = a4 && a4.$$typeof, a4) {
|
|
687
711
|
case k2:
|
|
688
712
|
case h3:
|
|
689
713
|
case l2:
|
|
690
714
|
case q2:
|
|
691
715
|
case p2:
|
|
692
716
|
case g4:
|
|
693
|
-
return
|
|
717
|
+
return a4;
|
|
694
718
|
default:
|
|
695
719
|
return r2;
|
|
696
720
|
}
|
|
@@ -704,7 +728,7 @@ function requireReactIs_production_min() {
|
|
|
704
728
|
reactIs_production_min.ContextProvider = g4;
|
|
705
729
|
reactIs_production_min.Element = b4;
|
|
706
730
|
reactIs_production_min.ForwardRef = l2;
|
|
707
|
-
reactIs_production_min.Fragment =
|
|
731
|
+
reactIs_production_min.Fragment = d3;
|
|
708
732
|
reactIs_production_min.Lazy = q2;
|
|
709
733
|
reactIs_production_min.Memo = p2;
|
|
710
734
|
reactIs_production_min.Portal = c3;
|
|
@@ -718,46 +742,46 @@ function requireReactIs_production_min() {
|
|
|
718
742
|
reactIs_production_min.isConcurrentMode = function() {
|
|
719
743
|
return false;
|
|
720
744
|
};
|
|
721
|
-
reactIs_production_min.isContextConsumer = function(
|
|
722
|
-
return
|
|
745
|
+
reactIs_production_min.isContextConsumer = function(a4) {
|
|
746
|
+
return v3(a4) === h3;
|
|
723
747
|
};
|
|
724
|
-
reactIs_production_min.isContextProvider = function(
|
|
725
|
-
return
|
|
748
|
+
reactIs_production_min.isContextProvider = function(a4) {
|
|
749
|
+
return v3(a4) === g4;
|
|
726
750
|
};
|
|
727
|
-
reactIs_production_min.isElement = function(
|
|
728
|
-
return "object" === typeof
|
|
751
|
+
reactIs_production_min.isElement = function(a4) {
|
|
752
|
+
return "object" === typeof a4 && null !== a4 && a4.$$typeof === b4;
|
|
729
753
|
};
|
|
730
|
-
reactIs_production_min.isForwardRef = function(
|
|
731
|
-
return
|
|
754
|
+
reactIs_production_min.isForwardRef = function(a4) {
|
|
755
|
+
return v3(a4) === l2;
|
|
732
756
|
};
|
|
733
|
-
reactIs_production_min.isFragment = function(
|
|
734
|
-
return
|
|
757
|
+
reactIs_production_min.isFragment = function(a4) {
|
|
758
|
+
return v3(a4) === d3;
|
|
735
759
|
};
|
|
736
|
-
reactIs_production_min.isLazy = function(
|
|
737
|
-
return
|
|
760
|
+
reactIs_production_min.isLazy = function(a4) {
|
|
761
|
+
return v3(a4) === q2;
|
|
738
762
|
};
|
|
739
|
-
reactIs_production_min.isMemo = function(
|
|
740
|
-
return
|
|
763
|
+
reactIs_production_min.isMemo = function(a4) {
|
|
764
|
+
return v3(a4) === p2;
|
|
741
765
|
};
|
|
742
|
-
reactIs_production_min.isPortal = function(
|
|
743
|
-
return
|
|
766
|
+
reactIs_production_min.isPortal = function(a4) {
|
|
767
|
+
return v3(a4) === c3;
|
|
744
768
|
};
|
|
745
|
-
reactIs_production_min.isProfiler = function(
|
|
746
|
-
return
|
|
769
|
+
reactIs_production_min.isProfiler = function(a4) {
|
|
770
|
+
return v3(a4) === f3;
|
|
747
771
|
};
|
|
748
|
-
reactIs_production_min.isStrictMode = function(
|
|
749
|
-
return
|
|
772
|
+
reactIs_production_min.isStrictMode = function(a4) {
|
|
773
|
+
return v3(a4) === e2;
|
|
750
774
|
};
|
|
751
|
-
reactIs_production_min.isSuspense = function(
|
|
752
|
-
return
|
|
775
|
+
reactIs_production_min.isSuspense = function(a4) {
|
|
776
|
+
return v3(a4) === m2;
|
|
753
777
|
};
|
|
754
|
-
reactIs_production_min.isSuspenseList = function(
|
|
755
|
-
return
|
|
778
|
+
reactIs_production_min.isSuspenseList = function(a4) {
|
|
779
|
+
return v3(a4) === n2;
|
|
756
780
|
};
|
|
757
|
-
reactIs_production_min.isValidElementType = function(
|
|
758
|
-
return "string" === typeof
|
|
781
|
+
reactIs_production_min.isValidElementType = function(a4) {
|
|
782
|
+
return "string" === typeof a4 || "function" === typeof a4 || a4 === d3 || a4 === f3 || a4 === e2 || a4 === m2 || a4 === n2 || a4 === t2 || "object" === typeof a4 && null !== a4 && (a4.$$typeof === q2 || a4.$$typeof === p2 || a4.$$typeof === g4 || a4.$$typeof === h3 || a4.$$typeof === l2 || a4.$$typeof === u2 || void 0 !== a4.getModuleId) ? true : false;
|
|
759
783
|
};
|
|
760
|
-
reactIs_production_min.typeOf =
|
|
784
|
+
reactIs_production_min.typeOf = v3;
|
|
761
785
|
return reactIs_production_min;
|
|
762
786
|
}
|
|
763
787
|
var hasRequiredReactIs;
|
|
@@ -792,7 +816,7 @@ var reactIsMethods = [
|
|
|
792
816
|
"isSuspenseList",
|
|
793
817
|
"isValidElementType"
|
|
794
818
|
];
|
|
795
|
-
var ReactIs = Object.fromEntries(reactIsMethods.map((m2) => [m2, (
|
|
819
|
+
var ReactIs = Object.fromEntries(reactIsMethods.map((m2) => [m2, (v3) => ReactIs18[m2](v3) || ReactIs19[m2](v3)]));
|
|
796
820
|
function getChildren(arg, children = []) {
|
|
797
821
|
if (Array.isArray(arg)) {
|
|
798
822
|
for (const item of arg) {
|
|
@@ -1161,7 +1185,7 @@ var plugins = {
|
|
|
1161
1185
|
Error: ErrorPlugin
|
|
1162
1186
|
};
|
|
1163
1187
|
|
|
1164
|
-
// ../../node_modules/.pnpm/@vitest+utils@4.0
|
|
1188
|
+
// ../../node_modules/.pnpm/@vitest+utils@4.1.0/node_modules/@vitest/utils/dist/helpers.js
|
|
1165
1189
|
import { VALID_ID_PREFIX, NULL_BYTE_PLACEHOLDER } from "./constants.js.mjs";
|
|
1166
1190
|
function assertTypes(value, name, types) {
|
|
1167
1191
|
const receivedType = typeof value;
|
|
@@ -1170,6 +1194,31 @@ function assertTypes(value, name, types) {
|
|
|
1170
1194
|
throw new TypeError(`${name} value must be ${types.join(" or ")}, received "${receivedType}"`);
|
|
1171
1195
|
}
|
|
1172
1196
|
}
|
|
1197
|
+
function filterOutComments(s3) {
|
|
1198
|
+
const result = [];
|
|
1199
|
+
let commentState = "none";
|
|
1200
|
+
for (let i3 = 0; i3 < s3.length; ++i3) {
|
|
1201
|
+
if (commentState === "singleline") {
|
|
1202
|
+
if (s3[i3] === "\n") {
|
|
1203
|
+
commentState = "none";
|
|
1204
|
+
}
|
|
1205
|
+
} else if (commentState === "multiline") {
|
|
1206
|
+
if (s3[i3 - 1] === "*" && s3[i3] === "/") {
|
|
1207
|
+
commentState = "none";
|
|
1208
|
+
}
|
|
1209
|
+
} else if (commentState === "none") {
|
|
1210
|
+
if (s3[i3] === "/" && s3[i3 + 1] === "/") {
|
|
1211
|
+
commentState = "singleline";
|
|
1212
|
+
} else if (s3[i3] === "/" && s3[i3 + 1] === "*") {
|
|
1213
|
+
commentState = "multiline";
|
|
1214
|
+
i3 += 2;
|
|
1215
|
+
} else {
|
|
1216
|
+
result.push(s3[i3]);
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
return result.join("");
|
|
1221
|
+
}
|
|
1173
1222
|
function toArray(array) {
|
|
1174
1223
|
if (array === null || array === void 0) {
|
|
1175
1224
|
array = [];
|
|
@@ -1214,8 +1263,25 @@ function isNegativeNaN(val) {
|
|
|
1214
1263
|
const isNegative = u32[1] >>> 31 === 1;
|
|
1215
1264
|
return isNegative;
|
|
1216
1265
|
}
|
|
1266
|
+
function ordinal(i3) {
|
|
1267
|
+
const j2 = i3 % 10;
|
|
1268
|
+
const k2 = i3 % 100;
|
|
1269
|
+
if (j2 === 1 && k2 !== 11) {
|
|
1270
|
+
return `${i3}st`;
|
|
1271
|
+
}
|
|
1272
|
+
if (j2 === 2 && k2 !== 12) {
|
|
1273
|
+
return `${i3}nd`;
|
|
1274
|
+
}
|
|
1275
|
+
if (j2 === 3 && k2 !== 13) {
|
|
1276
|
+
return `${i3}rd`;
|
|
1277
|
+
}
|
|
1278
|
+
return `${i3}th`;
|
|
1279
|
+
}
|
|
1280
|
+
function unique(array) {
|
|
1281
|
+
return Array.from(new Set(array));
|
|
1282
|
+
}
|
|
1217
1283
|
|
|
1218
|
-
// ../../node_modules/.pnpm/@vitest+utils@4.0
|
|
1284
|
+
// ../../node_modules/.pnpm/@vitest+utils@4.1.0/node_modules/@vitest/utils/dist/timers.js
|
|
1219
1285
|
var SAFE_TIMERS_SYMBOL = /* @__PURE__ */ Symbol("vitest:SAFE_TIMERS");
|
|
1220
1286
|
function getSafeTimers() {
|
|
1221
1287
|
const { setTimeout: safeSetTimeout, setInterval: safeSetInterval, clearInterval: safeClearInterval, clearTimeout: safeClearTimeout, setImmediate: safeSetImmediate, clearImmediate: safeClearImmediate, queueMicrotask: safeQueueMicrotask } = globalThis[SAFE_TIMERS_SYMBOL] || globalThis;
|
|
@@ -1232,7 +1298,7 @@ function getSafeTimers() {
|
|
|
1232
1298
|
};
|
|
1233
1299
|
}
|
|
1234
1300
|
|
|
1235
|
-
// ../../node_modules/.pnpm/@vitest+utils@4.0
|
|
1301
|
+
// ../../node_modules/.pnpm/@vitest+utils@4.1.0/node_modules/@vitest/utils/dist/display.js
|
|
1236
1302
|
var ansiColors = {
|
|
1237
1303
|
bold: ["1", "22"],
|
|
1238
1304
|
dim: ["2", "22"],
|
|
@@ -1759,14 +1825,23 @@ var PLUGINS = [
|
|
|
1759
1825
|
Immutable,
|
|
1760
1826
|
AsymmetricMatcher
|
|
1761
1827
|
];
|
|
1762
|
-
function stringify(object, maxDepth = 10, { maxLength, ...options } = {}) {
|
|
1828
|
+
function stringify(object, maxDepth = 10, { maxLength, filterNode, ...options } = {}) {
|
|
1763
1829
|
const MAX_LENGTH = maxLength ?? 1e4;
|
|
1764
1830
|
let result;
|
|
1831
|
+
const filterFn = typeof filterNode === "string" ? createNodeFilterFromSelector(filterNode) : filterNode;
|
|
1832
|
+
const plugins2 = filterFn ? [
|
|
1833
|
+
ReactTestComponent,
|
|
1834
|
+
ReactElement,
|
|
1835
|
+
createDOMElementFilter(filterFn),
|
|
1836
|
+
DOMCollection,
|
|
1837
|
+
Immutable,
|
|
1838
|
+
AsymmetricMatcher
|
|
1839
|
+
] : PLUGINS;
|
|
1765
1840
|
try {
|
|
1766
1841
|
result = format(object, {
|
|
1767
1842
|
maxDepth,
|
|
1768
1843
|
escapeString: false,
|
|
1769
|
-
plugins:
|
|
1844
|
+
plugins: plugins2,
|
|
1770
1845
|
...options
|
|
1771
1846
|
});
|
|
1772
1847
|
} catch {
|
|
@@ -1774,15 +1849,33 @@ function stringify(object, maxDepth = 10, { maxLength, ...options } = {}) {
|
|
|
1774
1849
|
callToJSON: false,
|
|
1775
1850
|
maxDepth,
|
|
1776
1851
|
escapeString: false,
|
|
1777
|
-
plugins:
|
|
1852
|
+
plugins: plugins2,
|
|
1778
1853
|
...options
|
|
1779
1854
|
});
|
|
1780
1855
|
}
|
|
1781
1856
|
return result.length >= MAX_LENGTH && maxDepth > 1 ? stringify(object, Math.floor(Math.min(maxDepth, Number.MAX_SAFE_INTEGER) / 2), {
|
|
1782
1857
|
maxLength,
|
|
1858
|
+
filterNode,
|
|
1783
1859
|
...options
|
|
1784
1860
|
}) : result;
|
|
1785
1861
|
}
|
|
1862
|
+
function createNodeFilterFromSelector(selector) {
|
|
1863
|
+
const ELEMENT_NODE2 = 1;
|
|
1864
|
+
const COMMENT_NODE2 = 8;
|
|
1865
|
+
return (node) => {
|
|
1866
|
+
if (node.nodeType === COMMENT_NODE2) {
|
|
1867
|
+
return false;
|
|
1868
|
+
}
|
|
1869
|
+
if (node.nodeType === ELEMENT_NODE2 && node.matches) {
|
|
1870
|
+
try {
|
|
1871
|
+
return !node.matches(selector);
|
|
1872
|
+
} catch {
|
|
1873
|
+
return true;
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1876
|
+
return true;
|
|
1877
|
+
};
|
|
1878
|
+
}
|
|
1786
1879
|
var formatRegExp = /%[sdjifoOc%]/g;
|
|
1787
1880
|
function baseFormat(args, options = {}) {
|
|
1788
1881
|
const formatArg = (item, inspecOptions) => {
|
|
@@ -1839,6 +1932,9 @@ function baseFormat(args, options = {}) {
|
|
|
1839
1932
|
if (typeof value === "bigint") {
|
|
1840
1933
|
return `${value.toString()}n`;
|
|
1841
1934
|
}
|
|
1935
|
+
if (typeof value === "symbol") {
|
|
1936
|
+
return "NaN";
|
|
1937
|
+
}
|
|
1842
1938
|
return Number(value).toString();
|
|
1843
1939
|
}
|
|
1844
1940
|
case "%i": {
|
|
@@ -1877,7 +1973,7 @@ function baseFormat(args, options = {}) {
|
|
|
1877
1973
|
});
|
|
1878
1974
|
for (let x = args[i3]; i3 < len; x = args[++i3]) {
|
|
1879
1975
|
if (x === null || typeof x !== "object") {
|
|
1880
|
-
str += ` ${x}`;
|
|
1976
|
+
str += ` ${typeof x === "symbol" ? x.toString() : x}`;
|
|
1881
1977
|
} else {
|
|
1882
1978
|
str += ` ${formatArg(x)}`;
|
|
1883
1979
|
}
|
|
@@ -1916,8 +2012,8 @@ function objDisplay(obj, options = {}) {
|
|
|
1916
2012
|
return str;
|
|
1917
2013
|
}
|
|
1918
2014
|
|
|
1919
|
-
// ../../node_modules/.pnpm/@vitest+runner@4.0
|
|
1920
|
-
import {
|
|
2015
|
+
// ../../node_modules/.pnpm/@vitest+runner@4.1.0/node_modules/@vitest/runner/dist/index.js
|
|
2016
|
+
import { w as getChainableContext, a as createChainable, v as validateTags, e as createTaskName, x as createNoTagsError, f as findTestFileStackTrace, d as createTagsFilter, b as createFileTask, c as calculateSuiteHash, u as someTasksAreOnly, q as interpretTaskModes, s as limitConcurrency, t as partitionSuiteChildren, p as hasTests, o as hasFailed } from "./chunk-tasks.js.mjs";
|
|
1921
2017
|
var PendingError = class extends Error {
|
|
1922
2018
|
code = "VITEST_PENDING";
|
|
1923
2019
|
taskId;
|
|
@@ -1928,6 +2024,15 @@ var PendingError = class extends Error {
|
|
|
1928
2024
|
this.taskId = task.id;
|
|
1929
2025
|
}
|
|
1930
2026
|
};
|
|
2027
|
+
var FixtureDependencyError = class extends Error {
|
|
2028
|
+
name = "FixtureDependencyError";
|
|
2029
|
+
};
|
|
2030
|
+
var FixtureAccessError = class extends Error {
|
|
2031
|
+
name = "FixtureAccessError";
|
|
2032
|
+
};
|
|
2033
|
+
var FixtureParseError = class extends Error {
|
|
2034
|
+
name = "FixtureParseError";
|
|
2035
|
+
};
|
|
1931
2036
|
var fnMap = /* @__PURE__ */ new WeakMap();
|
|
1932
2037
|
var testFixtureMap = /* @__PURE__ */ new WeakMap();
|
|
1933
2038
|
var hooksMap = /* @__PURE__ */ new WeakMap();
|
|
@@ -1937,7 +2042,7 @@ function setFn(key, fn) {
|
|
|
1937
2042
|
function setTestFixture(key, fixture) {
|
|
1938
2043
|
testFixtureMap.set(key, fixture);
|
|
1939
2044
|
}
|
|
1940
|
-
function
|
|
2045
|
+
function getTestFixtures(key) {
|
|
1941
2046
|
return testFixtureMap.get(key);
|
|
1942
2047
|
}
|
|
1943
2048
|
function setHooks(key, hooks) {
|
|
@@ -1946,165 +2051,290 @@ function setHooks(key, hooks) {
|
|
|
1946
2051
|
function getHooks(key) {
|
|
1947
2052
|
return hooksMap.get(key);
|
|
1948
2053
|
}
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
}
|
|
1964
|
-
return Object.values(newFixtures);
|
|
1965
|
-
}
|
|
1966
|
-
function mergeContextFixtures(fixtures, context, runner2) {
|
|
1967
|
-
const fixtureOptionKeys = [
|
|
2054
|
+
var TestFixtures = class _TestFixtures {
|
|
2055
|
+
_suiteContexts;
|
|
2056
|
+
_overrides = /* @__PURE__ */ new WeakMap();
|
|
2057
|
+
_registrations;
|
|
2058
|
+
static _definitions = [];
|
|
2059
|
+
static _builtinFixtures = [
|
|
2060
|
+
"task",
|
|
2061
|
+
"signal",
|
|
2062
|
+
"onTestFailed",
|
|
2063
|
+
"onTestFinished",
|
|
2064
|
+
"skip",
|
|
2065
|
+
"annotate"
|
|
2066
|
+
];
|
|
2067
|
+
static _fixtureOptionKeys = [
|
|
1968
2068
|
"auto",
|
|
1969
2069
|
"injected",
|
|
1970
2070
|
"scope"
|
|
1971
2071
|
];
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
2072
|
+
static _fixtureScopes = [
|
|
2073
|
+
"test",
|
|
2074
|
+
"file",
|
|
2075
|
+
"worker"
|
|
2076
|
+
];
|
|
2077
|
+
static _workerContextSuite = { type: "worker" };
|
|
2078
|
+
static clearDefinitions() {
|
|
2079
|
+
_TestFixtures._definitions.length = 0;
|
|
2080
|
+
}
|
|
2081
|
+
static getWorkerContexts() {
|
|
2082
|
+
return _TestFixtures._definitions.map((f3) => f3.getWorkerContext());
|
|
2083
|
+
}
|
|
2084
|
+
static getFileContexts(file) {
|
|
2085
|
+
return _TestFixtures._definitions.map((f3) => f3.getFileContext(file));
|
|
2086
|
+
}
|
|
2087
|
+
constructor(registrations) {
|
|
2088
|
+
this._registrations = registrations ?? /* @__PURE__ */ new Map();
|
|
2089
|
+
this._suiteContexts = /* @__PURE__ */ new WeakMap();
|
|
2090
|
+
_TestFixtures._definitions.push(this);
|
|
2091
|
+
}
|
|
2092
|
+
extend(runner2, userFixtures) {
|
|
2093
|
+
const { suite: suite2 } = getCurrentSuite();
|
|
2094
|
+
const isTopLevel = !suite2 || suite2.file === suite2;
|
|
2095
|
+
const registrations = this.parseUserFixtures(runner2, userFixtures, isTopLevel);
|
|
2096
|
+
return new _TestFixtures(registrations);
|
|
2097
|
+
}
|
|
2098
|
+
get(suite2) {
|
|
2099
|
+
let currentSuite = suite2;
|
|
2100
|
+
while (currentSuite) {
|
|
2101
|
+
const overrides = this._overrides.get(currentSuite);
|
|
2102
|
+
if (overrides) {
|
|
2103
|
+
return overrides;
|
|
2104
|
+
}
|
|
2105
|
+
if (currentSuite === currentSuite.file) {
|
|
2106
|
+
break;
|
|
2107
|
+
}
|
|
2108
|
+
currentSuite = currentSuite.suite || currentSuite.file;
|
|
2109
|
+
}
|
|
2110
|
+
return this._registrations;
|
|
2111
|
+
}
|
|
2112
|
+
override(runner2, userFixtures) {
|
|
2113
|
+
const { suite: currentSuite, file } = getCurrentSuite();
|
|
2114
|
+
const suite2 = currentSuite || file;
|
|
2115
|
+
const isTopLevel = !currentSuite || currentSuite.file === currentSuite;
|
|
2116
|
+
const suiteRegistrations = new Map(this.get(suite2));
|
|
2117
|
+
const registrations = this.parseUserFixtures(runner2, userFixtures, isTopLevel, suiteRegistrations);
|
|
2118
|
+
if (isTopLevel) {
|
|
2119
|
+
this._registrations = registrations;
|
|
2120
|
+
} else {
|
|
2121
|
+
this._overrides.set(suite2, registrations);
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
getFileContext(file) {
|
|
2125
|
+
if (!this._suiteContexts.has(file)) {
|
|
2126
|
+
this._suiteContexts.set(file, /* @__PURE__ */ Object.create(null));
|
|
2127
|
+
}
|
|
2128
|
+
return this._suiteContexts.get(file);
|
|
2129
|
+
}
|
|
2130
|
+
getWorkerContext() {
|
|
2131
|
+
if (!this._suiteContexts.has(_TestFixtures._workerContextSuite)) {
|
|
2132
|
+
this._suiteContexts.set(_TestFixtures._workerContextSuite, /* @__PURE__ */ Object.create(null));
|
|
2133
|
+
}
|
|
2134
|
+
return this._suiteContexts.get(_TestFixtures._workerContextSuite);
|
|
1992
2135
|
}
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
2136
|
+
parseUserFixtures(runner2, userFixtures, supportNonTest, registrations = new Map(this._registrations)) {
|
|
2137
|
+
const errors = [];
|
|
2138
|
+
Object.entries(userFixtures).forEach(([name, fn]) => {
|
|
2139
|
+
let options;
|
|
2140
|
+
let value;
|
|
2141
|
+
let _options;
|
|
2142
|
+
if (Array.isArray(fn) && fn.length >= 2 && isObject(fn[1]) && Object.keys(fn[1]).some((key) => _TestFixtures._fixtureOptionKeys.includes(key))) {
|
|
2143
|
+
_options = fn[1];
|
|
2144
|
+
options = {
|
|
2145
|
+
auto: _options.auto ?? false,
|
|
2146
|
+
scope: _options.scope ?? "test",
|
|
2147
|
+
injected: _options.injected ?? false
|
|
2148
|
+
};
|
|
2149
|
+
value = options.injected ? runner2.injectValue?.(name) ?? fn[0] : fn[0];
|
|
2150
|
+
} else {
|
|
2151
|
+
value = fn;
|
|
1998
2152
|
}
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
(
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
}
|
|
2153
|
+
const parent = registrations.get(name);
|
|
2154
|
+
if (parent && options) {
|
|
2155
|
+
if (parent.scope !== options.scope) {
|
|
2156
|
+
errors.push(new FixtureDependencyError(`The "${name}" fixture was already registered with a "${options.scope}" scope.`));
|
|
2157
|
+
}
|
|
2158
|
+
if (parent.auto !== options.auto) {
|
|
2159
|
+
errors.push(new FixtureDependencyError(`The "${name}" fixture was already registered as { auto: ${options.auto} }.`));
|
|
2160
|
+
}
|
|
2161
|
+
} else if (parent) {
|
|
2162
|
+
options = {
|
|
2163
|
+
auto: parent.auto,
|
|
2164
|
+
scope: parent.scope,
|
|
2165
|
+
injected: parent.injected
|
|
2166
|
+
};
|
|
2167
|
+
} else if (!options) {
|
|
2168
|
+
options = {
|
|
2169
|
+
auto: false,
|
|
2170
|
+
injected: false,
|
|
2171
|
+
scope: "test"
|
|
2172
|
+
};
|
|
2173
|
+
}
|
|
2174
|
+
if (options.scope && !_TestFixtures._fixtureScopes.includes(options.scope)) {
|
|
2175
|
+
errors.push(new FixtureDependencyError(`The "${name}" fixture has unknown scope "${options.scope}".`));
|
|
2176
|
+
}
|
|
2177
|
+
if (!supportNonTest && options.scope !== "test") {
|
|
2178
|
+
errors.push(new FixtureDependencyError(`The "${name}" fixture cannot be defined with a ${options.scope} scope${!_options?.scope && parent?.scope ? " (inherited from the base fixture)" : ""} inside the describe block. Define it at the top level of the file instead.`));
|
|
2179
|
+
}
|
|
2180
|
+
const deps = isFixtureFunction(value) ? getUsedProps(value) : /* @__PURE__ */ new Set();
|
|
2181
|
+
const item = {
|
|
2182
|
+
name,
|
|
2183
|
+
value,
|
|
2184
|
+
auto: options.auto ?? false,
|
|
2185
|
+
injected: options.injected ?? false,
|
|
2186
|
+
scope: options.scope ?? "test",
|
|
2187
|
+
deps,
|
|
2188
|
+
parent
|
|
2189
|
+
};
|
|
2190
|
+
registrations.set(name, item);
|
|
2191
|
+
if (item.scope === "worker" && (runner2.pool === "vmThreads" || runner2.pool === "vmForks")) {
|
|
2192
|
+
item.scope = "file";
|
|
2193
|
+
}
|
|
2194
|
+
});
|
|
2195
|
+
for (const fixture of registrations.values()) {
|
|
2196
|
+
for (const depName of fixture.deps) {
|
|
2197
|
+
if (_TestFixtures._builtinFixtures.includes(depName)) {
|
|
2198
|
+
continue;
|
|
2199
|
+
}
|
|
2200
|
+
const dep = registrations.get(depName);
|
|
2201
|
+
if (!dep) {
|
|
2202
|
+
errors.push(new FixtureDependencyError(`The "${fixture.name}" fixture depends on unknown fixture "${depName}".`));
|
|
2203
|
+
continue;
|
|
2204
|
+
}
|
|
2205
|
+
if (depName === fixture.name && !fixture.parent) {
|
|
2206
|
+
errors.push(new FixtureDependencyError(`The "${fixture.name}" fixture depends on itself, but does not have a base implementation.`));
|
|
2207
|
+
continue;
|
|
2208
|
+
}
|
|
2209
|
+
if (_TestFixtures._fixtureScopes.indexOf(fixture.scope) > _TestFixtures._fixtureScopes.indexOf(dep.scope)) {
|
|
2210
|
+
errors.push(new FixtureDependencyError(`The ${fixture.scope} "${fixture.name}" fixture cannot depend on a ${dep.scope} fixture "${dep.name}".`));
|
|
2211
|
+
continue;
|
|
2212
|
+
}
|
|
2013
2213
|
}
|
|
2014
2214
|
}
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
}
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2215
|
+
if (errors.length === 1) {
|
|
2216
|
+
throw errors[0];
|
|
2217
|
+
} else if (errors.length > 1) {
|
|
2218
|
+
throw new AggregateError(errors, "Cannot resolve user fixtures. See errors for more information.");
|
|
2219
|
+
}
|
|
2220
|
+
return registrations;
|
|
2221
|
+
}
|
|
2222
|
+
};
|
|
2223
|
+
var cleanupFnArrayMap = /* @__PURE__ */ new WeakMap();
|
|
2224
|
+
var contextHasFixturesCache = /* @__PURE__ */ new WeakMap();
|
|
2225
|
+
function withFixtures(fn, options) {
|
|
2226
|
+
const collector = getCurrentSuite();
|
|
2227
|
+
const suite2 = options?.suite || collector.suite || collector.file;
|
|
2228
|
+
return async (hookContext) => {
|
|
2229
|
+
const context = hookContext || options?.context;
|
|
2023
2230
|
if (!context) {
|
|
2231
|
+
if (options?.suiteHook) {
|
|
2232
|
+
validateSuiteHook(fn, options.suiteHook, options.stackTraceError);
|
|
2233
|
+
}
|
|
2024
2234
|
return fn({});
|
|
2025
2235
|
}
|
|
2026
|
-
const fixtures =
|
|
2027
|
-
if (!
|
|
2236
|
+
const fixtures = options?.fixtures || getTestFixtures(context);
|
|
2237
|
+
if (!fixtures) {
|
|
2028
2238
|
return fn(context);
|
|
2029
2239
|
}
|
|
2030
|
-
const
|
|
2031
|
-
|
|
2032
|
-
if (!usedProps.length && !hasAutoFixture) {
|
|
2240
|
+
const registrations = fixtures.get(suite2);
|
|
2241
|
+
if (!registrations.size) {
|
|
2033
2242
|
return fn(context);
|
|
2034
2243
|
}
|
|
2035
|
-
|
|
2036
|
-
|
|
2244
|
+
const usedFixtures = [];
|
|
2245
|
+
const usedProps = getUsedProps(fn);
|
|
2246
|
+
for (const fixture of registrations.values()) {
|
|
2247
|
+
if (fixture.auto || usedProps.has(fixture.name)) {
|
|
2248
|
+
usedFixtures.push(fixture);
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
if (!usedFixtures.length) {
|
|
2252
|
+
return fn(context);
|
|
2037
2253
|
}
|
|
2038
|
-
const fixtureValueMap = fixtureValueMaps.get(context);
|
|
2039
2254
|
if (!cleanupFnArrayMap.has(context)) {
|
|
2040
2255
|
cleanupFnArrayMap.set(context, []);
|
|
2041
2256
|
}
|
|
2042
2257
|
const cleanupFnArray = cleanupFnArrayMap.get(context);
|
|
2043
|
-
const
|
|
2044
|
-
const pendingFixtures = resolveDeps(usedFixtures);
|
|
2258
|
+
const pendingFixtures = resolveDeps(usedFixtures, registrations);
|
|
2045
2259
|
if (!pendingFixtures.length) {
|
|
2046
2260
|
return fn(context);
|
|
2047
2261
|
}
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2262
|
+
if (options?.suiteHook) {
|
|
2263
|
+
const testScopedFixtures = pendingFixtures.filter((f3) => f3.scope === "test");
|
|
2264
|
+
if (testScopedFixtures.length > 0) {
|
|
2265
|
+
const fixtureNames = testScopedFixtures.map((f3) => `"${f3.name}"`).join(", ");
|
|
2266
|
+
const alternativeHook = {
|
|
2267
|
+
aroundAll: "aroundEach",
|
|
2268
|
+
beforeAll: "beforeEach",
|
|
2269
|
+
afterAll: "afterEach"
|
|
2270
|
+
};
|
|
2271
|
+
const error = new FixtureDependencyError(`Test-scoped fixtures cannot be used inside ${options.suiteHook} hook. The following fixtures are test-scoped: ${fixtureNames}. Use { scope: 'file' } or { scope: 'worker' } fixtures instead, or move the logic to ${alternativeHook[options.suiteHook]} hook.`);
|
|
2272
|
+
if (options.stackTraceError?.stack) {
|
|
2273
|
+
error.stack = error.message + options.stackTraceError.stack.replace(options.stackTraceError.message, "");
|
|
2052
2274
|
}
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2275
|
+
throw error;
|
|
2276
|
+
}
|
|
2277
|
+
}
|
|
2278
|
+
if (!contextHasFixturesCache.has(context)) {
|
|
2279
|
+
contextHasFixturesCache.set(context, /* @__PURE__ */ new WeakSet());
|
|
2280
|
+
}
|
|
2281
|
+
const cachedFixtures = contextHasFixturesCache.get(context);
|
|
2282
|
+
for (const fixture of pendingFixtures) {
|
|
2283
|
+
if (fixture.scope === "test") {
|
|
2284
|
+
if (cachedFixtures.has(fixture)) {
|
|
2285
|
+
continue;
|
|
2060
2286
|
}
|
|
2287
|
+
cachedFixtures.add(fixture);
|
|
2288
|
+
const resolvedValue = await resolveTestFixtureValue(fixture, context, cleanupFnArray);
|
|
2289
|
+
context[fixture.name] = resolvedValue;
|
|
2290
|
+
cleanupFnArray.push(() => {
|
|
2291
|
+
cachedFixtures.delete(fixture);
|
|
2292
|
+
});
|
|
2293
|
+
} else {
|
|
2294
|
+
const resolvedValue = await resolveScopeFixtureValue(fixtures, suite2, fixture);
|
|
2295
|
+
context[fixture.name] = resolvedValue;
|
|
2061
2296
|
}
|
|
2062
2297
|
}
|
|
2063
|
-
return
|
|
2298
|
+
return fn(context);
|
|
2064
2299
|
};
|
|
2065
2300
|
}
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
if (!fixture.isFn) {
|
|
2072
|
-
var _fixture$prop;
|
|
2073
|
-
fileContext[_fixture$prop = fixture.prop] ?? (fileContext[_fixture$prop] = fixture.value);
|
|
2074
|
-
if (workerContext) {
|
|
2075
|
-
var _fixture$prop2;
|
|
2076
|
-
workerContext[_fixture$prop2 = fixture.prop] ?? (workerContext[_fixture$prop2] = fixture.value);
|
|
2077
|
-
}
|
|
2301
|
+
function isFixtureFunction(value) {
|
|
2302
|
+
return typeof value === "function";
|
|
2303
|
+
}
|
|
2304
|
+
function resolveTestFixtureValue(fixture, context, cleanupFnArray) {
|
|
2305
|
+
if (!isFixtureFunction(fixture.value)) {
|
|
2078
2306
|
return fixture.value;
|
|
2079
2307
|
}
|
|
2080
|
-
|
|
2081
|
-
|
|
2308
|
+
return resolveFixtureFunction(fixture.value, context, cleanupFnArray);
|
|
2309
|
+
}
|
|
2310
|
+
var scopedFixturePromiseCache = /* @__PURE__ */ new WeakMap();
|
|
2311
|
+
async function resolveScopeFixtureValue(fixtures, suite2, fixture) {
|
|
2312
|
+
const workerContext = fixtures.getWorkerContext();
|
|
2313
|
+
const fileContext = fixtures.getFileContext(suite2.file);
|
|
2314
|
+
const fixtureContext = fixture.scope === "worker" ? workerContext : fileContext;
|
|
2315
|
+
if (!isFixtureFunction(fixture.value)) {
|
|
2316
|
+
fixtureContext[fixture.name] = fixture.value;
|
|
2317
|
+
return fixture.value;
|
|
2082
2318
|
}
|
|
2083
|
-
if (
|
|
2084
|
-
return
|
|
2319
|
+
if (fixture.name in fixtureContext) {
|
|
2320
|
+
return fixtureContext[fixture.name];
|
|
2085
2321
|
}
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
if (!workerContext) {
|
|
2089
|
-
throw new TypeError("[@vitest/runner] The worker context is not available in the current test runner. Please, provide the `getWorkerContext` method when initiating the runner.");
|
|
2090
|
-
}
|
|
2091
|
-
fixtureContext = workerContext;
|
|
2092
|
-
} else {
|
|
2093
|
-
fixtureContext = fileContext;
|
|
2094
|
-
}
|
|
2095
|
-
if (fixture.prop in fixtureContext) {
|
|
2096
|
-
return fixtureContext[fixture.prop];
|
|
2322
|
+
if (scopedFixturePromiseCache.has(fixture)) {
|
|
2323
|
+
return scopedFixturePromiseCache.get(fixture);
|
|
2097
2324
|
}
|
|
2098
2325
|
if (!cleanupFnArrayMap.has(fixtureContext)) {
|
|
2099
2326
|
cleanupFnArrayMap.set(fixtureContext, []);
|
|
2100
2327
|
}
|
|
2101
2328
|
const cleanupFnFileArray = cleanupFnArrayMap.get(fixtureContext);
|
|
2102
|
-
const promise = resolveFixtureFunction(fixture.value,
|
|
2103
|
-
|
|
2104
|
-
|
|
2329
|
+
const promise = resolveFixtureFunction(fixture.value, fixture.scope === "file" ? {
|
|
2330
|
+
...workerContext,
|
|
2331
|
+
...fileContext
|
|
2332
|
+
} : fixtureContext, cleanupFnFileArray).then((value) => {
|
|
2333
|
+
fixtureContext[fixture.name] = value;
|
|
2334
|
+
scopedFixturePromiseCache.delete(fixture);
|
|
2105
2335
|
return value;
|
|
2106
2336
|
});
|
|
2107
|
-
|
|
2337
|
+
scopedFixturePromiseCache.set(fixture, promise);
|
|
2108
2338
|
return promise;
|
|
2109
2339
|
}
|
|
2110
2340
|
async function resolveFixtureFunction(fixtureFn, context, cleanupFnArray) {
|
|
@@ -2128,82 +2358,97 @@ async function resolveFixtureFunction(fixtureFn, context, cleanupFnArray) {
|
|
|
2128
2358
|
});
|
|
2129
2359
|
return useFnArgPromise;
|
|
2130
2360
|
}
|
|
2131
|
-
function resolveDeps(
|
|
2132
|
-
|
|
2361
|
+
function resolveDeps(usedFixtures, registrations, depSet = /* @__PURE__ */ new Set(), pendingFixtures = []) {
|
|
2362
|
+
usedFixtures.forEach((fixture) => {
|
|
2133
2363
|
if (pendingFixtures.includes(fixture)) {
|
|
2134
2364
|
return;
|
|
2135
2365
|
}
|
|
2136
|
-
if (!fixture.
|
|
2366
|
+
if (!isFixtureFunction(fixture.value) || !fixture.deps) {
|
|
2137
2367
|
pendingFixtures.push(fixture);
|
|
2138
2368
|
return;
|
|
2139
2369
|
}
|
|
2140
2370
|
if (depSet.has(fixture)) {
|
|
2141
|
-
|
|
2371
|
+
if (fixture.parent) {
|
|
2372
|
+
fixture = fixture.parent;
|
|
2373
|
+
} else {
|
|
2374
|
+
throw new Error(`Circular fixture dependency detected: ${fixture.name} <- ${[...depSet].reverse().map((d3) => d3.name).join(" <- ")}`);
|
|
2375
|
+
}
|
|
2142
2376
|
}
|
|
2143
2377
|
depSet.add(fixture);
|
|
2144
|
-
resolveDeps(fixture.deps, depSet, pendingFixtures);
|
|
2378
|
+
resolveDeps([...fixture.deps].map((n2) => n2 === fixture.name ? fixture.parent : registrations.get(n2)).filter((n2) => !!n2), registrations, depSet, pendingFixtures);
|
|
2145
2379
|
pendingFixtures.push(fixture);
|
|
2146
2380
|
depSet.clear();
|
|
2147
2381
|
});
|
|
2148
2382
|
return pendingFixtures;
|
|
2149
2383
|
}
|
|
2150
|
-
function
|
|
2151
|
-
|
|
2384
|
+
function validateSuiteHook(fn, hook, suiteError) {
|
|
2385
|
+
const usedProps = getUsedProps(fn, {
|
|
2386
|
+
sourceError: suiteError,
|
|
2387
|
+
suiteHook: hook
|
|
2388
|
+
});
|
|
2389
|
+
if (usedProps.size) {
|
|
2390
|
+
const error = new FixtureAccessError(`The ${hook} hook uses fixtures "${[...usedProps].join('", "')}", but has no access to context. Did you forget to call it as "test.${hook}()" instead of "${hook}()"?
|
|
2391
|
+
If you used internal "suite" task as the first argument previously, access it in the second argument instead. See https://vitest.dev/guide/test-context#suite-level-hooks`);
|
|
2392
|
+
if (suiteError) {
|
|
2393
|
+
error.stack = suiteError.stack?.replace(suiteError.message, error.message);
|
|
2394
|
+
}
|
|
2395
|
+
throw error;
|
|
2396
|
+
}
|
|
2397
|
+
}
|
|
2398
|
+
var kPropsSymbol = /* @__PURE__ */ Symbol("$vitest:fixture-props");
|
|
2399
|
+
var kPropNamesSymbol = /* @__PURE__ */ Symbol("$vitest:fixture-prop-names");
|
|
2400
|
+
function configureProps(fn, options) {
|
|
2401
|
+
Object.defineProperty(fn, kPropsSymbol, {
|
|
2402
|
+
value: options,
|
|
2403
|
+
enumerable: false
|
|
2404
|
+
});
|
|
2405
|
+
}
|
|
2406
|
+
function memoProps(fn, props) {
|
|
2407
|
+
fn[kPropNamesSymbol] = props;
|
|
2408
|
+
return props;
|
|
2409
|
+
}
|
|
2410
|
+
function getUsedProps(fn, { sourceError, suiteHook } = {}) {
|
|
2411
|
+
if (kPropNamesSymbol in fn) {
|
|
2412
|
+
return fn[kPropNamesSymbol];
|
|
2413
|
+
}
|
|
2414
|
+
const { index: fixturesIndex = 0, original: implementation = fn } = kPropsSymbol in fn ? fn[kPropsSymbol] : {};
|
|
2415
|
+
let fnString = filterOutComments(implementation.toString());
|
|
2152
2416
|
if (/__async\((?:this|null), (?:null|arguments|\[[_0-9, ]*\]), function\*/.test(fnString)) {
|
|
2153
2417
|
fnString = fnString.split(/__async\((?:this|null),/)[1];
|
|
2154
2418
|
}
|
|
2155
2419
|
const match = fnString.match(/[^(]*\(([^)]*)/);
|
|
2156
2420
|
if (!match) {
|
|
2157
|
-
return
|
|
2421
|
+
return memoProps(fn, /* @__PURE__ */ new Set());
|
|
2158
2422
|
}
|
|
2159
2423
|
const args = splitByComma(match[1]);
|
|
2160
2424
|
if (!args.length) {
|
|
2161
|
-
return
|
|
2425
|
+
return memoProps(fn, /* @__PURE__ */ new Set());
|
|
2162
2426
|
}
|
|
2163
|
-
|
|
2164
|
-
if (
|
|
2165
|
-
|
|
2166
|
-
if (!first) {
|
|
2167
|
-
return [];
|
|
2168
|
-
}
|
|
2427
|
+
const fixturesArgument = args[fixturesIndex];
|
|
2428
|
+
if (!fixturesArgument) {
|
|
2429
|
+
return memoProps(fn, /* @__PURE__ */ new Set());
|
|
2169
2430
|
}
|
|
2170
|
-
if (!(
|
|
2171
|
-
|
|
2431
|
+
if (!(fixturesArgument[0] === "{" && fixturesArgument.endsWith("}"))) {
|
|
2432
|
+
const ordinalArgument = ordinal(fixturesIndex + 1);
|
|
2433
|
+
const error = new FixtureParseError(`The ${ordinalArgument} argument inside a fixture must use object destructuring pattern, e.g. ({ task } => {}). Instead, received "${fixturesArgument}".${suiteHook ? ` If you used internal "suite" task as the ${ordinalArgument} argument previously, access it in the ${ordinal(fixturesIndex + 2)} argument instead.` : ""}`);
|
|
2434
|
+
if (sourceError) {
|
|
2435
|
+
error.stack = sourceError.stack?.replace(sourceError.message, error.message);
|
|
2436
|
+
}
|
|
2437
|
+
throw error;
|
|
2172
2438
|
}
|
|
2173
|
-
const _first =
|
|
2439
|
+
const _first = fixturesArgument.slice(1, -1).replace(/\s/g, "");
|
|
2174
2440
|
const props = splitByComma(_first).map((prop) => {
|
|
2175
2441
|
return prop.replace(/:.*|=.*/g, "");
|
|
2176
2442
|
});
|
|
2177
2443
|
const last = props.at(-1);
|
|
2178
2444
|
if (last && last.startsWith("...")) {
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
}
|
|
2183
|
-
function filterOutComments(s3) {
|
|
2184
|
-
const result = [];
|
|
2185
|
-
let commentState = "none";
|
|
2186
|
-
for (let i3 = 0; i3 < s3.length; ++i3) {
|
|
2187
|
-
if (commentState === "singleline") {
|
|
2188
|
-
if (s3[i3] === "\n") {
|
|
2189
|
-
commentState = "none";
|
|
2190
|
-
}
|
|
2191
|
-
} else if (commentState === "multiline") {
|
|
2192
|
-
if (s3[i3 - 1] === "*" && s3[i3] === "/") {
|
|
2193
|
-
commentState = "none";
|
|
2194
|
-
}
|
|
2195
|
-
} else if (commentState === "none") {
|
|
2196
|
-
if (s3[i3] === "/" && s3[i3 + 1] === "/") {
|
|
2197
|
-
commentState = "singleline";
|
|
2198
|
-
} else if (s3[i3] === "/" && s3[i3 + 1] === "*") {
|
|
2199
|
-
commentState = "multiline";
|
|
2200
|
-
i3 += 2;
|
|
2201
|
-
} else {
|
|
2202
|
-
result.push(s3[i3]);
|
|
2203
|
-
}
|
|
2445
|
+
const error = new FixtureParseError(`Rest parameters are not supported in fixtures, received "${last}".`);
|
|
2446
|
+
if (sourceError) {
|
|
2447
|
+
error.stack = sourceError.stack?.replace(sourceError.message, error.message);
|
|
2204
2448
|
}
|
|
2449
|
+
throw error;
|
|
2205
2450
|
}
|
|
2206
|
-
return
|
|
2451
|
+
return memoProps(fn, new Set(props));
|
|
2207
2452
|
}
|
|
2208
2453
|
function splitByComma(s3) {
|
|
2209
2454
|
const result = [];
|
|
@@ -2237,40 +2482,99 @@ function getDefaultHookTimeout() {
|
|
|
2237
2482
|
}
|
|
2238
2483
|
var CLEANUP_TIMEOUT_KEY = /* @__PURE__ */ Symbol.for("VITEST_CLEANUP_TIMEOUT");
|
|
2239
2484
|
var CLEANUP_STACK_TRACE_KEY = /* @__PURE__ */ Symbol.for("VITEST_CLEANUP_STACK_TRACE");
|
|
2485
|
+
var AROUND_TIMEOUT_KEY = /* @__PURE__ */ Symbol.for("VITEST_AROUND_TIMEOUT");
|
|
2486
|
+
var AROUND_STACK_TRACE_KEY = /* @__PURE__ */ Symbol.for("VITEST_AROUND_STACK_TRACE");
|
|
2240
2487
|
function beforeAll(fn, timeout = getDefaultHookTimeout()) {
|
|
2241
2488
|
assertTypes(fn, '"beforeAll" callback', ["function"]);
|
|
2242
2489
|
const stackTraceError = new Error("STACK_TRACE_ERROR");
|
|
2243
|
-
|
|
2490
|
+
const context = getChainableContext(this);
|
|
2491
|
+
return getCurrentSuite().on("beforeAll", Object.assign(withTimeout(withSuiteFixtures("beforeAll", fn, context, stackTraceError), timeout, true, stackTraceError), {
|
|
2244
2492
|
[CLEANUP_TIMEOUT_KEY]: timeout,
|
|
2245
2493
|
[CLEANUP_STACK_TRACE_KEY]: stackTraceError
|
|
2246
2494
|
}));
|
|
2247
2495
|
}
|
|
2248
2496
|
function afterAll(fn, timeout) {
|
|
2249
2497
|
assertTypes(fn, '"afterAll" callback', ["function"]);
|
|
2250
|
-
|
|
2498
|
+
const context = getChainableContext(this);
|
|
2499
|
+
const stackTraceError = new Error("STACK_TRACE_ERROR");
|
|
2500
|
+
return getCurrentSuite().on("afterAll", withTimeout(withSuiteFixtures("afterAll", fn, context, stackTraceError), timeout ?? getDefaultHookTimeout(), true, stackTraceError));
|
|
2251
2501
|
}
|
|
2252
2502
|
function beforeEach(fn, timeout = getDefaultHookTimeout()) {
|
|
2253
2503
|
assertTypes(fn, '"beforeEach" callback', ["function"]);
|
|
2254
2504
|
const stackTraceError = new Error("STACK_TRACE_ERROR");
|
|
2255
|
-
const
|
|
2256
|
-
|
|
2505
|
+
const wrapper = (context, suite2) => {
|
|
2506
|
+
const fixtureResolver = withFixtures(fn, { suite: suite2 });
|
|
2507
|
+
return fixtureResolver(context);
|
|
2508
|
+
};
|
|
2509
|
+
return getCurrentSuite().on("beforeEach", Object.assign(withTimeout(wrapper, timeout ?? getDefaultHookTimeout(), true, stackTraceError, abortIfTimeout), {
|
|
2257
2510
|
[CLEANUP_TIMEOUT_KEY]: timeout,
|
|
2258
2511
|
[CLEANUP_STACK_TRACE_KEY]: stackTraceError
|
|
2259
2512
|
}));
|
|
2260
2513
|
}
|
|
2261
2514
|
function afterEach(fn, timeout) {
|
|
2262
2515
|
assertTypes(fn, '"afterEach" callback', ["function"]);
|
|
2263
|
-
const
|
|
2264
|
-
|
|
2516
|
+
const wrapper = (context, suite2) => {
|
|
2517
|
+
const fixtureResolver = withFixtures(fn, { suite: suite2 });
|
|
2518
|
+
return fixtureResolver(context);
|
|
2519
|
+
};
|
|
2520
|
+
return getCurrentSuite().on("afterEach", withTimeout(wrapper, timeout ?? getDefaultHookTimeout(), true, new Error("STACK_TRACE_ERROR"), abortIfTimeout));
|
|
2265
2521
|
}
|
|
2266
2522
|
var onTestFailed = createTestHook("onTestFailed", (test3, handler, timeout) => {
|
|
2267
|
-
test3.onFailed
|
|
2523
|
+
test3.onFailed ||= [];
|
|
2268
2524
|
test3.onFailed.push(withTimeout(handler, timeout ?? getDefaultHookTimeout(), true, new Error("STACK_TRACE_ERROR"), abortIfTimeout));
|
|
2269
2525
|
});
|
|
2270
2526
|
var onTestFinished = createTestHook("onTestFinished", (test3, handler, timeout) => {
|
|
2271
|
-
test3.onFinished
|
|
2527
|
+
test3.onFinished ||= [];
|
|
2272
2528
|
test3.onFinished.push(withTimeout(handler, timeout ?? getDefaultHookTimeout(), true, new Error("STACK_TRACE_ERROR"), abortIfTimeout));
|
|
2273
2529
|
});
|
|
2530
|
+
function aroundAll(fn, timeout) {
|
|
2531
|
+
assertTypes(fn, '"aroundAll" callback', ["function"]);
|
|
2532
|
+
const stackTraceError = new Error("STACK_TRACE_ERROR");
|
|
2533
|
+
const resolvedTimeout = timeout ?? getDefaultHookTimeout();
|
|
2534
|
+
const context = getChainableContext(this);
|
|
2535
|
+
return getCurrentSuite().on("aroundAll", Object.assign(withSuiteFixtures("aroundAll", fn, context, stackTraceError, 1), {
|
|
2536
|
+
[AROUND_TIMEOUT_KEY]: resolvedTimeout,
|
|
2537
|
+
[AROUND_STACK_TRACE_KEY]: stackTraceError
|
|
2538
|
+
}));
|
|
2539
|
+
}
|
|
2540
|
+
function aroundEach(fn, timeout) {
|
|
2541
|
+
assertTypes(fn, '"aroundEach" callback', ["function"]);
|
|
2542
|
+
const stackTraceError = new Error("STACK_TRACE_ERROR");
|
|
2543
|
+
const resolvedTimeout = timeout ?? getDefaultHookTimeout();
|
|
2544
|
+
const wrapper = (runTest, context, suite2) => {
|
|
2545
|
+
const innerFn = (ctx) => fn(runTest, ctx, suite2);
|
|
2546
|
+
configureProps(innerFn, {
|
|
2547
|
+
index: 1,
|
|
2548
|
+
original: fn
|
|
2549
|
+
});
|
|
2550
|
+
const fixtureResolver = withFixtures(innerFn, { suite: suite2 });
|
|
2551
|
+
return fixtureResolver(context);
|
|
2552
|
+
};
|
|
2553
|
+
return getCurrentSuite().on("aroundEach", Object.assign(wrapper, {
|
|
2554
|
+
[AROUND_TIMEOUT_KEY]: resolvedTimeout,
|
|
2555
|
+
[AROUND_STACK_TRACE_KEY]: stackTraceError
|
|
2556
|
+
}));
|
|
2557
|
+
}
|
|
2558
|
+
function withSuiteFixtures(suiteHook, fn, context, stackTraceError, contextIndex = 0) {
|
|
2559
|
+
return (...args) => {
|
|
2560
|
+
const suite2 = args.at(-1);
|
|
2561
|
+
const prefix = args.slice(0, -1);
|
|
2562
|
+
const wrapper = (ctx) => fn(...prefix, ctx, suite2);
|
|
2563
|
+
configureProps(wrapper, {
|
|
2564
|
+
index: contextIndex,
|
|
2565
|
+
original: fn
|
|
2566
|
+
});
|
|
2567
|
+
const fixtures = context?.getFixtures();
|
|
2568
|
+
const fileContext = fixtures?.getFileContext(suite2.file);
|
|
2569
|
+
const fixtured = withFixtures(wrapper, {
|
|
2570
|
+
suiteHook,
|
|
2571
|
+
fixtures,
|
|
2572
|
+
context: fileContext,
|
|
2573
|
+
stackTraceError
|
|
2574
|
+
});
|
|
2575
|
+
return fixtured();
|
|
2576
|
+
};
|
|
2577
|
+
}
|
|
2274
2578
|
function createTestHook(name, handler) {
|
|
2275
2579
|
return (fn, timeout) => {
|
|
2276
2580
|
assertTypes(fn, `"${name}" callback`, ["function"]);
|
|
@@ -2316,9 +2620,12 @@ function createSuiteHooks() {
|
|
|
2316
2620
|
beforeAll: [],
|
|
2317
2621
|
afterAll: [],
|
|
2318
2622
|
beforeEach: [],
|
|
2319
|
-
afterEach: []
|
|
2623
|
+
afterEach: [],
|
|
2624
|
+
aroundEach: [],
|
|
2625
|
+
aroundAll: []
|
|
2320
2626
|
};
|
|
2321
2627
|
}
|
|
2628
|
+
var POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
|
|
2322
2629
|
function parseArguments(optionsOrFn, timeoutOrTest) {
|
|
2323
2630
|
if (timeoutOrTest != null && typeof timeoutOrTest === "object") {
|
|
2324
2631
|
throw new TypeError(`Signature "test(name, fn, { ... })" was deprecated in Vitest 3 and removed in Vitest 4. Please, provide options as a second argument instead.`);
|
|
@@ -2344,32 +2651,66 @@ function parseArguments(optionsOrFn, timeoutOrTest) {
|
|
|
2344
2651
|
};
|
|
2345
2652
|
}
|
|
2346
2653
|
function createSuiteCollector(name, factory = () => {
|
|
2347
|
-
}, mode, each, suiteOptions
|
|
2654
|
+
}, mode, each, suiteOptions) {
|
|
2348
2655
|
const tasks = [];
|
|
2349
2656
|
let suite2;
|
|
2350
2657
|
initSuite(true);
|
|
2351
2658
|
const task = function(name2 = "", options = {}) {
|
|
2352
|
-
|
|
2353
|
-
const
|
|
2354
|
-
const
|
|
2659
|
+
const currentSuite = collectorContext.currentSuite?.suite;
|
|
2660
|
+
const parentTask = currentSuite ?? collectorContext.currentSuite?.file;
|
|
2661
|
+
const parentTags = parentTask?.tags || [];
|
|
2662
|
+
const testTags = unique([...parentTags, ...toArray(options.tags)]);
|
|
2663
|
+
const tagsOptions = testTags.map((tag) => {
|
|
2664
|
+
const tagDefinition = runner.config.tags?.find((t2) => t2.name === tag);
|
|
2665
|
+
if (!tagDefinition && runner.config.strictTags) {
|
|
2666
|
+
throw createNoTagsError(runner.config.tags, tag);
|
|
2667
|
+
}
|
|
2668
|
+
return tagDefinition;
|
|
2669
|
+
}).filter((r2) => r2 != null).sort((tag1, tag2) => (tag2.priority ?? POSITIVE_INFINITY) - (tag1.priority ?? POSITIVE_INFINITY)).reduce((acc, tag) => {
|
|
2670
|
+
const { name: name3, description, priority, meta, ...options2 } = tag;
|
|
2671
|
+
Object.assign(acc, options2);
|
|
2672
|
+
if (meta) {
|
|
2673
|
+
acc.meta = Object.assign(acc.meta ?? /* @__PURE__ */ Object.create(null), meta);
|
|
2674
|
+
}
|
|
2675
|
+
return acc;
|
|
2676
|
+
}, {});
|
|
2677
|
+
const testOwnMeta = options.meta;
|
|
2678
|
+
options = {
|
|
2679
|
+
...tagsOptions,
|
|
2680
|
+
...options
|
|
2681
|
+
};
|
|
2682
|
+
const timeout = options.timeout ?? runner.config.testTimeout;
|
|
2683
|
+
const parentMeta = currentSuite?.meta;
|
|
2684
|
+
const tagMeta = tagsOptions.meta;
|
|
2685
|
+
const testMeta = /* @__PURE__ */ Object.create(null);
|
|
2686
|
+
if (tagMeta) {
|
|
2687
|
+
Object.assign(testMeta, tagMeta);
|
|
2688
|
+
}
|
|
2689
|
+
if (parentMeta) {
|
|
2690
|
+
Object.assign(testMeta, parentMeta);
|
|
2691
|
+
}
|
|
2692
|
+
if (testOwnMeta) {
|
|
2693
|
+
Object.assign(testMeta, testOwnMeta);
|
|
2694
|
+
}
|
|
2355
2695
|
const task2 = {
|
|
2356
2696
|
id: "",
|
|
2357
2697
|
name: name2,
|
|
2358
|
-
fullName: createTaskName([
|
|
2359
|
-
fullTestName: createTaskName([currentSuite
|
|
2698
|
+
fullName: createTaskName([currentSuite?.fullName ?? collectorContext.currentSuite?.file?.fullName, name2]),
|
|
2699
|
+
fullTestName: createTaskName([currentSuite?.fullTestName, name2]),
|
|
2360
2700
|
suite: currentSuite,
|
|
2361
2701
|
each: options.each,
|
|
2362
2702
|
fails: options.fails,
|
|
2363
2703
|
context: void 0,
|
|
2364
2704
|
type: "test",
|
|
2365
|
-
file:
|
|
2705
|
+
file: currentSuite?.file ?? collectorContext.currentSuite?.file,
|
|
2366
2706
|
timeout,
|
|
2367
2707
|
retry: options.retry ?? runner.config.retry,
|
|
2368
2708
|
repeats: options.repeats,
|
|
2369
2709
|
mode: options.only ? "only" : options.skip ? "skip" : options.todo ? "todo" : "run",
|
|
2370
|
-
meta:
|
|
2710
|
+
meta: testMeta,
|
|
2371
2711
|
annotations: [],
|
|
2372
|
-
artifacts: []
|
|
2712
|
+
artifacts: [],
|
|
2713
|
+
tags: testTags
|
|
2373
2714
|
};
|
|
2374
2715
|
const handler = options.handler;
|
|
2375
2716
|
if (task2.mode === "run" && !handler) {
|
|
@@ -2378,19 +2719,19 @@ function createSuiteCollector(name, factory = () => {
|
|
|
2378
2719
|
if (options.concurrent || !options.sequential && runner.config.sequence.concurrent) {
|
|
2379
2720
|
task2.concurrent = true;
|
|
2380
2721
|
}
|
|
2381
|
-
task2.shuffle = suiteOptions
|
|
2722
|
+
task2.shuffle = suiteOptions?.shuffle;
|
|
2382
2723
|
const context = createTestContext(task2, runner);
|
|
2383
2724
|
Object.defineProperty(task2, "context", {
|
|
2384
2725
|
value: context,
|
|
2385
2726
|
enumerable: false
|
|
2386
2727
|
});
|
|
2387
|
-
setTestFixture(context, options.fixtures);
|
|
2728
|
+
setTestFixture(context, options.fixtures ?? new TestFixtures());
|
|
2388
2729
|
const limit = Error.stackTraceLimit;
|
|
2389
|
-
Error.stackTraceLimit =
|
|
2730
|
+
Error.stackTraceLimit = 10;
|
|
2390
2731
|
const stackTraceError = new Error("STACK_TRACE_ERROR");
|
|
2391
2732
|
Error.stackTraceLimit = limit;
|
|
2392
2733
|
if (handler) {
|
|
2393
|
-
setFn(task2, withTimeout(withAwaitAsyncAssertions(withFixtures(
|
|
2734
|
+
setFn(task2, withTimeout(withCancel(withAwaitAsyncAssertions(withFixtures(handler, { context }), task2), task2.context.signal), timeout, false, stackTraceError, (_, error) => abortIfTimeout([context], error)));
|
|
2394
2735
|
}
|
|
2395
2736
|
if (runner.config.includeTaskLocation) {
|
|
2396
2737
|
const error = stackTraceError.stack;
|
|
@@ -2410,8 +2751,14 @@ function createSuiteCollector(name, factory = () => {
|
|
|
2410
2751
|
if (typeof suiteOptions === "object") {
|
|
2411
2752
|
options = Object.assign({}, suiteOptions, options);
|
|
2412
2753
|
}
|
|
2413
|
-
|
|
2414
|
-
options.
|
|
2754
|
+
const concurrent = this.concurrent ?? (!this.sequential && options?.concurrent);
|
|
2755
|
+
if (options.concurrent != null && concurrent != null) {
|
|
2756
|
+
options.concurrent = concurrent;
|
|
2757
|
+
}
|
|
2758
|
+
const sequential = this.sequential ?? (!this.concurrent && options?.sequential);
|
|
2759
|
+
if (options.sequential != null && sequential != null) {
|
|
2760
|
+
options.sequential = sequential;
|
|
2761
|
+
}
|
|
2415
2762
|
const test4 = task(formatName(name2), {
|
|
2416
2763
|
...this,
|
|
2417
2764
|
...options,
|
|
@@ -2419,7 +2766,6 @@ function createSuiteCollector(name, factory = () => {
|
|
|
2419
2766
|
});
|
|
2420
2767
|
test4.type = "test";
|
|
2421
2768
|
});
|
|
2422
|
-
let collectorFixtures = parentCollectorFixtures;
|
|
2423
2769
|
const collector = {
|
|
2424
2770
|
type: "collector",
|
|
2425
2771
|
name,
|
|
@@ -2427,44 +2773,39 @@ function createSuiteCollector(name, factory = () => {
|
|
|
2427
2773
|
suite: suite2,
|
|
2428
2774
|
options: suiteOptions,
|
|
2429
2775
|
test: test3,
|
|
2776
|
+
file: suite2.file,
|
|
2430
2777
|
tasks,
|
|
2431
2778
|
collect,
|
|
2432
2779
|
task,
|
|
2433
2780
|
clear,
|
|
2434
|
-
on: addHook
|
|
2435
|
-
fixtures() {
|
|
2436
|
-
return collectorFixtures;
|
|
2437
|
-
},
|
|
2438
|
-
scoped(fixtures) {
|
|
2439
|
-
const parsed = mergeContextFixtures(fixtures, { fixtures: collectorFixtures }, runner);
|
|
2440
|
-
if (parsed.fixtures) {
|
|
2441
|
-
collectorFixtures = parsed.fixtures;
|
|
2442
|
-
}
|
|
2443
|
-
}
|
|
2781
|
+
on: addHook
|
|
2444
2782
|
};
|
|
2445
2783
|
function addHook(name2, ...fn) {
|
|
2446
2784
|
getHooks(suite2)[name2].push(...fn);
|
|
2447
2785
|
}
|
|
2448
2786
|
function initSuite(includeLocation) {
|
|
2449
|
-
var _collectorContext$cur4, _collectorContext$cur5, _collectorContext$cur6;
|
|
2450
2787
|
if (typeof suiteOptions === "number") {
|
|
2451
2788
|
suiteOptions = { timeout: suiteOptions };
|
|
2452
2789
|
}
|
|
2453
|
-
const currentSuite =
|
|
2790
|
+
const currentSuite = collectorContext.currentSuite?.suite;
|
|
2791
|
+
const parentTask = currentSuite ?? collectorContext.currentSuite?.file;
|
|
2792
|
+
const suiteTags = toArray(suiteOptions?.tags);
|
|
2793
|
+
validateTags(runner.config, suiteTags);
|
|
2454
2794
|
suite2 = {
|
|
2455
2795
|
id: "",
|
|
2456
2796
|
type: "suite",
|
|
2457
2797
|
name,
|
|
2458
|
-
fullName: createTaskName([
|
|
2459
|
-
fullTestName: createTaskName([currentSuite
|
|
2798
|
+
fullName: createTaskName([currentSuite?.fullName ?? collectorContext.currentSuite?.file?.fullName, name]),
|
|
2799
|
+
fullTestName: createTaskName([currentSuite?.fullTestName, name]),
|
|
2460
2800
|
suite: currentSuite,
|
|
2461
2801
|
mode,
|
|
2462
2802
|
each,
|
|
2463
|
-
file:
|
|
2464
|
-
shuffle: suiteOptions
|
|
2803
|
+
file: currentSuite?.file ?? collectorContext.currentSuite?.file,
|
|
2804
|
+
shuffle: suiteOptions?.shuffle,
|
|
2465
2805
|
tasks: [],
|
|
2466
|
-
meta: /* @__PURE__ */ Object.create(null),
|
|
2467
|
-
concurrent: suiteOptions
|
|
2806
|
+
meta: suiteOptions?.meta ?? /* @__PURE__ */ Object.create(null),
|
|
2807
|
+
concurrent: suiteOptions?.concurrent,
|
|
2808
|
+
tags: unique([...parentTask?.tags || [], ...suiteTags])
|
|
2468
2809
|
};
|
|
2469
2810
|
if (runner && includeLocation && runner.config.includeTaskLocation) {
|
|
2470
2811
|
const limit = Error.stackTraceLimit;
|
|
@@ -2517,32 +2858,43 @@ function withAwaitAsyncAssertions(fn, task) {
|
|
|
2517
2858
|
}
|
|
2518
2859
|
function createSuite() {
|
|
2519
2860
|
function suiteFn(name, factoryOrOptions, optionsOrFactory) {
|
|
2520
|
-
var _currentSuite$options;
|
|
2521
2861
|
if (getCurrentTest()) {
|
|
2522
2862
|
throw new Error("Calling the suite function inside test function is not allowed. It can be only called at the top level or inside another suite function.");
|
|
2523
2863
|
}
|
|
2524
|
-
let mode = this.only ? "only" : this.skip ? "skip" : this.todo ? "todo" : "run";
|
|
2525
2864
|
const currentSuite = collectorContext.currentSuite || defaultSuite;
|
|
2526
2865
|
let { options, handler: factory } = parseArguments(factoryOrOptions, optionsOrFactory);
|
|
2527
|
-
if (mode === "run" && !factory) {
|
|
2528
|
-
mode = "todo";
|
|
2529
|
-
}
|
|
2530
2866
|
const isConcurrentSpecified = options.concurrent || this.concurrent || options.sequential === false;
|
|
2531
2867
|
const isSequentialSpecified = options.sequential || this.sequential || options.concurrent === false;
|
|
2868
|
+
const { meta: parentMeta, ...parentOptions } = currentSuite?.options || {};
|
|
2532
2869
|
options = {
|
|
2533
|
-
...
|
|
2534
|
-
...options
|
|
2535
|
-
shuffle: this.shuffle ?? options.shuffle ?? (currentSuite === null || currentSuite === void 0 || (_currentSuite$options = currentSuite.options) === null || _currentSuite$options === void 0 ? void 0 : _currentSuite$options.shuffle) ?? (runner === null || runner === void 0 ? void 0 : runner.config.sequence.shuffle)
|
|
2870
|
+
...parentOptions,
|
|
2871
|
+
...options
|
|
2536
2872
|
};
|
|
2873
|
+
const shuffle2 = this.shuffle ?? options.shuffle ?? currentSuite?.options?.shuffle ?? runner?.config.sequence.shuffle;
|
|
2874
|
+
if (shuffle2 != null) {
|
|
2875
|
+
options.shuffle = shuffle2;
|
|
2876
|
+
}
|
|
2877
|
+
let mode = this.only ?? options.only ? "only" : this.skip ?? options.skip ? "skip" : this.todo ?? options.todo ? "todo" : "run";
|
|
2878
|
+
if (mode === "run" && !factory) {
|
|
2879
|
+
mode = "todo";
|
|
2880
|
+
}
|
|
2537
2881
|
const isConcurrent = isConcurrentSpecified || options.concurrent && !isSequentialSpecified;
|
|
2538
2882
|
const isSequential = isSequentialSpecified || options.sequential && !isConcurrentSpecified;
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2883
|
+
if (isConcurrent != null) {
|
|
2884
|
+
options.concurrent = isConcurrent && !isSequential;
|
|
2885
|
+
}
|
|
2886
|
+
if (isSequential != null) {
|
|
2887
|
+
options.sequential = isSequential && !isConcurrent;
|
|
2888
|
+
}
|
|
2889
|
+
if (parentMeta) {
|
|
2890
|
+
options.meta = Object.assign(/* @__PURE__ */ Object.create(null), parentMeta, options.meta);
|
|
2891
|
+
}
|
|
2892
|
+
return createSuiteCollector(formatName(name), factory, mode, this.each, options);
|
|
2542
2893
|
}
|
|
2543
2894
|
suiteFn.each = function(cases, ...args) {
|
|
2544
|
-
const
|
|
2545
|
-
|
|
2895
|
+
const context = getChainableContext(this);
|
|
2896
|
+
const suite2 = context.withContext();
|
|
2897
|
+
context.setContext("each", true);
|
|
2546
2898
|
if (Array.isArray(cases) && args.length) {
|
|
2547
2899
|
cases = formatTemplateString(cases, args);
|
|
2548
2900
|
}
|
|
@@ -2567,7 +2919,7 @@ function createSuite() {
|
|
|
2567
2919
|
}
|
|
2568
2920
|
}
|
|
2569
2921
|
});
|
|
2570
|
-
|
|
2922
|
+
context.setContext("each", void 0);
|
|
2571
2923
|
};
|
|
2572
2924
|
};
|
|
2573
2925
|
suiteFn.for = function(cases, ...args) {
|
|
@@ -2593,11 +2945,12 @@ function createSuite() {
|
|
|
2593
2945
|
"todo"
|
|
2594
2946
|
], suiteFn);
|
|
2595
2947
|
}
|
|
2596
|
-
function createTaskCollector(fn
|
|
2948
|
+
function createTaskCollector(fn) {
|
|
2597
2949
|
const taskFn = fn;
|
|
2598
2950
|
taskFn.each = function(cases, ...args) {
|
|
2599
|
-
const
|
|
2600
|
-
|
|
2951
|
+
const context = getChainableContext(this);
|
|
2952
|
+
const test3 = context.withContext();
|
|
2953
|
+
context.setContext("each", true);
|
|
2601
2954
|
if (Array.isArray(cases) && args.length) {
|
|
2602
2955
|
cases = formatTemplateString(cases, args);
|
|
2603
2956
|
}
|
|
@@ -2622,11 +2975,12 @@ function createTaskCollector(fn, context) {
|
|
|
2622
2975
|
}
|
|
2623
2976
|
}
|
|
2624
2977
|
});
|
|
2625
|
-
|
|
2978
|
+
context.setContext("each", void 0);
|
|
2626
2979
|
};
|
|
2627
2980
|
};
|
|
2628
2981
|
taskFn.for = function(cases, ...args) {
|
|
2629
|
-
const
|
|
2982
|
+
const context = getChainableContext(this);
|
|
2983
|
+
const test3 = context.withContext();
|
|
2630
2984
|
if (Array.isArray(cases) && args.length) {
|
|
2631
2985
|
cases = formatTemplateString(cases, args);
|
|
2632
2986
|
}
|
|
@@ -2636,8 +2990,10 @@ function createTaskCollector(fn, context) {
|
|
|
2636
2990
|
cases.forEach((item, idx) => {
|
|
2637
2991
|
const handlerWrapper = handler ? (ctx) => handler(item, ctx) : void 0;
|
|
2638
2992
|
if (handlerWrapper) {
|
|
2639
|
-
handlerWrapper
|
|
2640
|
-
|
|
2993
|
+
configureProps(handlerWrapper, {
|
|
2994
|
+
index: 1,
|
|
2995
|
+
original: handler
|
|
2996
|
+
});
|
|
2641
2997
|
}
|
|
2642
2998
|
test3(formatTitle(_name, toArray(item), idx), options, handlerWrapper);
|
|
2643
2999
|
});
|
|
@@ -2649,27 +3005,78 @@ function createTaskCollector(fn, context) {
|
|
|
2649
3005
|
taskFn.runIf = function(condition) {
|
|
2650
3006
|
return condition ? this : this.skip;
|
|
2651
3007
|
};
|
|
3008
|
+
function parseBuilderFixtures(fixturesOrName, optionsOrFn, maybeFn) {
|
|
3009
|
+
if (typeof fixturesOrName !== "string") {
|
|
3010
|
+
return fixturesOrName;
|
|
3011
|
+
}
|
|
3012
|
+
const fixtureName = fixturesOrName;
|
|
3013
|
+
let fixtureOptions;
|
|
3014
|
+
let fixtureValue;
|
|
3015
|
+
if (maybeFn !== void 0) {
|
|
3016
|
+
fixtureOptions = optionsOrFn;
|
|
3017
|
+
fixtureValue = maybeFn;
|
|
3018
|
+
} else {
|
|
3019
|
+
if (optionsOrFn !== null && typeof optionsOrFn === "object" && !Array.isArray(optionsOrFn) && ("scope" in optionsOrFn || "auto" in optionsOrFn)) {
|
|
3020
|
+
fixtureOptions = optionsOrFn;
|
|
3021
|
+
fixtureValue = {};
|
|
3022
|
+
} else {
|
|
3023
|
+
fixtureOptions = void 0;
|
|
3024
|
+
fixtureValue = optionsOrFn;
|
|
3025
|
+
}
|
|
3026
|
+
}
|
|
3027
|
+
if (typeof fixtureValue === "function") {
|
|
3028
|
+
const builderFn = fixtureValue;
|
|
3029
|
+
const fixture = async (ctx, use) => {
|
|
3030
|
+
let cleanup;
|
|
3031
|
+
const onCleanup = (fn2) => {
|
|
3032
|
+
if (cleanup !== void 0) {
|
|
3033
|
+
throw new Error(`onCleanup can only be called once per fixture. Define separate fixtures if you need multiple cleanup functions.`);
|
|
3034
|
+
}
|
|
3035
|
+
cleanup = fn2;
|
|
3036
|
+
};
|
|
3037
|
+
const value = await builderFn(ctx, { onCleanup });
|
|
3038
|
+
await use(value);
|
|
3039
|
+
if (cleanup) {
|
|
3040
|
+
await cleanup();
|
|
3041
|
+
}
|
|
3042
|
+
};
|
|
3043
|
+
configureProps(fixture, { original: builderFn });
|
|
3044
|
+
if (fixtureOptions) {
|
|
3045
|
+
return { [fixtureName]: [fixture, fixtureOptions] };
|
|
3046
|
+
}
|
|
3047
|
+
return { [fixtureName]: fixture };
|
|
3048
|
+
}
|
|
3049
|
+
if (fixtureOptions) {
|
|
3050
|
+
return { [fixtureName]: [fixtureValue, fixtureOptions] };
|
|
3051
|
+
}
|
|
3052
|
+
return { [fixtureName]: fixtureValue };
|
|
3053
|
+
}
|
|
3054
|
+
taskFn.override = function(fixturesOrName, optionsOrFn, maybeFn) {
|
|
3055
|
+
const userFixtures = parseBuilderFixtures(fixturesOrName, optionsOrFn, maybeFn);
|
|
3056
|
+
getChainableContext(this).getFixtures().override(runner, userFixtures);
|
|
3057
|
+
return this;
|
|
3058
|
+
};
|
|
2652
3059
|
taskFn.scoped = function(fixtures) {
|
|
2653
|
-
|
|
2654
|
-
|
|
3060
|
+
console.warn(`test.scoped() is deprecated and will be removed in future versions. Please use test.override() instead.`);
|
|
3061
|
+
return this.override(fixtures);
|
|
2655
3062
|
};
|
|
2656
|
-
taskFn.extend = function(
|
|
2657
|
-
const
|
|
2658
|
-
const
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
context2.fixtures = mergeScopedFixtures(context2.fixtures || [], scopedFixtures);
|
|
2665
|
-
}
|
|
2666
|
-
originalWrapper.call(context2, formatName(name), optionsOrFn, optionsOrTest);
|
|
2667
|
-
}, _context);
|
|
3063
|
+
taskFn.extend = function(fixturesOrName, optionsOrFn, maybeFn) {
|
|
3064
|
+
const userFixtures = parseBuilderFixtures(fixturesOrName, optionsOrFn, maybeFn);
|
|
3065
|
+
const fixtures = getChainableContext(this).getFixtures().extend(runner, userFixtures);
|
|
3066
|
+
const _test3 = createTest(function(name, optionsOrFn2, optionsOrTest) {
|
|
3067
|
+
fn.call(this, formatName(name), optionsOrFn2, optionsOrTest);
|
|
3068
|
+
});
|
|
3069
|
+
getChainableContext(_test3).mergeContext({ fixtures });
|
|
3070
|
+
return _test3;
|
|
2668
3071
|
};
|
|
3072
|
+
taskFn.describe = suite;
|
|
3073
|
+
taskFn.suite = suite;
|
|
2669
3074
|
taskFn.beforeEach = beforeEach;
|
|
2670
3075
|
taskFn.afterEach = afterEach;
|
|
2671
3076
|
taskFn.beforeAll = beforeAll;
|
|
2672
3077
|
taskFn.afterAll = afterAll;
|
|
3078
|
+
taskFn.aroundEach = aroundEach;
|
|
3079
|
+
taskFn.aroundAll = aroundAll;
|
|
2673
3080
|
const _test2 = createChainable([
|
|
2674
3081
|
"concurrent",
|
|
2675
3082
|
"sequential",
|
|
@@ -2677,14 +3084,11 @@ function createTaskCollector(fn, context) {
|
|
|
2677
3084
|
"only",
|
|
2678
3085
|
"todo",
|
|
2679
3086
|
"fails"
|
|
2680
|
-
], taskFn);
|
|
2681
|
-
if (context) {
|
|
2682
|
-
_test2.mergeContext(context);
|
|
2683
|
-
}
|
|
3087
|
+
], taskFn, { fixtures: new TestFixtures() });
|
|
2684
3088
|
return _test2;
|
|
2685
3089
|
}
|
|
2686
|
-
function createTest(fn
|
|
2687
|
-
return createTaskCollector(fn
|
|
3090
|
+
function createTest(fn) {
|
|
3091
|
+
return createTaskCollector(fn);
|
|
2688
3092
|
}
|
|
2689
3093
|
function formatName(name) {
|
|
2690
3094
|
return typeof name === "string" ? name : typeof name === "function" ? name.name || "<anonymous>" : String(name);
|
|
@@ -2709,14 +3113,13 @@ function formatTitle(template, items, idx) {
|
|
|
2709
3113
|
const isObjectItem = isObject(items[0]);
|
|
2710
3114
|
function formatAttribute(s3) {
|
|
2711
3115
|
return s3.replace(/\$([$\w.]+)/g, (_, key) => {
|
|
2712
|
-
var _runner$config;
|
|
2713
3116
|
const isArrayKey = /^\d+$/.test(key);
|
|
2714
3117
|
if (!isObjectItem && !isArrayKey) {
|
|
2715
3118
|
return `$${key}`;
|
|
2716
3119
|
}
|
|
2717
3120
|
const arrayElement = isArrayKey ? objectAttr(items, key) : void 0;
|
|
2718
3121
|
const value = isObjectItem ? objectAttr(items[0], key, arrayElement) : arrayElement;
|
|
2719
|
-
return objDisplay(value, { truncate: runner
|
|
3122
|
+
return objDisplay(value, { truncate: runner?.config?.chaiConfig?.truncateThreshold });
|
|
2720
3123
|
});
|
|
2721
3124
|
}
|
|
2722
3125
|
let output = "";
|
|
@@ -2764,14 +3167,13 @@ function formatTemplateString(cases, args) {
|
|
|
2764
3167
|
}
|
|
2765
3168
|
return res;
|
|
2766
3169
|
}
|
|
2767
|
-
var now$2 = Date.now;
|
|
3170
|
+
var now$2 = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
|
|
2768
3171
|
var collectorContext = {
|
|
2769
3172
|
tasks: [],
|
|
2770
3173
|
currentSuite: null
|
|
2771
3174
|
};
|
|
2772
3175
|
function collectTask(task) {
|
|
2773
|
-
|
|
2774
|
-
(_collectorContext$cur = collectorContext.currentSuite) === null || _collectorContext$cur === void 0 ? void 0 : _collectorContext$cur.tasks.push(task);
|
|
3176
|
+
collectorContext.currentSuite?.tasks.push(task);
|
|
2775
3177
|
}
|
|
2776
3178
|
async function runWithSuite(suite2, fn) {
|
|
2777
3179
|
const prev = collectorContext.currentSuite;
|
|
@@ -2790,15 +3192,14 @@ function withTimeout(fn, timeout, isHook = false, stackTraceError, onTimeout) {
|
|
|
2790
3192
|
runner2._currentTaskStartTime = startTime;
|
|
2791
3193
|
runner2._currentTaskTimeout = timeout;
|
|
2792
3194
|
return new Promise((resolve_, reject_) => {
|
|
2793
|
-
var _timer$unref;
|
|
2794
3195
|
const timer = setTimeout3(() => {
|
|
2795
3196
|
clearTimeout3(timer);
|
|
2796
3197
|
rejectTimeoutError();
|
|
2797
3198
|
}, timeout);
|
|
2798
|
-
|
|
3199
|
+
timer.unref?.();
|
|
2799
3200
|
function rejectTimeoutError() {
|
|
2800
3201
|
const error = makeTimeoutError(isHook, timeout, stackTraceError);
|
|
2801
|
-
onTimeout
|
|
3202
|
+
onTimeout?.(args, error);
|
|
2802
3203
|
reject_(error);
|
|
2803
3204
|
}
|
|
2804
3205
|
function resolve(result) {
|
|
@@ -2830,6 +3231,23 @@ function withTimeout(fn, timeout, isHook = false, stackTraceError, onTimeout) {
|
|
|
2830
3231
|
});
|
|
2831
3232
|
});
|
|
2832
3233
|
}
|
|
3234
|
+
function withCancel(fn, signal) {
|
|
3235
|
+
return (function runWithCancel(...args) {
|
|
3236
|
+
return new Promise((resolve, reject) => {
|
|
3237
|
+
signal.addEventListener("abort", () => reject(signal.reason));
|
|
3238
|
+
try {
|
|
3239
|
+
const result = fn(...args);
|
|
3240
|
+
if (typeof result === "object" && result != null && typeof result.then === "function") {
|
|
3241
|
+
result.then(resolve, reject);
|
|
3242
|
+
} else {
|
|
3243
|
+
resolve(result);
|
|
3244
|
+
}
|
|
3245
|
+
} catch (error) {
|
|
3246
|
+
reject(error);
|
|
3247
|
+
}
|
|
3248
|
+
});
|
|
3249
|
+
});
|
|
3250
|
+
}
|
|
2833
3251
|
var abortControllers = /* @__PURE__ */ new WeakMap();
|
|
2834
3252
|
function abortIfTimeout([context], error) {
|
|
2835
3253
|
if (context) {
|
|
@@ -2838,10 +3256,9 @@ function abortIfTimeout([context], error) {
|
|
|
2838
3256
|
}
|
|
2839
3257
|
function abortContextSignal(context, error) {
|
|
2840
3258
|
const abortController = abortControllers.get(context);
|
|
2841
|
-
abortController
|
|
3259
|
+
abortController?.abort(error);
|
|
2842
3260
|
}
|
|
2843
3261
|
function createTestContext(test3, runner2) {
|
|
2844
|
-
var _runner$extendTaskCon;
|
|
2845
3262
|
const context = function() {
|
|
2846
3263
|
throw new Error("done() callback is deprecated, use promise instead");
|
|
2847
3264
|
};
|
|
@@ -2856,7 +3273,7 @@ function createTestContext(test3, runner2) {
|
|
|
2856
3273
|
if (condition === false) {
|
|
2857
3274
|
return void 0;
|
|
2858
3275
|
}
|
|
2859
|
-
test3.result
|
|
3276
|
+
test3.result ??= { state: "skip" };
|
|
2860
3277
|
test3.result.pending = true;
|
|
2861
3278
|
throw new PendingError("test is skipped; abort execution", test3, typeof condition === "string" ? condition : note);
|
|
2862
3279
|
};
|
|
@@ -2887,32 +3304,24 @@ function createTestContext(test3, runner2) {
|
|
|
2887
3304
|
}));
|
|
2888
3305
|
});
|
|
2889
3306
|
context.onTestFailed = (handler, timeout) => {
|
|
2890
|
-
test3.onFailed
|
|
3307
|
+
test3.onFailed ||= [];
|
|
2891
3308
|
test3.onFailed.push(withTimeout(handler, timeout ?? runner2.config.hookTimeout, true, new Error("STACK_TRACE_ERROR"), (_, error) => abortController.abort(error)));
|
|
2892
3309
|
};
|
|
2893
3310
|
context.onTestFinished = (handler, timeout) => {
|
|
2894
|
-
test3.onFinished
|
|
3311
|
+
test3.onFinished ||= [];
|
|
2895
3312
|
test3.onFinished.push(withTimeout(handler, timeout ?? runner2.config.hookTimeout, true, new Error("STACK_TRACE_ERROR"), (_, error) => abortController.abort(error)));
|
|
2896
3313
|
};
|
|
2897
|
-
return
|
|
3314
|
+
return runner2.extendTaskContext?.(context) || context;
|
|
2898
3315
|
}
|
|
2899
3316
|
function makeTimeoutError(isHook, timeout, stackTraceError) {
|
|
2900
3317
|
const message = `${isHook ? "Hook" : "Test"} timed out in ${timeout}ms.
|
|
2901
3318
|
If this is a long-running ${isHook ? "hook" : "test"}, pass a timeout value as the last argument or configure it globally with "${isHook ? "hookTimeout" : "testTimeout"}".`;
|
|
2902
3319
|
const error = new Error(message);
|
|
2903
|
-
if (stackTraceError
|
|
3320
|
+
if (stackTraceError?.stack) {
|
|
2904
3321
|
error.stack = stackTraceError.stack.replace(error.message, stackTraceError.message);
|
|
2905
3322
|
}
|
|
2906
3323
|
return error;
|
|
2907
3324
|
}
|
|
2908
|
-
var fileContexts = /* @__PURE__ */ new WeakMap();
|
|
2909
|
-
function getFileContext(file) {
|
|
2910
|
-
const context = fileContexts.get(file);
|
|
2911
|
-
if (!context) {
|
|
2912
|
-
throw new Error(`Cannot find file context for ${file.name}`);
|
|
2913
|
-
}
|
|
2914
|
-
return context;
|
|
2915
|
-
}
|
|
2916
3325
|
var now$1 = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
|
|
2917
3326
|
var now = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
|
|
2918
3327
|
var unixNow = Date.now;
|
|
@@ -2922,7 +3331,6 @@ var eventsPacks = [];
|
|
|
2922
3331
|
var pendingTasksUpdates = [];
|
|
2923
3332
|
function sendTasksUpdate(runner2) {
|
|
2924
3333
|
if (packs.size) {
|
|
2925
|
-
var _runner$onTaskUpdate;
|
|
2926
3334
|
const taskPacks = Array.from(packs).map(([id, task]) => {
|
|
2927
3335
|
return [
|
|
2928
3336
|
id,
|
|
@@ -2930,7 +3338,7 @@ function sendTasksUpdate(runner2) {
|
|
|
2930
3338
|
task[1]
|
|
2931
3339
|
];
|
|
2932
3340
|
});
|
|
2933
|
-
const p2 =
|
|
3341
|
+
const p2 = runner2.onTaskUpdate?.(taskPacks, eventsPacks);
|
|
2934
3342
|
if (p2) {
|
|
2935
3343
|
pendingTasksUpdates.push(p2);
|
|
2936
3344
|
p2.then(() => pendingTasksUpdates.splice(pendingTasksUpdates.indexOf(p2), 1), () => {
|
|
@@ -2955,15 +3363,12 @@ function throttle(fn, ms) {
|
|
|
2955
3363
|
pendingCall = void 0;
|
|
2956
3364
|
return fn.apply(this, args);
|
|
2957
3365
|
}
|
|
2958
|
-
pendingCall
|
|
3366
|
+
pendingCall ??= setTimeout2(() => call.bind(this)(...args), ms);
|
|
2959
3367
|
};
|
|
2960
3368
|
}
|
|
2961
3369
|
var sendTasksUpdateThrottled = throttle(sendTasksUpdate, 100);
|
|
2962
3370
|
async function recordArtifact(task, artifact) {
|
|
2963
3371
|
const runner2 = getRunner();
|
|
2964
|
-
if (task.result && task.result.state !== "run") {
|
|
2965
|
-
throw new Error(`Cannot record a test artifact outside of the test run. The test "${task.name}" finished running with the "${task.result.state}" state already.`);
|
|
2966
|
-
}
|
|
2967
3372
|
const stack = findTestFileStackTrace(task.file.filepath, new Error("STACK_TRACE").stack);
|
|
2968
3373
|
if (stack) {
|
|
2969
3374
|
artifact.location = {
|
|
@@ -3007,28 +3412,28 @@ function encodeUint8Array(bytes) {
|
|
|
3007
3412
|
const len = bytes.byteLength;
|
|
3008
3413
|
for (let i3 = 0; i3 < len; i3 += 3) {
|
|
3009
3414
|
if (len === i3 + 1) {
|
|
3010
|
-
const
|
|
3415
|
+
const a4 = (bytes[i3] & 252) >> 2;
|
|
3011
3416
|
const b4 = (bytes[i3] & 3) << 4;
|
|
3012
|
-
base64 += table[
|
|
3417
|
+
base64 += table[a4];
|
|
3013
3418
|
base64 += table[b4];
|
|
3014
3419
|
base64 += "==";
|
|
3015
3420
|
} else if (len === i3 + 2) {
|
|
3016
|
-
const
|
|
3421
|
+
const a4 = (bytes[i3] & 252) >> 2;
|
|
3017
3422
|
const b4 = (bytes[i3] & 3) << 4 | (bytes[i3 + 1] & 240) >> 4;
|
|
3018
3423
|
const c3 = (bytes[i3 + 1] & 15) << 2;
|
|
3019
|
-
base64 += table[
|
|
3424
|
+
base64 += table[a4];
|
|
3020
3425
|
base64 += table[b4];
|
|
3021
3426
|
base64 += table[c3];
|
|
3022
3427
|
base64 += "=";
|
|
3023
3428
|
} else {
|
|
3024
|
-
const
|
|
3429
|
+
const a4 = (bytes[i3] & 252) >> 2;
|
|
3025
3430
|
const b4 = (bytes[i3] & 3) << 4 | (bytes[i3 + 1] & 240) >> 4;
|
|
3026
3431
|
const c3 = (bytes[i3 + 1] & 15) << 2 | (bytes[i3 + 2] & 192) >> 6;
|
|
3027
|
-
const
|
|
3028
|
-
base64 += table[
|
|
3432
|
+
const d3 = bytes[i3 + 2] & 63;
|
|
3433
|
+
base64 += table[a4];
|
|
3029
3434
|
base64 += table[b4];
|
|
3030
3435
|
base64 += table[c3];
|
|
3031
|
-
base64 += table[
|
|
3436
|
+
base64 += table[d3];
|
|
3032
3437
|
}
|
|
3033
3438
|
}
|
|
3034
3439
|
return base64;
|
|
@@ -3061,15 +3466,16 @@ function manageArtifactAttachment(attachment) {
|
|
|
3061
3466
|
}
|
|
3062
3467
|
}
|
|
3063
3468
|
|
|
3064
|
-
// ../../node_modules/.pnpm/vitest@4.
|
|
3065
|
-
import "./chunks/utils.
|
|
3469
|
+
// ../../node_modules/.pnpm/vitest@4.1.0_@opentelemetry+api@1.9.0_@types+node@25.3.0_vite@7.3.1_@types+node@25.3.0__1256cd9683254972294f67b42fe9fd18/node_modules/vitest/dist/index.js
|
|
3470
|
+
import "./chunks/utils.BX5Fg8C4.js.mjs";
|
|
3066
3471
|
|
|
3067
|
-
// ../../node_modules/.pnpm/@vitest+runner@4.0
|
|
3068
|
-
import {
|
|
3472
|
+
// ../../node_modules/.pnpm/@vitest+runner@4.1.0/node_modules/@vitest/runner/dist/utils.js
|
|
3473
|
+
import { c, a, b, d as d2, e, f as f2, g as g2, h as h2, i, j, k, l, m, n, o, p, q, r, s, t, u, v } from "./chunk-tasks.js.mjs";
|
|
3069
3474
|
|
|
3070
|
-
// ../../node_modules/.pnpm/vitest@4.
|
|
3475
|
+
// ../../node_modules/.pnpm/vitest@4.1.0_@opentelemetry+api@1.9.0_@types+node@25.3.0_vite@7.3.1_@types+node@25.3.0__1256cd9683254972294f67b42fe9fd18/node_modules/vitest/dist/index.js
|
|
3071
3476
|
import "./chunks/_commonjsHelpers.D26ty3Ew.js.mjs";
|
|
3072
|
-
import "./chunks/
|
|
3477
|
+
import "./chunks/rpc.MzXet3jl.js.mjs";
|
|
3478
|
+
import "./chunks/index.Chj8NDwU.js.mjs";
|
|
3073
3479
|
|
|
3074
3480
|
// ../../node_modules/.pnpm/vite@7.3.1_@types+node@25.3.0_jiti@2.6.1_lightningcss@1.30.2_terser@5.44.1_yaml@2.8.2/node_modules/vite/dist/node/module-runner.js
|
|
3075
3481
|
var SOURCEMAPPING_URL = "sourceMa";
|