@sleepy-hollow/framework 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/LICENSE +373 -0
- package/README.md +95 -0
- package/dist/chunk-53TZY5YP.js +470 -0
- package/dist/chunk-53TZY5YP.js.map +1 -0
- package/dist/chunk-5WRI5ZAA.js +31 -0
- package/dist/chunk-5WRI5ZAA.js.map +1 -0
- package/dist/chunk-BAKXP7IR.js +85 -0
- package/dist/chunk-BAKXP7IR.js.map +1 -0
- package/dist/chunk-BJONRVDG.js +429 -0
- package/dist/chunk-BJONRVDG.js.map +1 -0
- package/dist/chunk-CAPFDC25.js +598 -0
- package/dist/chunk-CAPFDC25.js.map +1 -0
- package/dist/chunk-D4U3ZY4O.js +4585 -0
- package/dist/chunk-D4U3ZY4O.js.map +1 -0
- package/dist/chunk-DGTHFZPZ.js +830 -0
- package/dist/chunk-DGTHFZPZ.js.map +1 -0
- package/dist/chunk-LNJDFJGT.js +47 -0
- package/dist/chunk-LNJDFJGT.js.map +1 -0
- package/dist/cli.d.ts +427 -0
- package/dist/cli.js +5910 -0
- package/dist/cli.js.map +1 -0
- package/dist/database.d.ts +25 -0
- package/dist/database.js +16 -0
- package/dist/database.js.map +1 -0
- package/dist/dist-DUSC2237.js +546 -0
- package/dist/dist-DUSC2237.js.map +1 -0
- package/dist/index.d.ts +241 -0
- package/dist/index.js +71 -0
- package/dist/index.js.map +1 -0
- package/dist/magic-string.es-GTFBNHZR.js +1309 -0
- package/dist/magic-string.es-GTFBNHZR.js.map +1 -0
- package/dist/routing.d.ts +89 -0
- package/dist/routing.js +17 -0
- package/dist/routing.js.map +1 -0
- package/dist/security.d.ts +319 -0
- package/dist/security.js +21 -0
- package/dist/security.js.map +1 -0
- package/dist/server.d.ts +10 -0
- package/dist/server.js +8 -0
- package/dist/server.js.map +1 -0
- package/dist/testing.d.ts +157 -0
- package/dist/testing.js +29 -0
- package/dist/testing.js.map +1 -0
- package/dist/types-BC7LJJ6G.d.ts +131 -0
- package/dist/types-BUXw3UwN.d.ts +54 -0
- package/dist/types-Bet36nZS.d.ts +390 -0
- package/dist/types-DmzdxsaA.d.ts +113 -0
- package/dist/validation.d.ts +57 -0
- package/dist/validation.js +20 -0
- package/dist/validation.js.map +1 -0
- package/package.json +84 -0
|
@@ -0,0 +1,4585 @@
|
|
|
1
|
+
import {
|
|
2
|
+
openEmbeddedSqlite
|
|
3
|
+
} from "./chunk-BAKXP7IR.js";
|
|
4
|
+
import {
|
|
5
|
+
composeProjectSecurity
|
|
6
|
+
} from "./chunk-DGTHFZPZ.js";
|
|
7
|
+
import {
|
|
8
|
+
__commonJS,
|
|
9
|
+
__toESM
|
|
10
|
+
} from "./chunk-5WRI5ZAA.js";
|
|
11
|
+
|
|
12
|
+
// node_modules/expect-type/dist/branding.js
|
|
13
|
+
var require_branding = __commonJS({
|
|
14
|
+
"node_modules/expect-type/dist/branding.js"(exports) {
|
|
15
|
+
"use strict";
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// node_modules/expect-type/dist/messages.js
|
|
21
|
+
var require_messages = __commonJS({
|
|
22
|
+
"node_modules/expect-type/dist/messages.js"(exports) {
|
|
23
|
+
"use strict";
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// node_modules/expect-type/dist/overloads.js
|
|
29
|
+
var require_overloads = __commonJS({
|
|
30
|
+
"node_modules/expect-type/dist/overloads.js"(exports) {
|
|
31
|
+
"use strict";
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// node_modules/expect-type/dist/utils.js
|
|
37
|
+
var require_utils = __commonJS({
|
|
38
|
+
"node_modules/expect-type/dist/utils.js"(exports) {
|
|
39
|
+
"use strict";
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// node_modules/expect-type/dist/index.js
|
|
45
|
+
var require_dist = __commonJS({
|
|
46
|
+
"node_modules/expect-type/dist/index.js"(exports) {
|
|
47
|
+
"use strict";
|
|
48
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
49
|
+
if (k2 === void 0) k2 = k;
|
|
50
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
51
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
52
|
+
desc = { enumerable: true, get: function() {
|
|
53
|
+
return m[k];
|
|
54
|
+
} };
|
|
55
|
+
}
|
|
56
|
+
Object.defineProperty(o, k2, desc);
|
|
57
|
+
}) : (function(o, m, k, k2) {
|
|
58
|
+
if (k2 === void 0) k2 = k;
|
|
59
|
+
o[k2] = m[k];
|
|
60
|
+
}));
|
|
61
|
+
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
62
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
|
|
63
|
+
};
|
|
64
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
|
+
exports.expectTypeOf = void 0;
|
|
66
|
+
__exportStar(require_branding(), exports);
|
|
67
|
+
__exportStar(require_messages(), exports);
|
|
68
|
+
__exportStar(require_overloads(), exports);
|
|
69
|
+
__exportStar(require_utils(), exports);
|
|
70
|
+
var fn = () => true;
|
|
71
|
+
var expectTypeOf2 = (_actual) => {
|
|
72
|
+
const nonFunctionProperties = [
|
|
73
|
+
"parameters",
|
|
74
|
+
"returns",
|
|
75
|
+
"resolves",
|
|
76
|
+
"not",
|
|
77
|
+
"items",
|
|
78
|
+
"constructorParameters",
|
|
79
|
+
"thisParameter",
|
|
80
|
+
"instance",
|
|
81
|
+
"guards",
|
|
82
|
+
"asserts"
|
|
83
|
+
];
|
|
84
|
+
function createBranded() {
|
|
85
|
+
return {
|
|
86
|
+
inspect: () => true,
|
|
87
|
+
configure: () => createBranded(),
|
|
88
|
+
toEqualTypeOf: fn
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
const obj = {
|
|
92
|
+
toBeAny: fn,
|
|
93
|
+
toBeUnknown: fn,
|
|
94
|
+
toBeNever: fn,
|
|
95
|
+
toBeFunction: fn,
|
|
96
|
+
toBeObject: fn,
|
|
97
|
+
toBeArray: fn,
|
|
98
|
+
toBeString: fn,
|
|
99
|
+
toBeNumber: fn,
|
|
100
|
+
toBeBoolean: fn,
|
|
101
|
+
toBeVoid: fn,
|
|
102
|
+
toBeSymbol: fn,
|
|
103
|
+
toBeNull: fn,
|
|
104
|
+
toBeUndefined: fn,
|
|
105
|
+
toBeNullable: fn,
|
|
106
|
+
toBeBigInt: fn,
|
|
107
|
+
toMatchTypeOf: fn,
|
|
108
|
+
toEqualTypeOf: fn,
|
|
109
|
+
toBeConstructibleWith: fn,
|
|
110
|
+
toMatchObjectType: fn,
|
|
111
|
+
toExtend: fn,
|
|
112
|
+
map: exports.expectTypeOf,
|
|
113
|
+
toBeCallableWith: exports.expectTypeOf,
|
|
114
|
+
extract: exports.expectTypeOf,
|
|
115
|
+
exclude: exports.expectTypeOf,
|
|
116
|
+
pick: exports.expectTypeOf,
|
|
117
|
+
omit: exports.expectTypeOf,
|
|
118
|
+
toHaveProperty: exports.expectTypeOf,
|
|
119
|
+
parameter: exports.expectTypeOf,
|
|
120
|
+
get branded() {
|
|
121
|
+
return createBranded();
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
const getterProperties = nonFunctionProperties;
|
|
125
|
+
getterProperties.forEach((prop) => Object.defineProperty(obj, prop, { get: () => (0, exports.expectTypeOf)({}) }));
|
|
126
|
+
return obj;
|
|
127
|
+
};
|
|
128
|
+
exports.expectTypeOf = expectTypeOf2;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// core/testing/error.ts
|
|
133
|
+
var TestingError = class extends Error {
|
|
134
|
+
/** Every fault found, sorted by subject and then code. */
|
|
135
|
+
diagnostics;
|
|
136
|
+
/**
|
|
137
|
+
* Builds an error carrying every fault found.
|
|
138
|
+
*
|
|
139
|
+
* @param diagnostics The faults; they are sorted for stable output.
|
|
140
|
+
*/
|
|
141
|
+
constructor(diagnostics) {
|
|
142
|
+
super("Sleepy Hollow testing validation failed");
|
|
143
|
+
this.name = "TestingError";
|
|
144
|
+
this.diagnostics = [...diagnostics].sort(
|
|
145
|
+
(left, right) => (left.subject ?? "").localeCompare(right.subject ?? "") || left.code.localeCompare(right.code)
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
function testingDiagnostic(code, message, correction, subject) {
|
|
150
|
+
return { code, message, subject, correction };
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// core/testing/application.ts
|
|
154
|
+
function equal(left, right) {
|
|
155
|
+
if (Object.is(left, right)) return true;
|
|
156
|
+
if (Array.isArray(left) && Array.isArray(right)) {
|
|
157
|
+
return left.length === right.length && left.every((value, index2) => equal(value, right[index2]));
|
|
158
|
+
}
|
|
159
|
+
if (left !== null && right !== null && typeof left === "object" && typeof right === "object") {
|
|
160
|
+
const leftRecord = left;
|
|
161
|
+
const rightRecord = right;
|
|
162
|
+
const leftKeys = Object.keys(leftRecord).sort();
|
|
163
|
+
const rightKeys = Object.keys(rightRecord).sort();
|
|
164
|
+
return equal(leftKeys, rightKeys) && leftKeys.every((key) => equal(leftRecord[key], rightRecord[key]));
|
|
165
|
+
}
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
async function problem(response, expectation) {
|
|
169
|
+
const diagnostics = [];
|
|
170
|
+
const contentType = response.headers.get("content-type") ?? "";
|
|
171
|
+
if (!contentType.toLowerCase().startsWith("application/problem+json")) {
|
|
172
|
+
diagnostics.push(testingDiagnostic(
|
|
173
|
+
"SH_TEST_PROBLEM_CONTENT_TYPE",
|
|
174
|
+
`Expected application/problem+json but received ${contentType || "no content type"}.`,
|
|
175
|
+
"Return RFC 9457 Problem Details with the problem JSON media type."
|
|
176
|
+
));
|
|
177
|
+
}
|
|
178
|
+
if (response.status !== expectation.status || response.ok) {
|
|
179
|
+
diagnostics.push(testingDiagnostic(
|
|
180
|
+
"SH_TEST_PROBLEM_STATUS",
|
|
181
|
+
`Expected failing status ${expectation.status} but received ${response.status}.`,
|
|
182
|
+
"Return the approved non-success HTTP status in both the response and problem body."
|
|
183
|
+
));
|
|
184
|
+
}
|
|
185
|
+
let value;
|
|
186
|
+
try {
|
|
187
|
+
value = await response.json();
|
|
188
|
+
} catch {
|
|
189
|
+
diagnostics.push(testingDiagnostic(
|
|
190
|
+
"SH_TEST_PROBLEM_JSON",
|
|
191
|
+
"Problem response body is not valid JSON.",
|
|
192
|
+
"Return one RFC 9457 JSON object."
|
|
193
|
+
));
|
|
194
|
+
}
|
|
195
|
+
const body = value !== null && typeof value === "object" ? value : {};
|
|
196
|
+
if (typeof body.type !== "string" || typeof body.title !== "string" || typeof body.status !== "number" || body.status !== response.status) {
|
|
197
|
+
diagnostics.push(testingDiagnostic(
|
|
198
|
+
"SH_TEST_PROBLEM_SHAPE",
|
|
199
|
+
"Problem response lacks matching type, title, and numeric status members.",
|
|
200
|
+
"Return the required RFC 9457 members and match the HTTP status."
|
|
201
|
+
));
|
|
202
|
+
}
|
|
203
|
+
if (expectation.type !== void 0 && body.type !== expectation.type) {
|
|
204
|
+
diagnostics.push(testingDiagnostic(
|
|
205
|
+
"SH_TEST_PROBLEM_TYPE",
|
|
206
|
+
`Expected problem type ${expectation.type}.`,
|
|
207
|
+
"Return the approved stable problem type URI."
|
|
208
|
+
));
|
|
209
|
+
}
|
|
210
|
+
if (expectation.title !== void 0 && body.title !== expectation.title) {
|
|
211
|
+
diagnostics.push(testingDiagnostic(
|
|
212
|
+
"SH_TEST_PROBLEM_TITLE",
|
|
213
|
+
`Expected problem title ${expectation.title}.`,
|
|
214
|
+
"Return the approved safe problem title."
|
|
215
|
+
));
|
|
216
|
+
}
|
|
217
|
+
for (const [key, expected] of Object.entries(expectation.extensions ?? {})) {
|
|
218
|
+
if (!equal(body[key], expected)) {
|
|
219
|
+
diagnostics.push(testingDiagnostic(
|
|
220
|
+
"SH_TEST_PROBLEM_EXTENSION",
|
|
221
|
+
`Problem extension ${key} does not match its expected value.`,
|
|
222
|
+
"Return the approved safe extension value.",
|
|
223
|
+
key
|
|
224
|
+
));
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
if (diagnostics.length > 0) throw new TestingError(diagnostics);
|
|
228
|
+
return body;
|
|
229
|
+
}
|
|
230
|
+
function required(create) {
|
|
231
|
+
if (create === void 0) {
|
|
232
|
+
throw new TestingError([testingDiagnostic(
|
|
233
|
+
"SH_TEST_APPLICATION_SOURCE_REQUIRED",
|
|
234
|
+
"A test application needs either an application factory or a route inventory.",
|
|
235
|
+
"Supply create or routes."
|
|
236
|
+
)]);
|
|
237
|
+
}
|
|
238
|
+
return create;
|
|
239
|
+
}
|
|
240
|
+
async function secured(routes, security) {
|
|
241
|
+
const router = await composeProjectSecurity(routes, {
|
|
242
|
+
mode: "test",
|
|
243
|
+
root: security?.root ?? ".",
|
|
244
|
+
...security?.securityModule === void 0 ? {} : { securityModule: security.securityModule },
|
|
245
|
+
...security?.load === void 0 ? {} : { load: security.load }
|
|
246
|
+
});
|
|
247
|
+
return { fetch: (request) => router.fetch(request) };
|
|
248
|
+
}
|
|
249
|
+
async function testApplication(options) {
|
|
250
|
+
const database = openEmbeddedSqlite({ filename: ":memory:" });
|
|
251
|
+
let closed = false;
|
|
252
|
+
const cleanup = async () => {
|
|
253
|
+
if (closed) return;
|
|
254
|
+
closed = true;
|
|
255
|
+
try {
|
|
256
|
+
await options.cleanup?.();
|
|
257
|
+
} finally {
|
|
258
|
+
database.close();
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
try {
|
|
262
|
+
const application = options.routes === void 0 ? await required(options.create)({
|
|
263
|
+
database,
|
|
264
|
+
principal: options.principal === void 0 ? void 0 : structuredClone(options.principal),
|
|
265
|
+
credentials: options.credentials === void 0 ? void 0 : structuredClone(options.credentials)
|
|
266
|
+
}) : await secured(options.routes, options.security);
|
|
267
|
+
await options.seed?.({ database, application });
|
|
268
|
+
const origin = new URL(options.origin ?? "http://sleepy-hollow.test");
|
|
269
|
+
const fetchApplication = async (input, init) => {
|
|
270
|
+
const request = input instanceof Request ? new Request(input, init) : new Request(new URL(String(input), origin), init);
|
|
271
|
+
return await application.fetch(request);
|
|
272
|
+
};
|
|
273
|
+
const context = {
|
|
274
|
+
database,
|
|
275
|
+
application,
|
|
276
|
+
fetch: fetchApplication,
|
|
277
|
+
async request(requestOptions) {
|
|
278
|
+
const headers = new Headers(requestOptions.headers);
|
|
279
|
+
let body;
|
|
280
|
+
if (requestOptions.body !== void 0) {
|
|
281
|
+
headers.set("content-type", "application/json");
|
|
282
|
+
body = JSON.stringify(requestOptions.body);
|
|
283
|
+
}
|
|
284
|
+
const response = await fetchApplication(requestOptions.path, {
|
|
285
|
+
method: requestOptions.method ?? (body === void 0 ? "GET" : "POST"),
|
|
286
|
+
headers,
|
|
287
|
+
body
|
|
288
|
+
});
|
|
289
|
+
const text = await response.clone().text();
|
|
290
|
+
const parsed = text === "" ? void 0 : JSON.parse(text);
|
|
291
|
+
return { response, body: parsed };
|
|
292
|
+
},
|
|
293
|
+
assertProblem: problem,
|
|
294
|
+
close: cleanup,
|
|
295
|
+
[Symbol.asyncDispose]: cleanup
|
|
296
|
+
};
|
|
297
|
+
return Object.freeze(context);
|
|
298
|
+
} catch (error) {
|
|
299
|
+
await cleanup();
|
|
300
|
+
throw error;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// core/testing/criterion.ts
|
|
305
|
+
import { createHash } from "crypto";
|
|
306
|
+
|
|
307
|
+
// node_modules/tinyrainbow/dist/index.js
|
|
308
|
+
var b = {
|
|
309
|
+
reset: [0, 0],
|
|
310
|
+
bold: [1, 22, "\x1B[22m\x1B[1m"],
|
|
311
|
+
dim: [2, 22, "\x1B[22m\x1B[2m"],
|
|
312
|
+
italic: [3, 23],
|
|
313
|
+
underline: [4, 24],
|
|
314
|
+
inverse: [7, 27],
|
|
315
|
+
hidden: [8, 28],
|
|
316
|
+
strikethrough: [9, 29],
|
|
317
|
+
black: [30, 39],
|
|
318
|
+
red: [31, 39],
|
|
319
|
+
green: [32, 39],
|
|
320
|
+
yellow: [33, 39],
|
|
321
|
+
blue: [34, 39],
|
|
322
|
+
magenta: [35, 39],
|
|
323
|
+
cyan: [36, 39],
|
|
324
|
+
white: [37, 39],
|
|
325
|
+
gray: [90, 39],
|
|
326
|
+
bgBlack: [40, 49],
|
|
327
|
+
bgRed: [41, 49],
|
|
328
|
+
bgGreen: [42, 49],
|
|
329
|
+
bgYellow: [43, 49],
|
|
330
|
+
bgBlue: [44, 49],
|
|
331
|
+
bgMagenta: [45, 49],
|
|
332
|
+
bgCyan: [46, 49],
|
|
333
|
+
bgWhite: [47, 49],
|
|
334
|
+
blackBright: [90, 39],
|
|
335
|
+
redBright: [91, 39],
|
|
336
|
+
greenBright: [92, 39],
|
|
337
|
+
yellowBright: [93, 39],
|
|
338
|
+
blueBright: [94, 39],
|
|
339
|
+
magentaBright: [95, 39],
|
|
340
|
+
cyanBright: [96, 39],
|
|
341
|
+
whiteBright: [97, 39],
|
|
342
|
+
bgBlackBright: [100, 49],
|
|
343
|
+
bgRedBright: [101, 49],
|
|
344
|
+
bgGreenBright: [102, 49],
|
|
345
|
+
bgYellowBright: [103, 49],
|
|
346
|
+
bgBlueBright: [104, 49],
|
|
347
|
+
bgMagentaBright: [105, 49],
|
|
348
|
+
bgCyanBright: [106, 49],
|
|
349
|
+
bgWhiteBright: [107, 49]
|
|
350
|
+
};
|
|
351
|
+
function i(e) {
|
|
352
|
+
return String(e);
|
|
353
|
+
}
|
|
354
|
+
i.open = "";
|
|
355
|
+
i.close = "";
|
|
356
|
+
function B() {
|
|
357
|
+
let e = typeof process != "undefined" ? process : void 0, r = (e == null ? void 0 : e.env) || {}, a = r.FORCE_TTY !== "false", l = (e == null ? void 0 : e.argv) || [];
|
|
358
|
+
return !("NO_COLOR" in r || l.includes("--no-color")) && ("FORCE_COLOR" in r || l.includes("--color") || (e == null ? void 0 : e.platform) === "win32" || a && r.TERM !== "dumb" || "CI" in r) || typeof window != "undefined" && !!window.chrome;
|
|
359
|
+
}
|
|
360
|
+
function C({ force: e } = {}) {
|
|
361
|
+
let r = e || B(), a = (t, o, u, n) => {
|
|
362
|
+
let g = "", s = 0;
|
|
363
|
+
do
|
|
364
|
+
g += t.substring(s, n) + u, s = n + o.length, n = t.indexOf(o, s);
|
|
365
|
+
while (~n);
|
|
366
|
+
return g + t.substring(s);
|
|
367
|
+
}, l = (t, o, u = t) => {
|
|
368
|
+
let n = (g) => {
|
|
369
|
+
let s = String(g), h = s.indexOf(o, t.length);
|
|
370
|
+
return ~h ? t + a(s, o, u, h) + o : t + s + o;
|
|
371
|
+
};
|
|
372
|
+
return n.open = t, n.close = o, n;
|
|
373
|
+
}, c = {
|
|
374
|
+
isColorSupported: r
|
|
375
|
+
}, f = (t) => `\x1B[${t}m`;
|
|
376
|
+
for (let t in b) {
|
|
377
|
+
let o = b[t];
|
|
378
|
+
c[t] = r ? l(
|
|
379
|
+
f(o[0]),
|
|
380
|
+
f(o[1]),
|
|
381
|
+
o[2]
|
|
382
|
+
) : i;
|
|
383
|
+
}
|
|
384
|
+
return c;
|
|
385
|
+
}
|
|
386
|
+
var d = C();
|
|
387
|
+
var y = d;
|
|
388
|
+
|
|
389
|
+
// node_modules/@vitest/pretty-format/dist/index.js
|
|
390
|
+
function _mergeNamespaces(n, m) {
|
|
391
|
+
m.forEach(function(e) {
|
|
392
|
+
e && typeof e !== "string" && !Array.isArray(e) && Object.keys(e).forEach(function(k) {
|
|
393
|
+
if (k !== "default" && !(k in n)) {
|
|
394
|
+
var d2 = Object.getOwnPropertyDescriptor(e, k);
|
|
395
|
+
Object.defineProperty(n, k, d2.get ? d2 : {
|
|
396
|
+
enumerable: true,
|
|
397
|
+
get: function() {
|
|
398
|
+
return e[k];
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
});
|
|
404
|
+
return Object.freeze(n);
|
|
405
|
+
}
|
|
406
|
+
function getKeysOfEnumerableProperties(object, compareKeys) {
|
|
407
|
+
const rawKeys = Object.keys(object);
|
|
408
|
+
const keys = compareKeys === null ? rawKeys : rawKeys.sort(compareKeys);
|
|
409
|
+
if (Object.getOwnPropertySymbols) {
|
|
410
|
+
for (const symbol of Object.getOwnPropertySymbols(object)) {
|
|
411
|
+
if (Object.getOwnPropertyDescriptor(object, symbol).enumerable) {
|
|
412
|
+
keys.push(symbol);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
return keys;
|
|
417
|
+
}
|
|
418
|
+
function printIteratorEntries(iterator, config, indentation, depth, refs, printer2, separator = ": ") {
|
|
419
|
+
let result = "";
|
|
420
|
+
let width = 0;
|
|
421
|
+
let current = iterator.next();
|
|
422
|
+
if (!current.done) {
|
|
423
|
+
result += config.spacingOuter;
|
|
424
|
+
const indentationNext = indentation + config.indent;
|
|
425
|
+
while (!current.done) {
|
|
426
|
+
result += indentationNext;
|
|
427
|
+
if (width++ === config.maxWidth) {
|
|
428
|
+
result += "\u2026";
|
|
429
|
+
break;
|
|
430
|
+
}
|
|
431
|
+
const name = printer2(current.value[0], config, indentationNext, depth, refs);
|
|
432
|
+
const value = printer2(current.value[1], config, indentationNext, depth, refs);
|
|
433
|
+
result += name + separator + value;
|
|
434
|
+
current = iterator.next();
|
|
435
|
+
if (!current.done) {
|
|
436
|
+
result += `,${config.spacingInner}`;
|
|
437
|
+
} else if (!config.min) {
|
|
438
|
+
result += ",";
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
result += config.spacingOuter + indentation;
|
|
442
|
+
}
|
|
443
|
+
return result;
|
|
444
|
+
}
|
|
445
|
+
function printIteratorValues(iterator, config, indentation, depth, refs, printer2) {
|
|
446
|
+
let result = "";
|
|
447
|
+
let width = 0;
|
|
448
|
+
let current = iterator.next();
|
|
449
|
+
if (!current.done) {
|
|
450
|
+
result += config.spacingOuter;
|
|
451
|
+
const indentationNext = indentation + config.indent;
|
|
452
|
+
while (!current.done) {
|
|
453
|
+
result += indentationNext;
|
|
454
|
+
if (width++ === config.maxWidth) {
|
|
455
|
+
result += "\u2026";
|
|
456
|
+
break;
|
|
457
|
+
}
|
|
458
|
+
result += printer2(current.value, config, indentationNext, depth, refs);
|
|
459
|
+
current = iterator.next();
|
|
460
|
+
if (!current.done) {
|
|
461
|
+
result += `,${config.spacingInner}`;
|
|
462
|
+
} else if (!config.min) {
|
|
463
|
+
result += ",";
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
result += config.spacingOuter + indentation;
|
|
467
|
+
}
|
|
468
|
+
return result;
|
|
469
|
+
}
|
|
470
|
+
function printListItems(list, config, indentation, depth, refs, printer2) {
|
|
471
|
+
let result = "";
|
|
472
|
+
list = list instanceof ArrayBuffer ? new DataView(list) : list;
|
|
473
|
+
const isDataView = (l) => l instanceof DataView;
|
|
474
|
+
const length = isDataView(list) ? list.byteLength : list.length;
|
|
475
|
+
if (length > 0) {
|
|
476
|
+
result += config.spacingOuter;
|
|
477
|
+
const indentationNext = indentation + config.indent;
|
|
478
|
+
for (let i2 = 0; i2 < length; i2++) {
|
|
479
|
+
result += indentationNext;
|
|
480
|
+
if (i2 === config.maxWidth) {
|
|
481
|
+
result += "\u2026";
|
|
482
|
+
break;
|
|
483
|
+
}
|
|
484
|
+
if (isDataView(list) || i2 in list) {
|
|
485
|
+
result += printer2(isDataView(list) ? list.getInt8(i2) : list[i2], config, indentationNext, depth, refs);
|
|
486
|
+
}
|
|
487
|
+
if (i2 < length - 1) {
|
|
488
|
+
result += `,${config.spacingInner}`;
|
|
489
|
+
} else if (!config.min) {
|
|
490
|
+
result += ",";
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
result += config.spacingOuter + indentation;
|
|
494
|
+
}
|
|
495
|
+
return result;
|
|
496
|
+
}
|
|
497
|
+
function printObjectProperties(val, config, indentation, depth, refs, printer2) {
|
|
498
|
+
let result = "";
|
|
499
|
+
const keys = getKeysOfEnumerableProperties(val, config.compareKeys);
|
|
500
|
+
if (keys.length > 0) {
|
|
501
|
+
result += config.spacingOuter;
|
|
502
|
+
const indentationNext = indentation + config.indent;
|
|
503
|
+
for (let i2 = 0; i2 < keys.length; i2++) {
|
|
504
|
+
const key = keys[i2];
|
|
505
|
+
const name = printer2(key, config, indentationNext, depth, refs);
|
|
506
|
+
const value = printer2(val[key], config, indentationNext, depth, refs);
|
|
507
|
+
result += `${indentationNext + name}: ${value}`;
|
|
508
|
+
if (i2 < keys.length - 1) {
|
|
509
|
+
result += `,${config.spacingInner}`;
|
|
510
|
+
} else if (!config.min) {
|
|
511
|
+
result += ",";
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
result += config.spacingOuter + indentation;
|
|
515
|
+
}
|
|
516
|
+
return result;
|
|
517
|
+
}
|
|
518
|
+
var asymmetricMatcher = typeof Symbol === "function" && Symbol.for ? /* @__PURE__ */ Symbol.for("jest.asymmetricMatcher") : 1267621;
|
|
519
|
+
var SPACE$2 = " ";
|
|
520
|
+
var serialize$5 = (val, config, indentation, depth, refs, printer2) => {
|
|
521
|
+
const stringedValue = val.toString();
|
|
522
|
+
if (stringedValue === "ArrayContaining" || stringedValue === "ArrayNotContaining") {
|
|
523
|
+
if (++depth > config.maxDepth) {
|
|
524
|
+
return `[${stringedValue}]`;
|
|
525
|
+
}
|
|
526
|
+
return `${stringedValue + SPACE$2}[${printListItems(val.sample, config, indentation, depth, refs, printer2)}]`;
|
|
527
|
+
}
|
|
528
|
+
if (stringedValue === "ObjectContaining" || stringedValue === "ObjectNotContaining") {
|
|
529
|
+
if (++depth > config.maxDepth) {
|
|
530
|
+
return `[${stringedValue}]`;
|
|
531
|
+
}
|
|
532
|
+
return `${stringedValue + SPACE$2}{${printObjectProperties(val.sample, config, indentation, depth, refs, printer2)}}`;
|
|
533
|
+
}
|
|
534
|
+
if (stringedValue === "StringMatching" || stringedValue === "StringNotMatching") {
|
|
535
|
+
return stringedValue + SPACE$2 + printer2(val.sample, config, indentation, depth, refs);
|
|
536
|
+
}
|
|
537
|
+
if (stringedValue === "StringContaining" || stringedValue === "StringNotContaining") {
|
|
538
|
+
return stringedValue + SPACE$2 + printer2(val.sample, config, indentation, depth, refs);
|
|
539
|
+
}
|
|
540
|
+
if (typeof val.toAsymmetricMatcher !== "function") {
|
|
541
|
+
throw new TypeError(`Asymmetric matcher ${val.constructor.name} does not implement toAsymmetricMatcher()`);
|
|
542
|
+
}
|
|
543
|
+
return val.toAsymmetricMatcher();
|
|
544
|
+
};
|
|
545
|
+
var test$5 = (val) => val && val.$$typeof === asymmetricMatcher;
|
|
546
|
+
var plugin$5 = {
|
|
547
|
+
serialize: serialize$5,
|
|
548
|
+
test: test$5
|
|
549
|
+
};
|
|
550
|
+
var SPACE$1 = " ";
|
|
551
|
+
var OBJECT_NAMES = /* @__PURE__ */ new Set(["DOMStringMap", "NamedNodeMap"]);
|
|
552
|
+
var ARRAY_REGEXP = /^(?:HTML\w*Collection|NodeList)$/;
|
|
553
|
+
function testName(name) {
|
|
554
|
+
return OBJECT_NAMES.has(name) || ARRAY_REGEXP.test(name);
|
|
555
|
+
}
|
|
556
|
+
var test$4 = (val) => val && val.constructor && !!val.constructor.name && testName(val.constructor.name);
|
|
557
|
+
function isNamedNodeMap(collection) {
|
|
558
|
+
return collection.constructor.name === "NamedNodeMap";
|
|
559
|
+
}
|
|
560
|
+
var serialize$4 = (collection, config, indentation, depth, refs, printer2) => {
|
|
561
|
+
const name = collection.constructor.name;
|
|
562
|
+
if (++depth > config.maxDepth) {
|
|
563
|
+
return `[${name}]`;
|
|
564
|
+
}
|
|
565
|
+
return (config.min ? "" : name + SPACE$1) + (OBJECT_NAMES.has(name) ? `{${printObjectProperties(isNamedNodeMap(collection) ? [...collection].reduce((props, attribute) => {
|
|
566
|
+
props[attribute.name] = attribute.value;
|
|
567
|
+
return props;
|
|
568
|
+
}, {}) : { ...collection }, config, indentation, depth, refs, printer2)}}` : `[${printListItems([...collection], config, indentation, depth, refs, printer2)}]`);
|
|
569
|
+
};
|
|
570
|
+
var plugin$4 = {
|
|
571
|
+
serialize: serialize$4,
|
|
572
|
+
test: test$4
|
|
573
|
+
};
|
|
574
|
+
function escapeHTML(str) {
|
|
575
|
+
return str.replaceAll("<", "<").replaceAll(">", ">");
|
|
576
|
+
}
|
|
577
|
+
function printProps(keys, props, config, indentation, depth, refs, printer2) {
|
|
578
|
+
const indentationNext = indentation + config.indent;
|
|
579
|
+
const colors = config.colors;
|
|
580
|
+
return keys.map((key) => {
|
|
581
|
+
const value = props[key];
|
|
582
|
+
if (typeof value === "string" && value[0] === "_" && value.startsWith("__vitest_") && value.match(/__vitest_\d+__/)) {
|
|
583
|
+
return "";
|
|
584
|
+
}
|
|
585
|
+
let printed = printer2(value, config, indentationNext, depth, refs);
|
|
586
|
+
if (typeof value !== "string") {
|
|
587
|
+
if (printed.includes("\n")) {
|
|
588
|
+
printed = config.spacingOuter + indentationNext + printed + config.spacingOuter + indentation;
|
|
589
|
+
}
|
|
590
|
+
printed = `{${printed}}`;
|
|
591
|
+
}
|
|
592
|
+
return `${config.spacingInner + indentation + colors.prop.open + key + colors.prop.close}=${colors.value.open}${printed}${colors.value.close}`;
|
|
593
|
+
}).join("");
|
|
594
|
+
}
|
|
595
|
+
function printChildren(children, config, indentation, depth, refs, printer2) {
|
|
596
|
+
return children.map((child) => config.spacingOuter + indentation + (typeof child === "string" ? printText(child, config) : printer2(child, config, indentation, depth, refs))).join("");
|
|
597
|
+
}
|
|
598
|
+
function printShadowRoot(children, config, indentation, depth, refs, printer2) {
|
|
599
|
+
if (config.printShadowRoot === false) {
|
|
600
|
+
return "";
|
|
601
|
+
}
|
|
602
|
+
return [`${config.spacingOuter + indentation}#shadow-root`, printChildren(children, config, indentation + config.indent, depth, refs, printer2)].join("");
|
|
603
|
+
}
|
|
604
|
+
function printText(text, config) {
|
|
605
|
+
const contentColor = config.colors.content;
|
|
606
|
+
return contentColor.open + escapeHTML(text) + contentColor.close;
|
|
607
|
+
}
|
|
608
|
+
function printComment(comment, config) {
|
|
609
|
+
const commentColor = config.colors.comment;
|
|
610
|
+
return `${commentColor.open}<!--${escapeHTML(comment)}-->${commentColor.close}`;
|
|
611
|
+
}
|
|
612
|
+
function printElement(type, printedProps, printedChildren, config, indentation) {
|
|
613
|
+
const tagColor = config.colors.tag;
|
|
614
|
+
return `${tagColor.open}<${type}${printedProps && tagColor.close + printedProps + config.spacingOuter + indentation + tagColor.open}${printedChildren ? `>${tagColor.close}${printedChildren}${config.spacingOuter}${indentation}${tagColor.open}</${type}` : `${printedProps && !config.min ? "" : " "}/`}>${tagColor.close}`;
|
|
615
|
+
}
|
|
616
|
+
function printElementAsLeaf(type, config) {
|
|
617
|
+
const tagColor = config.colors.tag;
|
|
618
|
+
return `${tagColor.open}<${type}${tagColor.close} \u2026${tagColor.open} />${tagColor.close}`;
|
|
619
|
+
}
|
|
620
|
+
var ELEMENT_NODE = 1;
|
|
621
|
+
var TEXT_NODE = 3;
|
|
622
|
+
var COMMENT_NODE = 8;
|
|
623
|
+
var FRAGMENT_NODE = 11;
|
|
624
|
+
var ELEMENT_REGEXP = /^(?:(?:HTML|SVG)\w*)?Element$/;
|
|
625
|
+
function testHasAttribute(val) {
|
|
626
|
+
try {
|
|
627
|
+
return typeof val.hasAttribute === "function" && val.hasAttribute("is");
|
|
628
|
+
} catch {
|
|
629
|
+
return false;
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
function testNode(val) {
|
|
633
|
+
const constructorName = val.constructor.name;
|
|
634
|
+
const { nodeType, tagName } = val;
|
|
635
|
+
const isCustomElement = typeof tagName === "string" && tagName.includes("-") || testHasAttribute(val);
|
|
636
|
+
return nodeType === ELEMENT_NODE && (ELEMENT_REGEXP.test(constructorName) || isCustomElement) || nodeType === TEXT_NODE && constructorName === "Text" || nodeType === COMMENT_NODE && constructorName === "Comment" || nodeType === FRAGMENT_NODE && constructorName === "DocumentFragment";
|
|
637
|
+
}
|
|
638
|
+
var test$3 = (val) => val?.constructor?.name && testNode(val);
|
|
639
|
+
function nodeIsText(node) {
|
|
640
|
+
return node.nodeType === TEXT_NODE;
|
|
641
|
+
}
|
|
642
|
+
function nodeIsComment(node) {
|
|
643
|
+
return node.nodeType === COMMENT_NODE;
|
|
644
|
+
}
|
|
645
|
+
function nodeIsFragment(node) {
|
|
646
|
+
return node.nodeType === FRAGMENT_NODE;
|
|
647
|
+
}
|
|
648
|
+
function filterChildren(children, filterNode) {
|
|
649
|
+
let filtered = children.filter((node) => {
|
|
650
|
+
if (node.nodeType === TEXT_NODE) {
|
|
651
|
+
const text = node.data || "";
|
|
652
|
+
return text.trim().length > 0;
|
|
653
|
+
}
|
|
654
|
+
return true;
|
|
655
|
+
});
|
|
656
|
+
if (filterNode) {
|
|
657
|
+
filtered = filtered.filter(filterNode);
|
|
658
|
+
}
|
|
659
|
+
return filtered;
|
|
660
|
+
}
|
|
661
|
+
function serializeDOM(node, config, indentation, depth, refs, printer2, filterNode) {
|
|
662
|
+
if (nodeIsText(node)) {
|
|
663
|
+
return printText(node.data, config);
|
|
664
|
+
}
|
|
665
|
+
if (nodeIsComment(node)) {
|
|
666
|
+
return printComment(node.data, config);
|
|
667
|
+
}
|
|
668
|
+
const type = nodeIsFragment(node) ? "DocumentFragment" : node.tagName.toLowerCase();
|
|
669
|
+
if (++depth > config.maxDepth) {
|
|
670
|
+
return printElementAsLeaf(type, config);
|
|
671
|
+
}
|
|
672
|
+
const children = Array.prototype.slice.call(node.childNodes || node.children);
|
|
673
|
+
const shadowChildren = nodeIsFragment(node) || !node.shadowRoot ? [] : Array.prototype.slice.call(node.shadowRoot.children);
|
|
674
|
+
const resolvedChildren = filterNode ? filterChildren(children, filterNode) : children;
|
|
675
|
+
const resolvedShadowChildren = filterNode ? filterChildren(shadowChildren, filterNode) : shadowChildren;
|
|
676
|
+
return printElement(type, printProps(nodeIsFragment(node) ? [] : Array.from(node.attributes, (attr) => attr.name).sort(), nodeIsFragment(node) ? {} : [...node.attributes].reduce((props, attribute) => {
|
|
677
|
+
props[attribute.name] = attribute.value;
|
|
678
|
+
return props;
|
|
679
|
+
}, {}), 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);
|
|
680
|
+
}
|
|
681
|
+
var serialize$3 = (node, config, indentation, depth, refs, printer2) => serializeDOM(node, config, indentation, depth, refs, printer2);
|
|
682
|
+
function createDOMElementFilter(filterNode) {
|
|
683
|
+
return {
|
|
684
|
+
test: test$3,
|
|
685
|
+
serialize: (node, config, indentation, depth, refs, printer2) => serializeDOM(node, config, indentation, depth, refs, printer2, filterNode)
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
var plugin$3 = {
|
|
689
|
+
serialize: serialize$3,
|
|
690
|
+
test: test$3
|
|
691
|
+
};
|
|
692
|
+
var IS_ITERABLE_SENTINEL = "@@__IMMUTABLE_ITERABLE__@@";
|
|
693
|
+
var IS_LIST_SENTINEL = "@@__IMMUTABLE_LIST__@@";
|
|
694
|
+
var IS_KEYED_SENTINEL = "@@__IMMUTABLE_KEYED__@@";
|
|
695
|
+
var IS_MAP_SENTINEL = "@@__IMMUTABLE_MAP__@@";
|
|
696
|
+
var IS_ORDERED_SENTINEL = "@@__IMMUTABLE_ORDERED__@@";
|
|
697
|
+
var IS_RECORD_SENTINEL = "@@__IMMUTABLE_RECORD__@@";
|
|
698
|
+
var IS_SEQ_SENTINEL = "@@__IMMUTABLE_SEQ__@@";
|
|
699
|
+
var IS_SET_SENTINEL = "@@__IMMUTABLE_SET__@@";
|
|
700
|
+
var IS_STACK_SENTINEL = "@@__IMMUTABLE_STACK__@@";
|
|
701
|
+
var getImmutableName = (name) => `Immutable.${name}`;
|
|
702
|
+
var printAsLeaf = (name) => `[${name}]`;
|
|
703
|
+
var SPACE = " ";
|
|
704
|
+
var LAZY = "\u2026";
|
|
705
|
+
function printImmutableEntries(val, config, indentation, depth, refs, printer2, type) {
|
|
706
|
+
return ++depth > config.maxDepth ? printAsLeaf(getImmutableName(type)) : `${getImmutableName(type) + SPACE}{${printIteratorEntries(val.entries(), config, indentation, depth, refs, printer2)}}`;
|
|
707
|
+
}
|
|
708
|
+
function getRecordEntries(val) {
|
|
709
|
+
let i2 = 0;
|
|
710
|
+
return { next() {
|
|
711
|
+
if (i2 < val._keys.length) {
|
|
712
|
+
const key = val._keys[i2++];
|
|
713
|
+
return {
|
|
714
|
+
done: false,
|
|
715
|
+
value: [key, val.get(key)]
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
return {
|
|
719
|
+
done: true,
|
|
720
|
+
value: void 0
|
|
721
|
+
};
|
|
722
|
+
} };
|
|
723
|
+
}
|
|
724
|
+
function printImmutableRecord(val, config, indentation, depth, refs, printer2) {
|
|
725
|
+
const name = getImmutableName(val._name || "Record");
|
|
726
|
+
return ++depth > config.maxDepth ? printAsLeaf(name) : `${name + SPACE}{${printIteratorEntries(getRecordEntries(val), config, indentation, depth, refs, printer2)}}`;
|
|
727
|
+
}
|
|
728
|
+
function printImmutableSeq(val, config, indentation, depth, refs, printer2) {
|
|
729
|
+
const name = getImmutableName("Seq");
|
|
730
|
+
if (++depth > config.maxDepth) {
|
|
731
|
+
return printAsLeaf(name);
|
|
732
|
+
}
|
|
733
|
+
if (val[IS_KEYED_SENTINEL]) {
|
|
734
|
+
return `${name + SPACE}{${val._iter || val._object ? printIteratorEntries(val.entries(), config, indentation, depth, refs, printer2) : LAZY}}`;
|
|
735
|
+
}
|
|
736
|
+
return `${name + SPACE}[${val._iter || val._array || val._collection || val._iterable ? printIteratorValues(val.values(), config, indentation, depth, refs, printer2) : LAZY}]`;
|
|
737
|
+
}
|
|
738
|
+
function printImmutableValues(val, config, indentation, depth, refs, printer2, type) {
|
|
739
|
+
return ++depth > config.maxDepth ? printAsLeaf(getImmutableName(type)) : `${getImmutableName(type) + SPACE}[${printIteratorValues(val.values(), config, indentation, depth, refs, printer2)}]`;
|
|
740
|
+
}
|
|
741
|
+
var serialize$2 = (val, config, indentation, depth, refs, printer2) => {
|
|
742
|
+
if (val[IS_MAP_SENTINEL]) {
|
|
743
|
+
return printImmutableEntries(val, config, indentation, depth, refs, printer2, val[IS_ORDERED_SENTINEL] ? "OrderedMap" : "Map");
|
|
744
|
+
}
|
|
745
|
+
if (val[IS_LIST_SENTINEL]) {
|
|
746
|
+
return printImmutableValues(val, config, indentation, depth, refs, printer2, "List");
|
|
747
|
+
}
|
|
748
|
+
if (val[IS_SET_SENTINEL]) {
|
|
749
|
+
return printImmutableValues(val, config, indentation, depth, refs, printer2, val[IS_ORDERED_SENTINEL] ? "OrderedSet" : "Set");
|
|
750
|
+
}
|
|
751
|
+
if (val[IS_STACK_SENTINEL]) {
|
|
752
|
+
return printImmutableValues(val, config, indentation, depth, refs, printer2, "Stack");
|
|
753
|
+
}
|
|
754
|
+
if (val[IS_SEQ_SENTINEL]) {
|
|
755
|
+
return printImmutableSeq(val, config, indentation, depth, refs, printer2);
|
|
756
|
+
}
|
|
757
|
+
return printImmutableRecord(val, config, indentation, depth, refs, printer2);
|
|
758
|
+
};
|
|
759
|
+
var test$2 = (val) => val && (val[IS_ITERABLE_SENTINEL] === true || val[IS_RECORD_SENTINEL] === true);
|
|
760
|
+
var plugin$2 = {
|
|
761
|
+
serialize: serialize$2,
|
|
762
|
+
test: test$2
|
|
763
|
+
};
|
|
764
|
+
function getDefaultExportFromCjs(x) {
|
|
765
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
766
|
+
}
|
|
767
|
+
var reactIs$1 = { exports: {} };
|
|
768
|
+
var reactIs_production = {};
|
|
769
|
+
var hasRequiredReactIs_production;
|
|
770
|
+
function requireReactIs_production() {
|
|
771
|
+
if (hasRequiredReactIs_production) return reactIs_production;
|
|
772
|
+
hasRequiredReactIs_production = 1;
|
|
773
|
+
var REACT_ELEMENT_TYPE = /* @__PURE__ */ Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = /* @__PURE__ */ Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = /* @__PURE__ */ Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = /* @__PURE__ */ Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = /* @__PURE__ */ Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = /* @__PURE__ */ Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = /* @__PURE__ */ Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = /* @__PURE__ */ Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = /* @__PURE__ */ Symbol.for("react.memo"), REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy"), REACT_VIEW_TRANSITION_TYPE = /* @__PURE__ */ Symbol.for("react.view_transition"), REACT_CLIENT_REFERENCE = /* @__PURE__ */ Symbol.for("react.client.reference");
|
|
774
|
+
function typeOf(object) {
|
|
775
|
+
if ("object" === typeof object && null !== object) {
|
|
776
|
+
var $$typeof = object.$$typeof;
|
|
777
|
+
switch ($$typeof) {
|
|
778
|
+
case REACT_ELEMENT_TYPE:
|
|
779
|
+
switch (object = object.type, object) {
|
|
780
|
+
case REACT_FRAGMENT_TYPE:
|
|
781
|
+
case REACT_PROFILER_TYPE:
|
|
782
|
+
case REACT_STRICT_MODE_TYPE:
|
|
783
|
+
case REACT_SUSPENSE_TYPE:
|
|
784
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
|
785
|
+
case REACT_VIEW_TRANSITION_TYPE:
|
|
786
|
+
return object;
|
|
787
|
+
default:
|
|
788
|
+
switch (object = object && object.$$typeof, object) {
|
|
789
|
+
case REACT_CONTEXT_TYPE:
|
|
790
|
+
case REACT_FORWARD_REF_TYPE:
|
|
791
|
+
case REACT_LAZY_TYPE:
|
|
792
|
+
case REACT_MEMO_TYPE:
|
|
793
|
+
return object;
|
|
794
|
+
case REACT_CONSUMER_TYPE:
|
|
795
|
+
return object;
|
|
796
|
+
default:
|
|
797
|
+
return $$typeof;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
case REACT_PORTAL_TYPE:
|
|
801
|
+
return $$typeof;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
reactIs_production.ContextConsumer = REACT_CONSUMER_TYPE;
|
|
806
|
+
reactIs_production.ContextProvider = REACT_CONTEXT_TYPE;
|
|
807
|
+
reactIs_production.Element = REACT_ELEMENT_TYPE;
|
|
808
|
+
reactIs_production.ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
809
|
+
reactIs_production.Fragment = REACT_FRAGMENT_TYPE;
|
|
810
|
+
reactIs_production.Lazy = REACT_LAZY_TYPE;
|
|
811
|
+
reactIs_production.Memo = REACT_MEMO_TYPE;
|
|
812
|
+
reactIs_production.Portal = REACT_PORTAL_TYPE;
|
|
813
|
+
reactIs_production.Profiler = REACT_PROFILER_TYPE;
|
|
814
|
+
reactIs_production.StrictMode = REACT_STRICT_MODE_TYPE;
|
|
815
|
+
reactIs_production.Suspense = REACT_SUSPENSE_TYPE;
|
|
816
|
+
reactIs_production.SuspenseList = REACT_SUSPENSE_LIST_TYPE;
|
|
817
|
+
reactIs_production.isContextConsumer = function(object) {
|
|
818
|
+
return typeOf(object) === REACT_CONSUMER_TYPE;
|
|
819
|
+
};
|
|
820
|
+
reactIs_production.isContextProvider = function(object) {
|
|
821
|
+
return typeOf(object) === REACT_CONTEXT_TYPE;
|
|
822
|
+
};
|
|
823
|
+
reactIs_production.isElement = function(object) {
|
|
824
|
+
return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
825
|
+
};
|
|
826
|
+
reactIs_production.isForwardRef = function(object) {
|
|
827
|
+
return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
|
828
|
+
};
|
|
829
|
+
reactIs_production.isFragment = function(object) {
|
|
830
|
+
return typeOf(object) === REACT_FRAGMENT_TYPE;
|
|
831
|
+
};
|
|
832
|
+
reactIs_production.isLazy = function(object) {
|
|
833
|
+
return typeOf(object) === REACT_LAZY_TYPE;
|
|
834
|
+
};
|
|
835
|
+
reactIs_production.isMemo = function(object) {
|
|
836
|
+
return typeOf(object) === REACT_MEMO_TYPE;
|
|
837
|
+
};
|
|
838
|
+
reactIs_production.isPortal = function(object) {
|
|
839
|
+
return typeOf(object) === REACT_PORTAL_TYPE;
|
|
840
|
+
};
|
|
841
|
+
reactIs_production.isProfiler = function(object) {
|
|
842
|
+
return typeOf(object) === REACT_PROFILER_TYPE;
|
|
843
|
+
};
|
|
844
|
+
reactIs_production.isStrictMode = function(object) {
|
|
845
|
+
return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
|
846
|
+
};
|
|
847
|
+
reactIs_production.isSuspense = function(object) {
|
|
848
|
+
return typeOf(object) === REACT_SUSPENSE_TYPE;
|
|
849
|
+
};
|
|
850
|
+
reactIs_production.isSuspenseList = function(object) {
|
|
851
|
+
return typeOf(object) === REACT_SUSPENSE_LIST_TYPE;
|
|
852
|
+
};
|
|
853
|
+
reactIs_production.isValidElementType = function(type) {
|
|
854
|
+
return "string" === typeof type || "function" === typeof type || type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || "object" === typeof type && null !== type && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_CONSUMER_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_CLIENT_REFERENCE || void 0 !== type.getModuleId) ? true : false;
|
|
855
|
+
};
|
|
856
|
+
reactIs_production.typeOf = typeOf;
|
|
857
|
+
return reactIs_production;
|
|
858
|
+
}
|
|
859
|
+
var hasRequiredReactIs$1;
|
|
860
|
+
function requireReactIs$1() {
|
|
861
|
+
if (hasRequiredReactIs$1) return reactIs$1.exports;
|
|
862
|
+
hasRequiredReactIs$1 = 1;
|
|
863
|
+
{
|
|
864
|
+
reactIs$1.exports = requireReactIs_production();
|
|
865
|
+
}
|
|
866
|
+
return reactIs$1.exports;
|
|
867
|
+
}
|
|
868
|
+
var reactIsExports$1 = requireReactIs$1();
|
|
869
|
+
var index$1 = /* @__PURE__ */ getDefaultExportFromCjs(reactIsExports$1);
|
|
870
|
+
var ReactIs19 = /* @__PURE__ */ _mergeNamespaces({
|
|
871
|
+
__proto__: null,
|
|
872
|
+
default: index$1
|
|
873
|
+
}, [reactIsExports$1]);
|
|
874
|
+
var reactIs = { exports: {} };
|
|
875
|
+
var reactIs_production_min = {};
|
|
876
|
+
var hasRequiredReactIs_production_min;
|
|
877
|
+
function requireReactIs_production_min() {
|
|
878
|
+
if (hasRequiredReactIs_production_min) return reactIs_production_min;
|
|
879
|
+
hasRequiredReactIs_production_min = 1;
|
|
880
|
+
var b2 = /* @__PURE__ */ Symbol.for("react.element"), c = /* @__PURE__ */ Symbol.for("react.portal"), d2 = /* @__PURE__ */ Symbol.for("react.fragment"), e = /* @__PURE__ */ Symbol.for("react.strict_mode"), f = /* @__PURE__ */ Symbol.for("react.profiler"), g = /* @__PURE__ */ Symbol.for("react.provider"), h = /* @__PURE__ */ Symbol.for("react.context"), k = /* @__PURE__ */ Symbol.for("react.server_context"), l = /* @__PURE__ */ Symbol.for("react.forward_ref"), m = /* @__PURE__ */ Symbol.for("react.suspense"), n = /* @__PURE__ */ Symbol.for("react.suspense_list"), p = /* @__PURE__ */ Symbol.for("react.memo"), q = /* @__PURE__ */ Symbol.for("react.lazy"), t = /* @__PURE__ */ Symbol.for("react.offscreen"), u;
|
|
881
|
+
u = /* @__PURE__ */ Symbol.for("react.module.reference");
|
|
882
|
+
function v(a) {
|
|
883
|
+
if ("object" === typeof a && null !== a) {
|
|
884
|
+
var r = a.$$typeof;
|
|
885
|
+
switch (r) {
|
|
886
|
+
case b2:
|
|
887
|
+
switch (a = a.type, a) {
|
|
888
|
+
case d2:
|
|
889
|
+
case f:
|
|
890
|
+
case e:
|
|
891
|
+
case m:
|
|
892
|
+
case n:
|
|
893
|
+
return a;
|
|
894
|
+
default:
|
|
895
|
+
switch (a = a && a.$$typeof, a) {
|
|
896
|
+
case k:
|
|
897
|
+
case h:
|
|
898
|
+
case l:
|
|
899
|
+
case q:
|
|
900
|
+
case p:
|
|
901
|
+
case g:
|
|
902
|
+
return a;
|
|
903
|
+
default:
|
|
904
|
+
return r;
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
case c:
|
|
908
|
+
return r;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
reactIs_production_min.ContextConsumer = h;
|
|
913
|
+
reactIs_production_min.ContextProvider = g;
|
|
914
|
+
reactIs_production_min.Element = b2;
|
|
915
|
+
reactIs_production_min.ForwardRef = l;
|
|
916
|
+
reactIs_production_min.Fragment = d2;
|
|
917
|
+
reactIs_production_min.Lazy = q;
|
|
918
|
+
reactIs_production_min.Memo = p;
|
|
919
|
+
reactIs_production_min.Portal = c;
|
|
920
|
+
reactIs_production_min.Profiler = f;
|
|
921
|
+
reactIs_production_min.StrictMode = e;
|
|
922
|
+
reactIs_production_min.Suspense = m;
|
|
923
|
+
reactIs_production_min.SuspenseList = n;
|
|
924
|
+
reactIs_production_min.isAsyncMode = function() {
|
|
925
|
+
return false;
|
|
926
|
+
};
|
|
927
|
+
reactIs_production_min.isConcurrentMode = function() {
|
|
928
|
+
return false;
|
|
929
|
+
};
|
|
930
|
+
reactIs_production_min.isContextConsumer = function(a) {
|
|
931
|
+
return v(a) === h;
|
|
932
|
+
};
|
|
933
|
+
reactIs_production_min.isContextProvider = function(a) {
|
|
934
|
+
return v(a) === g;
|
|
935
|
+
};
|
|
936
|
+
reactIs_production_min.isElement = function(a) {
|
|
937
|
+
return "object" === typeof a && null !== a && a.$$typeof === b2;
|
|
938
|
+
};
|
|
939
|
+
reactIs_production_min.isForwardRef = function(a) {
|
|
940
|
+
return v(a) === l;
|
|
941
|
+
};
|
|
942
|
+
reactIs_production_min.isFragment = function(a) {
|
|
943
|
+
return v(a) === d2;
|
|
944
|
+
};
|
|
945
|
+
reactIs_production_min.isLazy = function(a) {
|
|
946
|
+
return v(a) === q;
|
|
947
|
+
};
|
|
948
|
+
reactIs_production_min.isMemo = function(a) {
|
|
949
|
+
return v(a) === p;
|
|
950
|
+
};
|
|
951
|
+
reactIs_production_min.isPortal = function(a) {
|
|
952
|
+
return v(a) === c;
|
|
953
|
+
};
|
|
954
|
+
reactIs_production_min.isProfiler = function(a) {
|
|
955
|
+
return v(a) === f;
|
|
956
|
+
};
|
|
957
|
+
reactIs_production_min.isStrictMode = function(a) {
|
|
958
|
+
return v(a) === e;
|
|
959
|
+
};
|
|
960
|
+
reactIs_production_min.isSuspense = function(a) {
|
|
961
|
+
return v(a) === m;
|
|
962
|
+
};
|
|
963
|
+
reactIs_production_min.isSuspenseList = function(a) {
|
|
964
|
+
return v(a) === n;
|
|
965
|
+
};
|
|
966
|
+
reactIs_production_min.isValidElementType = function(a) {
|
|
967
|
+
return "string" === typeof a || "function" === typeof a || a === d2 || a === f || a === e || a === m || a === n || a === t || "object" === typeof a && null !== a && (a.$$typeof === q || a.$$typeof === p || a.$$typeof === g || a.$$typeof === h || a.$$typeof === l || a.$$typeof === u || void 0 !== a.getModuleId) ? true : false;
|
|
968
|
+
};
|
|
969
|
+
reactIs_production_min.typeOf = v;
|
|
970
|
+
return reactIs_production_min;
|
|
971
|
+
}
|
|
972
|
+
var hasRequiredReactIs;
|
|
973
|
+
function requireReactIs() {
|
|
974
|
+
if (hasRequiredReactIs) return reactIs.exports;
|
|
975
|
+
hasRequiredReactIs = 1;
|
|
976
|
+
{
|
|
977
|
+
reactIs.exports = requireReactIs_production_min();
|
|
978
|
+
}
|
|
979
|
+
return reactIs.exports;
|
|
980
|
+
}
|
|
981
|
+
var reactIsExports = requireReactIs();
|
|
982
|
+
var index = /* @__PURE__ */ getDefaultExportFromCjs(reactIsExports);
|
|
983
|
+
var ReactIs18 = /* @__PURE__ */ _mergeNamespaces({
|
|
984
|
+
__proto__: null,
|
|
985
|
+
default: index
|
|
986
|
+
}, [reactIsExports]);
|
|
987
|
+
var reactIsMethods = [
|
|
988
|
+
"isAsyncMode",
|
|
989
|
+
"isConcurrentMode",
|
|
990
|
+
"isContextConsumer",
|
|
991
|
+
"isContextProvider",
|
|
992
|
+
"isElement",
|
|
993
|
+
"isForwardRef",
|
|
994
|
+
"isFragment",
|
|
995
|
+
"isLazy",
|
|
996
|
+
"isMemo",
|
|
997
|
+
"isPortal",
|
|
998
|
+
"isProfiler",
|
|
999
|
+
"isStrictMode",
|
|
1000
|
+
"isSuspense",
|
|
1001
|
+
"isSuspenseList",
|
|
1002
|
+
"isValidElementType"
|
|
1003
|
+
];
|
|
1004
|
+
var ReactIs = Object.fromEntries(reactIsMethods.map((m) => [m, (v) => ReactIs18[m](v) || ReactIs19[m](v)]));
|
|
1005
|
+
function getChildren(arg, children = []) {
|
|
1006
|
+
if (Array.isArray(arg)) {
|
|
1007
|
+
for (const item of arg) {
|
|
1008
|
+
getChildren(item, children);
|
|
1009
|
+
}
|
|
1010
|
+
} else if (arg != null && arg !== false && arg !== "") {
|
|
1011
|
+
children.push(arg);
|
|
1012
|
+
}
|
|
1013
|
+
return children;
|
|
1014
|
+
}
|
|
1015
|
+
function getType(element) {
|
|
1016
|
+
const type = element.type;
|
|
1017
|
+
if (typeof type === "string") {
|
|
1018
|
+
return type;
|
|
1019
|
+
}
|
|
1020
|
+
if (typeof type === "function") {
|
|
1021
|
+
return type.displayName || type.name || "Unknown";
|
|
1022
|
+
}
|
|
1023
|
+
if (ReactIs.isFragment(element)) {
|
|
1024
|
+
return "React.Fragment";
|
|
1025
|
+
}
|
|
1026
|
+
if (ReactIs.isSuspense(element)) {
|
|
1027
|
+
return "React.Suspense";
|
|
1028
|
+
}
|
|
1029
|
+
if (typeof type === "object" && type !== null) {
|
|
1030
|
+
if (ReactIs.isContextProvider(element)) {
|
|
1031
|
+
return "Context.Provider";
|
|
1032
|
+
}
|
|
1033
|
+
if (ReactIs.isContextConsumer(element)) {
|
|
1034
|
+
return "Context.Consumer";
|
|
1035
|
+
}
|
|
1036
|
+
if (ReactIs.isForwardRef(element)) {
|
|
1037
|
+
if (type.displayName) {
|
|
1038
|
+
return type.displayName;
|
|
1039
|
+
}
|
|
1040
|
+
const functionName = type.render.displayName || type.render.name || "";
|
|
1041
|
+
return functionName === "" ? "ForwardRef" : `ForwardRef(${functionName})`;
|
|
1042
|
+
}
|
|
1043
|
+
if (ReactIs.isMemo(element)) {
|
|
1044
|
+
const functionName = type.displayName || type.type.displayName || type.type.name || "";
|
|
1045
|
+
return functionName === "" ? "Memo" : `Memo(${functionName})`;
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
return "UNDEFINED";
|
|
1049
|
+
}
|
|
1050
|
+
function getPropKeys$1(element) {
|
|
1051
|
+
const { props } = element;
|
|
1052
|
+
return Object.keys(props).filter((key) => key !== "children" && props[key] !== void 0).sort();
|
|
1053
|
+
}
|
|
1054
|
+
var serialize$1 = (element, config, indentation, depth, refs, printer2) => ++depth > config.maxDepth ? printElementAsLeaf(getType(element), config) : printElement(getType(element), printProps(getPropKeys$1(element), element.props, config, indentation + config.indent, depth, refs, printer2), printChildren(getChildren(element.props.children), config, indentation + config.indent, depth, refs, printer2), config, indentation);
|
|
1055
|
+
var test$1 = (val) => val != null && ReactIs.isElement(val);
|
|
1056
|
+
var plugin$1 = {
|
|
1057
|
+
serialize: serialize$1,
|
|
1058
|
+
test: test$1
|
|
1059
|
+
};
|
|
1060
|
+
var testSymbol = typeof Symbol === "function" && Symbol.for ? /* @__PURE__ */ Symbol.for("react.test.json") : 245830487;
|
|
1061
|
+
function getPropKeys(object) {
|
|
1062
|
+
const { props } = object;
|
|
1063
|
+
return props ? Object.keys(props).filter((key) => props[key] !== void 0).sort() : [];
|
|
1064
|
+
}
|
|
1065
|
+
var serialize = (object, config, indentation, depth, refs, printer2) => ++depth > config.maxDepth ? printElementAsLeaf(object.type, config) : printElement(object.type, object.props ? printProps(getPropKeys(object), object.props, config, indentation + config.indent, depth, refs, printer2) : "", object.children ? printChildren(object.children, config, indentation + config.indent, depth, refs, printer2) : "", config, indentation);
|
|
1066
|
+
var test = (val) => val && val.$$typeof === testSymbol;
|
|
1067
|
+
var plugin = {
|
|
1068
|
+
serialize,
|
|
1069
|
+
test
|
|
1070
|
+
};
|
|
1071
|
+
var toString = Object.prototype.toString;
|
|
1072
|
+
var toISOString = Date.prototype.toISOString;
|
|
1073
|
+
var errorToString = Error.prototype.toString;
|
|
1074
|
+
var regExpToString = RegExp.prototype.toString;
|
|
1075
|
+
function getConstructorName(val) {
|
|
1076
|
+
return typeof val.constructor === "function" && val.constructor.name || "Object";
|
|
1077
|
+
}
|
|
1078
|
+
function isWindow(val) {
|
|
1079
|
+
return typeof window !== "undefined" && val === window;
|
|
1080
|
+
}
|
|
1081
|
+
var SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;
|
|
1082
|
+
var NEWLINE_REGEXP = /\n/g;
|
|
1083
|
+
var PrettyFormatPluginError = class extends Error {
|
|
1084
|
+
constructor(message, stack) {
|
|
1085
|
+
super(message);
|
|
1086
|
+
this.stack = stack;
|
|
1087
|
+
this.name = this.constructor.name;
|
|
1088
|
+
}
|
|
1089
|
+
};
|
|
1090
|
+
function isToStringedArrayType(toStringed) {
|
|
1091
|
+
return toStringed === "[object Array]" || toStringed === "[object ArrayBuffer]" || toStringed === "[object DataView]" || toStringed === "[object Float32Array]" || toStringed === "[object Float64Array]" || toStringed === "[object Int8Array]" || toStringed === "[object Int16Array]" || toStringed === "[object Int32Array]" || toStringed === "[object Uint8Array]" || toStringed === "[object Uint8ClampedArray]" || toStringed === "[object Uint16Array]" || toStringed === "[object Uint32Array]";
|
|
1092
|
+
}
|
|
1093
|
+
function printNumber(val) {
|
|
1094
|
+
return Object.is(val, -0) ? "-0" : String(val);
|
|
1095
|
+
}
|
|
1096
|
+
function printBigInt(val) {
|
|
1097
|
+
return String(`${val}n`);
|
|
1098
|
+
}
|
|
1099
|
+
function printFunction(val, printFunctionName) {
|
|
1100
|
+
if (!printFunctionName) {
|
|
1101
|
+
return "[Function]";
|
|
1102
|
+
}
|
|
1103
|
+
return `[Function ${val.name || "anonymous"}]`;
|
|
1104
|
+
}
|
|
1105
|
+
function printSymbol(val) {
|
|
1106
|
+
return String(val).replace(SYMBOL_REGEXP, "Symbol($1)");
|
|
1107
|
+
}
|
|
1108
|
+
function printError(val) {
|
|
1109
|
+
return `[${errorToString.call(val)}]`;
|
|
1110
|
+
}
|
|
1111
|
+
function printBasicValue(val, printFunctionName, escapeRegex, escapeString) {
|
|
1112
|
+
if (val === true || val === false) {
|
|
1113
|
+
return `${val}`;
|
|
1114
|
+
}
|
|
1115
|
+
if (val === void 0) {
|
|
1116
|
+
return "undefined";
|
|
1117
|
+
}
|
|
1118
|
+
if (val === null) {
|
|
1119
|
+
return "null";
|
|
1120
|
+
}
|
|
1121
|
+
const typeOf = typeof val;
|
|
1122
|
+
if (typeOf === "number") {
|
|
1123
|
+
return printNumber(val);
|
|
1124
|
+
}
|
|
1125
|
+
if (typeOf === "bigint") {
|
|
1126
|
+
return printBigInt(val);
|
|
1127
|
+
}
|
|
1128
|
+
if (typeOf === "string") {
|
|
1129
|
+
if (escapeString) {
|
|
1130
|
+
return `"${val.replaceAll(/"|\\/g, "\\$&")}"`;
|
|
1131
|
+
}
|
|
1132
|
+
return `"${val}"`;
|
|
1133
|
+
}
|
|
1134
|
+
if (typeOf === "function") {
|
|
1135
|
+
return printFunction(val, printFunctionName);
|
|
1136
|
+
}
|
|
1137
|
+
if (typeOf === "symbol") {
|
|
1138
|
+
return printSymbol(val);
|
|
1139
|
+
}
|
|
1140
|
+
const toStringed = toString.call(val);
|
|
1141
|
+
if (toStringed === "[object WeakMap]") {
|
|
1142
|
+
return "WeakMap {}";
|
|
1143
|
+
}
|
|
1144
|
+
if (toStringed === "[object WeakSet]") {
|
|
1145
|
+
return "WeakSet {}";
|
|
1146
|
+
}
|
|
1147
|
+
if (toStringed === "[object Function]" || toStringed === "[object GeneratorFunction]") {
|
|
1148
|
+
return printFunction(val, printFunctionName);
|
|
1149
|
+
}
|
|
1150
|
+
if (toStringed === "[object Symbol]") {
|
|
1151
|
+
return printSymbol(val);
|
|
1152
|
+
}
|
|
1153
|
+
if (toStringed === "[object Date]") {
|
|
1154
|
+
return Number.isNaN(+val) ? "Date { NaN }" : toISOString.call(val);
|
|
1155
|
+
}
|
|
1156
|
+
if (toStringed === "[object Error]") {
|
|
1157
|
+
return printError(val);
|
|
1158
|
+
}
|
|
1159
|
+
if (toStringed === "[object RegExp]") {
|
|
1160
|
+
if (escapeRegex) {
|
|
1161
|
+
return regExpToString.call(val).replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&");
|
|
1162
|
+
}
|
|
1163
|
+
return regExpToString.call(val);
|
|
1164
|
+
}
|
|
1165
|
+
if (val instanceof Error) {
|
|
1166
|
+
return printError(val);
|
|
1167
|
+
}
|
|
1168
|
+
return null;
|
|
1169
|
+
}
|
|
1170
|
+
function printComplexValue(val, config, indentation, depth, refs, hasCalledToJSON) {
|
|
1171
|
+
if (refs.includes(val)) {
|
|
1172
|
+
return "[Circular]";
|
|
1173
|
+
}
|
|
1174
|
+
refs = [...refs];
|
|
1175
|
+
refs.push(val);
|
|
1176
|
+
const hitMaxDepth = ++depth > config.maxDepth;
|
|
1177
|
+
const min = config.min;
|
|
1178
|
+
if (config.callToJSON && !hitMaxDepth && val.toJSON && typeof val.toJSON === "function" && !hasCalledToJSON) {
|
|
1179
|
+
return printer(val.toJSON(), config, indentation, depth, refs, true);
|
|
1180
|
+
}
|
|
1181
|
+
const toStringed = toString.call(val);
|
|
1182
|
+
if (toStringed === "[object Arguments]") {
|
|
1183
|
+
return hitMaxDepth ? "[Arguments]" : `${min ? "" : "Arguments "}[${printListItems(val, config, indentation, depth, refs, printer)}]`;
|
|
1184
|
+
}
|
|
1185
|
+
if (isToStringedArrayType(toStringed)) {
|
|
1186
|
+
return hitMaxDepth ? `[${val.constructor.name}]` : `${min ? "" : !config.printBasicPrototype && val.constructor.name === "Array" ? "" : `${val.constructor.name} `}[${printListItems(val, config, indentation, depth, refs, printer)}]`;
|
|
1187
|
+
}
|
|
1188
|
+
if (toStringed === "[object Map]") {
|
|
1189
|
+
return hitMaxDepth ? "[Map]" : `Map {${printIteratorEntries(val.entries(), config, indentation, depth, refs, printer, " => ")}}`;
|
|
1190
|
+
}
|
|
1191
|
+
if (toStringed === "[object Set]") {
|
|
1192
|
+
return hitMaxDepth ? "[Set]" : `Set {${printIteratorValues(val.values(), config, indentation, depth, refs, printer)}}`;
|
|
1193
|
+
}
|
|
1194
|
+
return hitMaxDepth || isWindow(val) ? `[${getConstructorName(val)}]` : `${min ? "" : !config.printBasicPrototype && getConstructorName(val) === "Object" ? "" : `${getConstructorName(val)} `}{${printObjectProperties(val, config, indentation, depth, refs, printer)}}`;
|
|
1195
|
+
}
|
|
1196
|
+
var ErrorPlugin = {
|
|
1197
|
+
test: (val) => val && val instanceof Error,
|
|
1198
|
+
serialize(val, config, indentation, depth, refs, printer2) {
|
|
1199
|
+
if (refs.includes(val)) {
|
|
1200
|
+
return "[Circular]";
|
|
1201
|
+
}
|
|
1202
|
+
refs = [...refs, val];
|
|
1203
|
+
const hitMaxDepth = ++depth > config.maxDepth;
|
|
1204
|
+
const { message, cause, ...rest } = val;
|
|
1205
|
+
const entries = {
|
|
1206
|
+
message,
|
|
1207
|
+
...typeof cause !== "undefined" ? { cause } : {},
|
|
1208
|
+
...val instanceof AggregateError ? { errors: val.errors } : {},
|
|
1209
|
+
...rest
|
|
1210
|
+
};
|
|
1211
|
+
const name = val.name !== "Error" ? val.name : getConstructorName(val);
|
|
1212
|
+
return hitMaxDepth ? `[${name}]` : `${name} {${printIteratorEntries(Object.entries(entries).values(), config, indentation, depth, refs, printer2)}}`;
|
|
1213
|
+
}
|
|
1214
|
+
};
|
|
1215
|
+
function isNewPlugin(plugin2) {
|
|
1216
|
+
return plugin2.serialize != null;
|
|
1217
|
+
}
|
|
1218
|
+
function printPlugin(plugin2, val, config, indentation, depth, refs) {
|
|
1219
|
+
let printed;
|
|
1220
|
+
try {
|
|
1221
|
+
printed = isNewPlugin(plugin2) ? plugin2.serialize(val, config, indentation, depth, refs, printer) : plugin2.print(val, (valChild) => printer(valChild, config, indentation, depth, refs), (str) => {
|
|
1222
|
+
const indentationNext = indentation + config.indent;
|
|
1223
|
+
return indentationNext + str.replaceAll(NEWLINE_REGEXP, `
|
|
1224
|
+
${indentationNext}`);
|
|
1225
|
+
}, {
|
|
1226
|
+
edgeSpacing: config.spacingOuter,
|
|
1227
|
+
min: config.min,
|
|
1228
|
+
spacing: config.spacingInner
|
|
1229
|
+
}, config.colors);
|
|
1230
|
+
} catch (error) {
|
|
1231
|
+
throw new PrettyFormatPluginError(error.message, error.stack);
|
|
1232
|
+
}
|
|
1233
|
+
if (typeof printed !== "string") {
|
|
1234
|
+
throw new TypeError(`pretty-format: Plugin must return type "string" but instead returned "${typeof printed}".`);
|
|
1235
|
+
}
|
|
1236
|
+
return printed;
|
|
1237
|
+
}
|
|
1238
|
+
function findPlugin(plugins2, val) {
|
|
1239
|
+
for (const plugin2 of plugins2) {
|
|
1240
|
+
try {
|
|
1241
|
+
if (plugin2.test(val)) {
|
|
1242
|
+
return plugin2;
|
|
1243
|
+
}
|
|
1244
|
+
} catch (error) {
|
|
1245
|
+
throw new PrettyFormatPluginError(error.message, error.stack);
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
return null;
|
|
1249
|
+
}
|
|
1250
|
+
function printer(val, config, indentation, depth, refs, hasCalledToJSON) {
|
|
1251
|
+
let result;
|
|
1252
|
+
const plugin2 = findPlugin(config.plugins, val);
|
|
1253
|
+
if (plugin2 !== null) {
|
|
1254
|
+
result = printPlugin(plugin2, val, config, indentation, depth, refs);
|
|
1255
|
+
} else {
|
|
1256
|
+
const basicResult = printBasicValue(val, config.printFunctionName, config.escapeRegex, config.escapeString);
|
|
1257
|
+
if (basicResult !== null) {
|
|
1258
|
+
result = basicResult;
|
|
1259
|
+
} else {
|
|
1260
|
+
result = printComplexValue(val, config, indentation, depth, refs, hasCalledToJSON);
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
config._outputLengthPerDepth[depth] ??= 0;
|
|
1264
|
+
config._outputLengthPerDepth[depth] += result.length;
|
|
1265
|
+
if (config._outputLengthPerDepth[depth] > config.maxOutputLength) {
|
|
1266
|
+
config.maxDepth = 0;
|
|
1267
|
+
}
|
|
1268
|
+
return result;
|
|
1269
|
+
}
|
|
1270
|
+
var DEFAULT_THEME = {
|
|
1271
|
+
comment: "gray",
|
|
1272
|
+
content: "reset",
|
|
1273
|
+
prop: "yellow",
|
|
1274
|
+
tag: "cyan",
|
|
1275
|
+
value: "green"
|
|
1276
|
+
};
|
|
1277
|
+
var DEFAULT_THEME_KEYS = Object.keys(DEFAULT_THEME);
|
|
1278
|
+
var DEFAULT_OPTIONS = {
|
|
1279
|
+
callToJSON: true,
|
|
1280
|
+
compareKeys: void 0,
|
|
1281
|
+
escapeRegex: false,
|
|
1282
|
+
escapeString: true,
|
|
1283
|
+
highlight: false,
|
|
1284
|
+
indent: 2,
|
|
1285
|
+
maxDepth: Number.POSITIVE_INFINITY,
|
|
1286
|
+
maxOutputLength: 1e6,
|
|
1287
|
+
maxWidth: Number.POSITIVE_INFINITY,
|
|
1288
|
+
min: false,
|
|
1289
|
+
plugins: [],
|
|
1290
|
+
printBasicPrototype: true,
|
|
1291
|
+
printFunctionName: true,
|
|
1292
|
+
printShadowRoot: true,
|
|
1293
|
+
theme: DEFAULT_THEME
|
|
1294
|
+
};
|
|
1295
|
+
function validateOptions(options) {
|
|
1296
|
+
for (const key of Object.keys(options)) {
|
|
1297
|
+
if (!Object.hasOwn(DEFAULT_OPTIONS, key)) {
|
|
1298
|
+
throw new Error(`pretty-format: Unknown option "${key}".`);
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
if (options.min && options.indent !== void 0 && options.indent !== 0) {
|
|
1302
|
+
throw new Error('pretty-format: Options "min" and "indent" cannot be used together.');
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
function getColorsHighlight() {
|
|
1306
|
+
return DEFAULT_THEME_KEYS.reduce((colors, key) => {
|
|
1307
|
+
const value = DEFAULT_THEME[key];
|
|
1308
|
+
const color = value && y[value];
|
|
1309
|
+
if (color && typeof color.close === "string" && typeof color.open === "string") {
|
|
1310
|
+
colors[key] = color;
|
|
1311
|
+
} else {
|
|
1312
|
+
throw new Error(`pretty-format: Option "theme" has a key "${key}" whose value "${value}" is undefined in ansi-styles.`);
|
|
1313
|
+
}
|
|
1314
|
+
return colors;
|
|
1315
|
+
}, /* @__PURE__ */ Object.create(null));
|
|
1316
|
+
}
|
|
1317
|
+
function getColorsEmpty() {
|
|
1318
|
+
return DEFAULT_THEME_KEYS.reduce((colors, key) => {
|
|
1319
|
+
colors[key] = {
|
|
1320
|
+
close: "",
|
|
1321
|
+
open: ""
|
|
1322
|
+
};
|
|
1323
|
+
return colors;
|
|
1324
|
+
}, /* @__PURE__ */ Object.create(null));
|
|
1325
|
+
}
|
|
1326
|
+
function getPrintFunctionName(options) {
|
|
1327
|
+
return options?.printFunctionName ?? DEFAULT_OPTIONS.printFunctionName;
|
|
1328
|
+
}
|
|
1329
|
+
function getEscapeRegex(options) {
|
|
1330
|
+
return options?.escapeRegex ?? DEFAULT_OPTIONS.escapeRegex;
|
|
1331
|
+
}
|
|
1332
|
+
function getEscapeString(options) {
|
|
1333
|
+
return options?.escapeString ?? DEFAULT_OPTIONS.escapeString;
|
|
1334
|
+
}
|
|
1335
|
+
function getConfig(options) {
|
|
1336
|
+
return {
|
|
1337
|
+
callToJSON: options?.callToJSON ?? DEFAULT_OPTIONS.callToJSON,
|
|
1338
|
+
colors: options?.highlight ? getColorsHighlight() : getColorsEmpty(),
|
|
1339
|
+
compareKeys: typeof options?.compareKeys === "function" || options?.compareKeys === null ? options.compareKeys : DEFAULT_OPTIONS.compareKeys,
|
|
1340
|
+
escapeRegex: getEscapeRegex(options),
|
|
1341
|
+
escapeString: getEscapeString(options),
|
|
1342
|
+
indent: options?.min ? "" : createIndent(options?.indent ?? DEFAULT_OPTIONS.indent),
|
|
1343
|
+
maxDepth: options?.maxDepth ?? DEFAULT_OPTIONS.maxDepth,
|
|
1344
|
+
maxWidth: options?.maxWidth ?? DEFAULT_OPTIONS.maxWidth,
|
|
1345
|
+
min: options?.min ?? DEFAULT_OPTIONS.min,
|
|
1346
|
+
plugins: options?.plugins ?? DEFAULT_OPTIONS.plugins,
|
|
1347
|
+
printBasicPrototype: options?.printBasicPrototype ?? true,
|
|
1348
|
+
printFunctionName: getPrintFunctionName(options),
|
|
1349
|
+
printShadowRoot: options?.printShadowRoot ?? true,
|
|
1350
|
+
spacingInner: options?.min ? " " : "\n",
|
|
1351
|
+
spacingOuter: options?.min ? "" : "\n",
|
|
1352
|
+
maxOutputLength: options?.maxOutputLength ?? DEFAULT_OPTIONS.maxOutputLength,
|
|
1353
|
+
_outputLengthPerDepth: []
|
|
1354
|
+
};
|
|
1355
|
+
}
|
|
1356
|
+
function createIndent(indent) {
|
|
1357
|
+
return Array.from({ length: indent + 1 }).join(" ");
|
|
1358
|
+
}
|
|
1359
|
+
function format(val, options) {
|
|
1360
|
+
if (options) {
|
|
1361
|
+
validateOptions(options);
|
|
1362
|
+
if (options.plugins) {
|
|
1363
|
+
const plugin2 = findPlugin(options.plugins, val);
|
|
1364
|
+
if (plugin2 !== null) {
|
|
1365
|
+
return printPlugin(plugin2, val, getConfig(options), "", 0, []);
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
const basicResult = printBasicValue(val, getPrintFunctionName(options), getEscapeRegex(options), getEscapeString(options));
|
|
1370
|
+
if (basicResult !== null) {
|
|
1371
|
+
return basicResult;
|
|
1372
|
+
}
|
|
1373
|
+
return printComplexValue(val, getConfig(options), "", 0, []);
|
|
1374
|
+
}
|
|
1375
|
+
var plugins = {
|
|
1376
|
+
AsymmetricMatcher: plugin$5,
|
|
1377
|
+
DOMCollection: plugin$4,
|
|
1378
|
+
DOMElement: plugin$3,
|
|
1379
|
+
Immutable: plugin$2,
|
|
1380
|
+
ReactElement: plugin$1,
|
|
1381
|
+
ReactTestComponent: plugin,
|
|
1382
|
+
Error: ErrorPlugin
|
|
1383
|
+
};
|
|
1384
|
+
|
|
1385
|
+
// node_modules/@vitest/utils/dist/display.js
|
|
1386
|
+
var ansiColors = {
|
|
1387
|
+
bold: ["1", "22"],
|
|
1388
|
+
dim: ["2", "22"],
|
|
1389
|
+
italic: ["3", "23"],
|
|
1390
|
+
underline: ["4", "24"],
|
|
1391
|
+
// 5 & 6 are blinking
|
|
1392
|
+
inverse: ["7", "27"],
|
|
1393
|
+
hidden: ["8", "28"],
|
|
1394
|
+
strike: ["9", "29"],
|
|
1395
|
+
// 10-20 are fonts
|
|
1396
|
+
// 21-29 are resets for 1-9
|
|
1397
|
+
black: ["30", "39"],
|
|
1398
|
+
red: ["31", "39"],
|
|
1399
|
+
green: ["32", "39"],
|
|
1400
|
+
yellow: ["33", "39"],
|
|
1401
|
+
blue: ["34", "39"],
|
|
1402
|
+
magenta: ["35", "39"],
|
|
1403
|
+
cyan: ["36", "39"],
|
|
1404
|
+
white: ["37", "39"],
|
|
1405
|
+
brightblack: ["30;1", "39"],
|
|
1406
|
+
brightred: ["31;1", "39"],
|
|
1407
|
+
brightgreen: ["32;1", "39"],
|
|
1408
|
+
brightyellow: ["33;1", "39"],
|
|
1409
|
+
brightblue: ["34;1", "39"],
|
|
1410
|
+
brightmagenta: ["35;1", "39"],
|
|
1411
|
+
brightcyan: ["36;1", "39"],
|
|
1412
|
+
brightwhite: ["37;1", "39"],
|
|
1413
|
+
grey: ["90", "39"]
|
|
1414
|
+
};
|
|
1415
|
+
var styles = {
|
|
1416
|
+
special: "cyan",
|
|
1417
|
+
number: "yellow",
|
|
1418
|
+
bigint: "yellow",
|
|
1419
|
+
boolean: "yellow",
|
|
1420
|
+
undefined: "grey",
|
|
1421
|
+
null: "bold",
|
|
1422
|
+
string: "green",
|
|
1423
|
+
symbol: "green",
|
|
1424
|
+
date: "magenta",
|
|
1425
|
+
regexp: "red"
|
|
1426
|
+
};
|
|
1427
|
+
var truncator = "\u2026";
|
|
1428
|
+
function colorise(value, styleType) {
|
|
1429
|
+
const color = ansiColors[styles[styleType]] || ansiColors[styleType] || "";
|
|
1430
|
+
if (!color) {
|
|
1431
|
+
return String(value);
|
|
1432
|
+
}
|
|
1433
|
+
return `\x1B[${color[0]}m${String(value)}\x1B[${color[1]}m`;
|
|
1434
|
+
}
|
|
1435
|
+
function normaliseOptions({
|
|
1436
|
+
showHidden = false,
|
|
1437
|
+
depth = 2,
|
|
1438
|
+
colors = false,
|
|
1439
|
+
customInspect = true,
|
|
1440
|
+
showProxy = false,
|
|
1441
|
+
maxArrayLength = Infinity,
|
|
1442
|
+
breakLength = Infinity,
|
|
1443
|
+
seen = [],
|
|
1444
|
+
// eslint-disable-next-line no-shadow
|
|
1445
|
+
truncate: truncate2 = Infinity,
|
|
1446
|
+
stylize = String
|
|
1447
|
+
} = {}, inspect2) {
|
|
1448
|
+
const options = {
|
|
1449
|
+
showHidden: Boolean(showHidden),
|
|
1450
|
+
depth: Number(depth),
|
|
1451
|
+
colors: Boolean(colors),
|
|
1452
|
+
customInspect: Boolean(customInspect),
|
|
1453
|
+
showProxy: Boolean(showProxy),
|
|
1454
|
+
maxArrayLength: Number(maxArrayLength),
|
|
1455
|
+
breakLength: Number(breakLength),
|
|
1456
|
+
truncate: Number(truncate2),
|
|
1457
|
+
seen,
|
|
1458
|
+
inspect: inspect2,
|
|
1459
|
+
stylize
|
|
1460
|
+
};
|
|
1461
|
+
if (options.colors) {
|
|
1462
|
+
options.stylize = colorise;
|
|
1463
|
+
}
|
|
1464
|
+
return options;
|
|
1465
|
+
}
|
|
1466
|
+
function isHighSurrogate(char) {
|
|
1467
|
+
return char >= "\uD800" && char <= "\uDBFF";
|
|
1468
|
+
}
|
|
1469
|
+
function truncate(string, length, tail = truncator) {
|
|
1470
|
+
string = String(string);
|
|
1471
|
+
const tailLength = tail.length;
|
|
1472
|
+
const stringLength = string.length;
|
|
1473
|
+
if (tailLength > length && stringLength > tailLength) {
|
|
1474
|
+
return tail;
|
|
1475
|
+
}
|
|
1476
|
+
if (stringLength > length && stringLength > tailLength) {
|
|
1477
|
+
let end = length - tailLength;
|
|
1478
|
+
if (end > 0 && isHighSurrogate(string[end - 1])) {
|
|
1479
|
+
end = end - 1;
|
|
1480
|
+
}
|
|
1481
|
+
return `${string.slice(0, end)}${tail}`;
|
|
1482
|
+
}
|
|
1483
|
+
return string;
|
|
1484
|
+
}
|
|
1485
|
+
function inspectList(list, options, inspectItem, separator = ", ") {
|
|
1486
|
+
inspectItem = inspectItem || options.inspect;
|
|
1487
|
+
const size = list.length;
|
|
1488
|
+
if (size === 0)
|
|
1489
|
+
return "";
|
|
1490
|
+
const originalLength = options.truncate;
|
|
1491
|
+
let output = "";
|
|
1492
|
+
let peek = "";
|
|
1493
|
+
let truncated = "";
|
|
1494
|
+
for (let i2 = 0; i2 < size; i2 += 1) {
|
|
1495
|
+
const last = i2 + 1 === list.length;
|
|
1496
|
+
const secondToLast = i2 + 2 === list.length;
|
|
1497
|
+
truncated = `${truncator}(${list.length - i2})`;
|
|
1498
|
+
const value = list[i2];
|
|
1499
|
+
options.truncate = originalLength - output.length - (last ? 0 : separator.length);
|
|
1500
|
+
const string = peek || inspectItem(value, options) + (last ? "" : separator);
|
|
1501
|
+
const nextLength = output.length + string.length;
|
|
1502
|
+
const truncatedLength = nextLength + truncated.length;
|
|
1503
|
+
if (last && nextLength > originalLength && output.length + truncated.length <= originalLength) {
|
|
1504
|
+
break;
|
|
1505
|
+
}
|
|
1506
|
+
if (!last && !secondToLast && truncatedLength > originalLength) {
|
|
1507
|
+
break;
|
|
1508
|
+
}
|
|
1509
|
+
peek = last ? "" : inspectItem(list[i2 + 1], options) + (secondToLast ? "" : separator);
|
|
1510
|
+
if (!last && secondToLast && truncatedLength > originalLength && nextLength + peek.length > originalLength) {
|
|
1511
|
+
break;
|
|
1512
|
+
}
|
|
1513
|
+
output += string;
|
|
1514
|
+
if (!last && !secondToLast && nextLength + peek.length >= originalLength) {
|
|
1515
|
+
truncated = `${truncator}(${list.length - i2 - 1})`;
|
|
1516
|
+
break;
|
|
1517
|
+
}
|
|
1518
|
+
truncated = "";
|
|
1519
|
+
}
|
|
1520
|
+
return `${output}${truncated}`;
|
|
1521
|
+
}
|
|
1522
|
+
function quoteComplexKey(key) {
|
|
1523
|
+
if (key.match(/^[a-zA-Z_][a-zA-Z_0-9]*$/)) {
|
|
1524
|
+
return key;
|
|
1525
|
+
}
|
|
1526
|
+
return JSON.stringify(key).replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'");
|
|
1527
|
+
}
|
|
1528
|
+
function inspectProperty([key, value], options) {
|
|
1529
|
+
options.truncate -= 2;
|
|
1530
|
+
if (typeof key === "string") {
|
|
1531
|
+
key = quoteComplexKey(key);
|
|
1532
|
+
} else if (typeof key !== "number") {
|
|
1533
|
+
key = `[${options.inspect(key, options)}]`;
|
|
1534
|
+
}
|
|
1535
|
+
options.truncate -= key.length;
|
|
1536
|
+
value = options.inspect(value, options);
|
|
1537
|
+
return `${key}: ${value}`;
|
|
1538
|
+
}
|
|
1539
|
+
function inspectArray(array, options) {
|
|
1540
|
+
const nonIndexProperties = Object.keys(array).slice(array.length);
|
|
1541
|
+
if (!array.length && !nonIndexProperties.length)
|
|
1542
|
+
return "[]";
|
|
1543
|
+
options.truncate -= 4;
|
|
1544
|
+
const listContents = inspectList(array, options);
|
|
1545
|
+
options.truncate -= listContents.length;
|
|
1546
|
+
let propertyContents = "";
|
|
1547
|
+
if (nonIndexProperties.length) {
|
|
1548
|
+
propertyContents = inspectList(nonIndexProperties.map((key) => [key, array[key]]), options, inspectProperty);
|
|
1549
|
+
}
|
|
1550
|
+
return `[ ${listContents}${propertyContents ? `, ${propertyContents}` : ""} ]`;
|
|
1551
|
+
}
|
|
1552
|
+
var getArrayName = (array) => {
|
|
1553
|
+
if (typeof Buffer === "function" && array instanceof Buffer) {
|
|
1554
|
+
return "Buffer";
|
|
1555
|
+
}
|
|
1556
|
+
if (array[Symbol.toStringTag]) {
|
|
1557
|
+
return array[Symbol.toStringTag];
|
|
1558
|
+
}
|
|
1559
|
+
return array.constructor.name;
|
|
1560
|
+
};
|
|
1561
|
+
function inspectTypedArray(array, options) {
|
|
1562
|
+
const name = getArrayName(array);
|
|
1563
|
+
options.truncate -= name.length + 4;
|
|
1564
|
+
const nonIndexProperties = Object.keys(array).slice(array.length);
|
|
1565
|
+
if (!array.length && !nonIndexProperties.length)
|
|
1566
|
+
return `${name}[]`;
|
|
1567
|
+
let output = "";
|
|
1568
|
+
for (let i2 = 0; i2 < array.length; i2++) {
|
|
1569
|
+
const string = `${options.stylize(truncate(array[i2], options.truncate), "number")}${i2 === array.length - 1 ? "" : ", "}`;
|
|
1570
|
+
options.truncate -= string.length;
|
|
1571
|
+
if (array[i2] !== array.length && options.truncate <= 3) {
|
|
1572
|
+
output += `${truncator}(${array.length - array[i2] + 1})`;
|
|
1573
|
+
break;
|
|
1574
|
+
}
|
|
1575
|
+
output += string;
|
|
1576
|
+
}
|
|
1577
|
+
let propertyContents = "";
|
|
1578
|
+
if (nonIndexProperties.length) {
|
|
1579
|
+
propertyContents = inspectList(nonIndexProperties.map((key) => [key, array[key]]), options, inspectProperty);
|
|
1580
|
+
}
|
|
1581
|
+
return `${name}[ ${output}${propertyContents ? `, ${propertyContents}` : ""} ]`;
|
|
1582
|
+
}
|
|
1583
|
+
function inspectDate(dateObject, options) {
|
|
1584
|
+
const stringRepresentation = dateObject.toJSON();
|
|
1585
|
+
if (stringRepresentation === null) {
|
|
1586
|
+
return "Invalid Date";
|
|
1587
|
+
}
|
|
1588
|
+
const split = stringRepresentation.split("T");
|
|
1589
|
+
const date = split[0];
|
|
1590
|
+
return options.stylize(`${date}T${truncate(split[1], options.truncate - date.length - 1)}`, "date");
|
|
1591
|
+
}
|
|
1592
|
+
function inspectFunction(func, options) {
|
|
1593
|
+
const functionType = func[Symbol.toStringTag] || "Function";
|
|
1594
|
+
const name = func.name;
|
|
1595
|
+
if (!name) {
|
|
1596
|
+
return options.stylize(`[${functionType}]`, "special");
|
|
1597
|
+
}
|
|
1598
|
+
return options.stylize(`[${functionType} ${truncate(name, options.truncate - 11)}]`, "special");
|
|
1599
|
+
}
|
|
1600
|
+
function inspectMapEntry([key, value], options) {
|
|
1601
|
+
options.truncate -= 4;
|
|
1602
|
+
key = options.inspect(key, options);
|
|
1603
|
+
options.truncate -= key.length;
|
|
1604
|
+
value = options.inspect(value, options);
|
|
1605
|
+
return `${key} => ${value}`;
|
|
1606
|
+
}
|
|
1607
|
+
function mapToEntries(map) {
|
|
1608
|
+
const entries = [];
|
|
1609
|
+
map.forEach((value, key) => {
|
|
1610
|
+
entries.push([key, value]);
|
|
1611
|
+
});
|
|
1612
|
+
return entries;
|
|
1613
|
+
}
|
|
1614
|
+
function inspectMap(map, options) {
|
|
1615
|
+
if (map.size === 0)
|
|
1616
|
+
return "Map{}";
|
|
1617
|
+
options.truncate -= 7;
|
|
1618
|
+
return `Map{ ${inspectList(mapToEntries(map), options, inspectMapEntry)} }`;
|
|
1619
|
+
}
|
|
1620
|
+
var isNaN = Number.isNaN || ((i2) => i2 !== i2);
|
|
1621
|
+
function inspectNumber(number, options) {
|
|
1622
|
+
if (isNaN(number)) {
|
|
1623
|
+
return options.stylize("NaN", "number");
|
|
1624
|
+
}
|
|
1625
|
+
if (number === Infinity) {
|
|
1626
|
+
return options.stylize("Infinity", "number");
|
|
1627
|
+
}
|
|
1628
|
+
if (number === -Infinity) {
|
|
1629
|
+
return options.stylize("-Infinity", "number");
|
|
1630
|
+
}
|
|
1631
|
+
if (number === 0) {
|
|
1632
|
+
return options.stylize(1 / number === Infinity ? "+0" : "-0", "number");
|
|
1633
|
+
}
|
|
1634
|
+
return options.stylize(truncate(String(number), options.truncate), "number");
|
|
1635
|
+
}
|
|
1636
|
+
function inspectBigInt(number, options) {
|
|
1637
|
+
let nums = truncate(number.toString(), options.truncate - 1);
|
|
1638
|
+
if (nums !== truncator)
|
|
1639
|
+
nums += "n";
|
|
1640
|
+
return options.stylize(nums, "bigint");
|
|
1641
|
+
}
|
|
1642
|
+
function inspectRegExp(value, options) {
|
|
1643
|
+
const flags = value.toString().split("/")[2];
|
|
1644
|
+
const sourceLength = options.truncate - (2 + flags.length);
|
|
1645
|
+
const source = value.source;
|
|
1646
|
+
return options.stylize(`/${truncate(source, sourceLength)}/${flags}`, "regexp");
|
|
1647
|
+
}
|
|
1648
|
+
function arrayFromSet(set) {
|
|
1649
|
+
const values = [];
|
|
1650
|
+
set.forEach((value) => {
|
|
1651
|
+
values.push(value);
|
|
1652
|
+
});
|
|
1653
|
+
return values;
|
|
1654
|
+
}
|
|
1655
|
+
function inspectSet(set, options) {
|
|
1656
|
+
if (set.size === 0)
|
|
1657
|
+
return "Set{}";
|
|
1658
|
+
options.truncate -= 7;
|
|
1659
|
+
return `Set{ ${inspectList(arrayFromSet(set), options)} }`;
|
|
1660
|
+
}
|
|
1661
|
+
var stringEscapeChars = new RegExp("['\\u0000-\\u001f\\u007f-\\u009f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]", "g");
|
|
1662
|
+
var escapeCharacters = {
|
|
1663
|
+
"\b": "\\b",
|
|
1664
|
+
" ": "\\t",
|
|
1665
|
+
"\n": "\\n",
|
|
1666
|
+
"\f": "\\f",
|
|
1667
|
+
"\r": "\\r",
|
|
1668
|
+
"'": "\\'",
|
|
1669
|
+
"\\": "\\\\"
|
|
1670
|
+
};
|
|
1671
|
+
var hex = 16;
|
|
1672
|
+
function escape(char) {
|
|
1673
|
+
return escapeCharacters[char] || `\\u${`0000${char.charCodeAt(0).toString(hex)}`.slice(-4)}`;
|
|
1674
|
+
}
|
|
1675
|
+
function inspectString(string, options) {
|
|
1676
|
+
if (stringEscapeChars.test(string)) {
|
|
1677
|
+
string = string.replace(stringEscapeChars, escape);
|
|
1678
|
+
}
|
|
1679
|
+
return options.stylize(`'${truncate(string, options.truncate - 2)}'`, "string");
|
|
1680
|
+
}
|
|
1681
|
+
function inspectSymbol(value) {
|
|
1682
|
+
if ("description" in Symbol.prototype) {
|
|
1683
|
+
return value.description ? `Symbol(${value.description})` : "Symbol()";
|
|
1684
|
+
}
|
|
1685
|
+
return value.toString();
|
|
1686
|
+
}
|
|
1687
|
+
var getPromiseValue = () => "Promise{\u2026}";
|
|
1688
|
+
function inspectObject$1(object, options) {
|
|
1689
|
+
const properties = Object.getOwnPropertyNames(object);
|
|
1690
|
+
const symbols = Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : [];
|
|
1691
|
+
if (properties.length === 0 && symbols.length === 0) {
|
|
1692
|
+
return "{}";
|
|
1693
|
+
}
|
|
1694
|
+
options.truncate -= 4;
|
|
1695
|
+
options.seen = options.seen || [];
|
|
1696
|
+
if (options.seen.includes(object)) {
|
|
1697
|
+
return "[Circular]";
|
|
1698
|
+
}
|
|
1699
|
+
options.seen.push(object);
|
|
1700
|
+
const propertyContents = inspectList(properties.map((key) => [key, object[key]]), options, inspectProperty);
|
|
1701
|
+
const symbolContents = inspectList(symbols.map((key) => [key, object[key]]), options, inspectProperty);
|
|
1702
|
+
options.seen.pop();
|
|
1703
|
+
let sep = "";
|
|
1704
|
+
if (propertyContents && symbolContents) {
|
|
1705
|
+
sep = ", ";
|
|
1706
|
+
}
|
|
1707
|
+
return `{ ${propertyContents}${sep}${symbolContents} }`;
|
|
1708
|
+
}
|
|
1709
|
+
var toStringTag = typeof Symbol !== "undefined" && Symbol.toStringTag ? Symbol.toStringTag : false;
|
|
1710
|
+
function inspectClass(value, options) {
|
|
1711
|
+
let name = "";
|
|
1712
|
+
if (toStringTag && toStringTag in value) {
|
|
1713
|
+
name = value[toStringTag];
|
|
1714
|
+
}
|
|
1715
|
+
name = name || value.constructor.name;
|
|
1716
|
+
if (!name || name === "_class") {
|
|
1717
|
+
name = "<Anonymous Class>";
|
|
1718
|
+
}
|
|
1719
|
+
options.truncate -= name.length;
|
|
1720
|
+
return `${name}${inspectObject$1(value, options)}`;
|
|
1721
|
+
}
|
|
1722
|
+
function inspectArguments(args, options) {
|
|
1723
|
+
if (args.length === 0)
|
|
1724
|
+
return "Arguments[]";
|
|
1725
|
+
options.truncate -= 13;
|
|
1726
|
+
return `Arguments[ ${inspectList(args, options)} ]`;
|
|
1727
|
+
}
|
|
1728
|
+
var errorKeys = [
|
|
1729
|
+
"stack",
|
|
1730
|
+
"line",
|
|
1731
|
+
"column",
|
|
1732
|
+
"name",
|
|
1733
|
+
"message",
|
|
1734
|
+
"fileName",
|
|
1735
|
+
"lineNumber",
|
|
1736
|
+
"columnNumber",
|
|
1737
|
+
"number",
|
|
1738
|
+
"description",
|
|
1739
|
+
"cause"
|
|
1740
|
+
];
|
|
1741
|
+
function inspectObject(error, options) {
|
|
1742
|
+
const properties = Object.getOwnPropertyNames(error).filter((key) => errorKeys.indexOf(key) === -1);
|
|
1743
|
+
const name = error.name;
|
|
1744
|
+
options.truncate -= name.length;
|
|
1745
|
+
let message = "";
|
|
1746
|
+
if (typeof error.message === "string") {
|
|
1747
|
+
message = truncate(error.message, options.truncate);
|
|
1748
|
+
} else {
|
|
1749
|
+
properties.unshift("message");
|
|
1750
|
+
}
|
|
1751
|
+
message = message ? `: ${message}` : "";
|
|
1752
|
+
options.truncate -= message.length + 5;
|
|
1753
|
+
options.seen = options.seen || [];
|
|
1754
|
+
if (options.seen.includes(error)) {
|
|
1755
|
+
return "[Circular]";
|
|
1756
|
+
}
|
|
1757
|
+
options.seen.push(error);
|
|
1758
|
+
const propertyContents = inspectList(properties.map((key) => [key, error[key]]), options, inspectProperty);
|
|
1759
|
+
return `${name}${message}${propertyContents ? ` { ${propertyContents} }` : ""}`;
|
|
1760
|
+
}
|
|
1761
|
+
function inspectAttribute([key, value], options) {
|
|
1762
|
+
options.truncate -= 3;
|
|
1763
|
+
if (!value) {
|
|
1764
|
+
return `${options.stylize(String(key), "yellow")}`;
|
|
1765
|
+
}
|
|
1766
|
+
return `${options.stylize(String(key), "yellow")}=${options.stylize(`"${value}"`, "string")}`;
|
|
1767
|
+
}
|
|
1768
|
+
function inspectNodeCollection(collection, options) {
|
|
1769
|
+
return inspectList(collection, options, inspectNode, "\n");
|
|
1770
|
+
}
|
|
1771
|
+
function inspectNode(node, options) {
|
|
1772
|
+
switch (node.nodeType) {
|
|
1773
|
+
case 1:
|
|
1774
|
+
return inspectHTML(node, options);
|
|
1775
|
+
case 3:
|
|
1776
|
+
return options.inspect(node.data, options);
|
|
1777
|
+
default:
|
|
1778
|
+
return options.inspect(node, options);
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
function inspectHTML(element, options) {
|
|
1782
|
+
const properties = element.getAttributeNames();
|
|
1783
|
+
const name = element.tagName.toLowerCase();
|
|
1784
|
+
const head = options.stylize(`<${name}`, "special");
|
|
1785
|
+
const headClose = options.stylize(`>`, "special");
|
|
1786
|
+
const tail = options.stylize(`</${name}>`, "special");
|
|
1787
|
+
options.truncate -= name.length * 2 + 5;
|
|
1788
|
+
let propertyContents = "";
|
|
1789
|
+
if (properties.length > 0) {
|
|
1790
|
+
propertyContents += " ";
|
|
1791
|
+
propertyContents += inspectList(properties.map((key) => [key, element.getAttribute(key)]), options, inspectAttribute, " ");
|
|
1792
|
+
}
|
|
1793
|
+
options.truncate -= propertyContents.length;
|
|
1794
|
+
const truncate2 = options.truncate;
|
|
1795
|
+
let children = inspectNodeCollection(element.children, options);
|
|
1796
|
+
if (children && children.length > truncate2) {
|
|
1797
|
+
children = `${truncator}(${element.children.length})`;
|
|
1798
|
+
}
|
|
1799
|
+
return `${head}${propertyContents}${headClose}${children}${tail}`;
|
|
1800
|
+
}
|
|
1801
|
+
var symbolsSupported = typeof Symbol === "function" && typeof Symbol.for === "function";
|
|
1802
|
+
var chaiInspect = symbolsSupported ? /* @__PURE__ */ Symbol.for("chai/inspect") : "@@chai/inspect";
|
|
1803
|
+
var nodeInspect = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
|
|
1804
|
+
var constructorMap = /* @__PURE__ */ new WeakMap();
|
|
1805
|
+
var stringTagMap = {};
|
|
1806
|
+
var baseTypesMap = {
|
|
1807
|
+
undefined: (value, options) => options.stylize("undefined", "undefined"),
|
|
1808
|
+
null: (value, options) => options.stylize("null", "null"),
|
|
1809
|
+
boolean: (value, options) => options.stylize(String(value), "boolean"),
|
|
1810
|
+
Boolean: (value, options) => options.stylize(String(value), "boolean"),
|
|
1811
|
+
number: inspectNumber,
|
|
1812
|
+
Number: inspectNumber,
|
|
1813
|
+
bigint: inspectBigInt,
|
|
1814
|
+
BigInt: inspectBigInt,
|
|
1815
|
+
string: inspectString,
|
|
1816
|
+
String: inspectString,
|
|
1817
|
+
function: inspectFunction,
|
|
1818
|
+
Function: inspectFunction,
|
|
1819
|
+
symbol: inspectSymbol,
|
|
1820
|
+
// A Symbol polyfill will return `Symbol` not `symbol` from typedetect
|
|
1821
|
+
Symbol: inspectSymbol,
|
|
1822
|
+
Array: inspectArray,
|
|
1823
|
+
Date: inspectDate,
|
|
1824
|
+
Map: inspectMap,
|
|
1825
|
+
Set: inspectSet,
|
|
1826
|
+
RegExp: inspectRegExp,
|
|
1827
|
+
Promise: getPromiseValue,
|
|
1828
|
+
// WeakSet, WeakMap are totally opaque to us
|
|
1829
|
+
WeakSet: (value, options) => options.stylize("WeakSet{\u2026}", "special"),
|
|
1830
|
+
WeakMap: (value, options) => options.stylize("WeakMap{\u2026}", "special"),
|
|
1831
|
+
Arguments: inspectArguments,
|
|
1832
|
+
Int8Array: inspectTypedArray,
|
|
1833
|
+
Uint8Array: inspectTypedArray,
|
|
1834
|
+
Uint8ClampedArray: inspectTypedArray,
|
|
1835
|
+
Int16Array: inspectTypedArray,
|
|
1836
|
+
Uint16Array: inspectTypedArray,
|
|
1837
|
+
Int32Array: inspectTypedArray,
|
|
1838
|
+
Uint32Array: inspectTypedArray,
|
|
1839
|
+
Float32Array: inspectTypedArray,
|
|
1840
|
+
Float64Array: inspectTypedArray,
|
|
1841
|
+
Generator: () => "",
|
|
1842
|
+
DataView: () => "",
|
|
1843
|
+
ArrayBuffer: () => "",
|
|
1844
|
+
Error: inspectObject,
|
|
1845
|
+
HTMLCollection: inspectNodeCollection,
|
|
1846
|
+
NodeList: inspectNodeCollection
|
|
1847
|
+
};
|
|
1848
|
+
var inspectCustom = (value, options, type, inspectFn) => {
|
|
1849
|
+
if (chaiInspect in value && typeof value[chaiInspect] === "function") {
|
|
1850
|
+
return value[chaiInspect](options);
|
|
1851
|
+
}
|
|
1852
|
+
if (nodeInspect in value && typeof value[nodeInspect] === "function") {
|
|
1853
|
+
return value[nodeInspect](options.depth, options, inspectFn);
|
|
1854
|
+
}
|
|
1855
|
+
if ("inspect" in value && typeof value.inspect === "function") {
|
|
1856
|
+
return value.inspect(options.depth, options);
|
|
1857
|
+
}
|
|
1858
|
+
if ("constructor" in value && constructorMap.has(value.constructor)) {
|
|
1859
|
+
return constructorMap.get(value.constructor)(value, options);
|
|
1860
|
+
}
|
|
1861
|
+
if (stringTagMap[type]) {
|
|
1862
|
+
return stringTagMap[type](value, options);
|
|
1863
|
+
}
|
|
1864
|
+
return "";
|
|
1865
|
+
};
|
|
1866
|
+
var toString2 = Object.prototype.toString;
|
|
1867
|
+
function inspect$1(value, opts = {}) {
|
|
1868
|
+
const options = normaliseOptions(opts, inspect$1);
|
|
1869
|
+
const { customInspect } = options;
|
|
1870
|
+
let type = value === null ? "null" : typeof value;
|
|
1871
|
+
if (type === "object") {
|
|
1872
|
+
type = toString2.call(value).slice(8, -1);
|
|
1873
|
+
}
|
|
1874
|
+
if (type in baseTypesMap) {
|
|
1875
|
+
return baseTypesMap[type](value, options);
|
|
1876
|
+
}
|
|
1877
|
+
if (customInspect && value) {
|
|
1878
|
+
const output = inspectCustom(value, options, type, inspect$1);
|
|
1879
|
+
if (output) {
|
|
1880
|
+
if (typeof output === "string")
|
|
1881
|
+
return output;
|
|
1882
|
+
return inspect$1(output, options);
|
|
1883
|
+
}
|
|
1884
|
+
}
|
|
1885
|
+
const proto = value ? Object.getPrototypeOf(value) : false;
|
|
1886
|
+
if (proto === Object.prototype || proto === null) {
|
|
1887
|
+
return inspectObject$1(value, options);
|
|
1888
|
+
}
|
|
1889
|
+
if (value && typeof HTMLElement === "function" && value instanceof HTMLElement) {
|
|
1890
|
+
return inspectHTML(value, options);
|
|
1891
|
+
}
|
|
1892
|
+
if ("constructor" in value) {
|
|
1893
|
+
if (value.constructor !== Object) {
|
|
1894
|
+
return inspectClass(value, options);
|
|
1895
|
+
}
|
|
1896
|
+
return inspectObject$1(value, options);
|
|
1897
|
+
}
|
|
1898
|
+
if (value === Object(value)) {
|
|
1899
|
+
return inspectObject$1(value, options);
|
|
1900
|
+
}
|
|
1901
|
+
return options.stylize(String(value), type);
|
|
1902
|
+
}
|
|
1903
|
+
var { AsymmetricMatcher, DOMCollection, DOMElement, Immutable, ReactElement, ReactTestComponent } = plugins;
|
|
1904
|
+
var PLUGINS = [
|
|
1905
|
+
ReactTestComponent,
|
|
1906
|
+
ReactElement,
|
|
1907
|
+
DOMElement,
|
|
1908
|
+
DOMCollection,
|
|
1909
|
+
Immutable,
|
|
1910
|
+
AsymmetricMatcher
|
|
1911
|
+
];
|
|
1912
|
+
function stringify(object, maxDepth = 10, { maxLength, filterNode, ...options } = {}) {
|
|
1913
|
+
const MAX_LENGTH = maxLength ?? 1e4;
|
|
1914
|
+
let result;
|
|
1915
|
+
const filterFn = typeof filterNode === "string" ? createNodeFilterFromSelector(filterNode) : filterNode;
|
|
1916
|
+
const plugins2 = filterFn ? [
|
|
1917
|
+
ReactTestComponent,
|
|
1918
|
+
ReactElement,
|
|
1919
|
+
createDOMElementFilter(filterFn),
|
|
1920
|
+
DOMCollection,
|
|
1921
|
+
Immutable,
|
|
1922
|
+
AsymmetricMatcher
|
|
1923
|
+
] : PLUGINS;
|
|
1924
|
+
try {
|
|
1925
|
+
result = format(object, {
|
|
1926
|
+
maxDepth,
|
|
1927
|
+
escapeString: false,
|
|
1928
|
+
plugins: plugins2,
|
|
1929
|
+
...options
|
|
1930
|
+
});
|
|
1931
|
+
} catch {
|
|
1932
|
+
result = format(object, {
|
|
1933
|
+
callToJSON: false,
|
|
1934
|
+
maxDepth,
|
|
1935
|
+
escapeString: false,
|
|
1936
|
+
plugins: plugins2,
|
|
1937
|
+
...options
|
|
1938
|
+
});
|
|
1939
|
+
}
|
|
1940
|
+
return result.length >= MAX_LENGTH && maxDepth > 1 ? stringify(object, Math.floor(Math.min(maxDepth, Number.MAX_SAFE_INTEGER) / 2), {
|
|
1941
|
+
maxLength,
|
|
1942
|
+
filterNode,
|
|
1943
|
+
...options
|
|
1944
|
+
}) : result;
|
|
1945
|
+
}
|
|
1946
|
+
function createNodeFilterFromSelector(selector) {
|
|
1947
|
+
const ELEMENT_NODE2 = 1;
|
|
1948
|
+
const COMMENT_NODE2 = 8;
|
|
1949
|
+
return (node) => {
|
|
1950
|
+
if (node.nodeType === COMMENT_NODE2) {
|
|
1951
|
+
return false;
|
|
1952
|
+
}
|
|
1953
|
+
if (node.nodeType === ELEMENT_NODE2 && node.matches) {
|
|
1954
|
+
try {
|
|
1955
|
+
return !node.matches(selector);
|
|
1956
|
+
} catch {
|
|
1957
|
+
return true;
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
return true;
|
|
1961
|
+
};
|
|
1962
|
+
}
|
|
1963
|
+
var formatRegExp = /%[sdjifoOc%]/g;
|
|
1964
|
+
function baseFormat(args, options = {}) {
|
|
1965
|
+
const formatArg = (item, inspecOptions) => {
|
|
1966
|
+
if (options.prettifyObject) {
|
|
1967
|
+
return stringify(item, void 0, {
|
|
1968
|
+
printBasicPrototype: false,
|
|
1969
|
+
escapeString: false
|
|
1970
|
+
});
|
|
1971
|
+
}
|
|
1972
|
+
return inspect(item, inspecOptions);
|
|
1973
|
+
};
|
|
1974
|
+
if (typeof args[0] !== "string") {
|
|
1975
|
+
const objects = [];
|
|
1976
|
+
for (let i3 = 0; i3 < args.length; i3++) {
|
|
1977
|
+
objects.push(formatArg(args[i3], {
|
|
1978
|
+
depth: 0,
|
|
1979
|
+
colors: false
|
|
1980
|
+
}));
|
|
1981
|
+
}
|
|
1982
|
+
return objects.join(" ");
|
|
1983
|
+
}
|
|
1984
|
+
const len = args.length;
|
|
1985
|
+
let i2 = 1;
|
|
1986
|
+
const template = args[0];
|
|
1987
|
+
let str = String(template).replace(formatRegExp, (x) => {
|
|
1988
|
+
if (x === "%%") {
|
|
1989
|
+
return "%";
|
|
1990
|
+
}
|
|
1991
|
+
if (i2 >= len) {
|
|
1992
|
+
return x;
|
|
1993
|
+
}
|
|
1994
|
+
switch (x) {
|
|
1995
|
+
case "%s": {
|
|
1996
|
+
const value = args[i2++];
|
|
1997
|
+
if (typeof value === "bigint") {
|
|
1998
|
+
return `${value.toString()}n`;
|
|
1999
|
+
}
|
|
2000
|
+
if (typeof value === "number" && value === 0 && 1 / value < 0) {
|
|
2001
|
+
return "-0";
|
|
2002
|
+
}
|
|
2003
|
+
if (typeof value === "object" && value !== null) {
|
|
2004
|
+
if (typeof value.toString === "function" && value.toString !== Object.prototype.toString) {
|
|
2005
|
+
return value.toString();
|
|
2006
|
+
}
|
|
2007
|
+
return formatArg(value, {
|
|
2008
|
+
depth: 0,
|
|
2009
|
+
colors: false
|
|
2010
|
+
});
|
|
2011
|
+
}
|
|
2012
|
+
return String(value);
|
|
2013
|
+
}
|
|
2014
|
+
case "%d": {
|
|
2015
|
+
const value = args[i2++];
|
|
2016
|
+
if (typeof value === "bigint") {
|
|
2017
|
+
return `${value.toString()}n`;
|
|
2018
|
+
}
|
|
2019
|
+
if (typeof value === "symbol") {
|
|
2020
|
+
return "NaN";
|
|
2021
|
+
}
|
|
2022
|
+
return Number(value).toString();
|
|
2023
|
+
}
|
|
2024
|
+
case "%i": {
|
|
2025
|
+
const value = args[i2++];
|
|
2026
|
+
if (typeof value === "bigint") {
|
|
2027
|
+
return `${value.toString()}n`;
|
|
2028
|
+
}
|
|
2029
|
+
return Number.parseInt(String(value)).toString();
|
|
2030
|
+
}
|
|
2031
|
+
case "%f":
|
|
2032
|
+
return Number.parseFloat(String(args[i2++])).toString();
|
|
2033
|
+
case "%o":
|
|
2034
|
+
return formatArg(args[i2++], {
|
|
2035
|
+
showHidden: true,
|
|
2036
|
+
showProxy: true
|
|
2037
|
+
});
|
|
2038
|
+
case "%O":
|
|
2039
|
+
return formatArg(args[i2++]);
|
|
2040
|
+
case "%c": {
|
|
2041
|
+
i2++;
|
|
2042
|
+
return "";
|
|
2043
|
+
}
|
|
2044
|
+
case "%j":
|
|
2045
|
+
try {
|
|
2046
|
+
return JSON.stringify(args[i2++]);
|
|
2047
|
+
} catch (err) {
|
|
2048
|
+
const m = err.message;
|
|
2049
|
+
if (m.includes("circular structure") || m.includes("cyclic structures") || m.includes("cyclic object")) {
|
|
2050
|
+
return "[Circular]";
|
|
2051
|
+
}
|
|
2052
|
+
throw err;
|
|
2053
|
+
}
|
|
2054
|
+
default:
|
|
2055
|
+
return x;
|
|
2056
|
+
}
|
|
2057
|
+
});
|
|
2058
|
+
for (let x = args[i2]; i2 < len; x = args[++i2]) {
|
|
2059
|
+
if (x === null || typeof x !== "object") {
|
|
2060
|
+
str += ` ${typeof x === "symbol" ? x.toString() : x}`;
|
|
2061
|
+
} else {
|
|
2062
|
+
str += ` ${formatArg(x)}`;
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2065
|
+
return str;
|
|
2066
|
+
}
|
|
2067
|
+
function format2(...args) {
|
|
2068
|
+
return baseFormat(args);
|
|
2069
|
+
}
|
|
2070
|
+
function inspect(obj, options = {}) {
|
|
2071
|
+
if (options.truncate === 0) {
|
|
2072
|
+
options.truncate = Number.POSITIVE_INFINITY;
|
|
2073
|
+
}
|
|
2074
|
+
return inspect$1(obj, options);
|
|
2075
|
+
}
|
|
2076
|
+
function objDisplay(obj, options = {}) {
|
|
2077
|
+
if (typeof options.truncate === "undefined") {
|
|
2078
|
+
options.truncate = 40;
|
|
2079
|
+
}
|
|
2080
|
+
const str = inspect(obj, options);
|
|
2081
|
+
const type = Object.prototype.toString.call(obj);
|
|
2082
|
+
if (options.truncate && str.length >= options.truncate) {
|
|
2083
|
+
if (type === "[object Function]") {
|
|
2084
|
+
const fn = obj;
|
|
2085
|
+
return !fn.name ? "[Function]" : `[Function: ${fn.name}]`;
|
|
2086
|
+
} else if (type === "[object Array]") {
|
|
2087
|
+
return `[ Array(${obj.length}) ]`;
|
|
2088
|
+
} else if (type === "[object Object]") {
|
|
2089
|
+
const keys = Object.keys(obj);
|
|
2090
|
+
const kstr = keys.length > 2 ? `${keys.splice(0, 2).join(", ")}, ...` : keys.join(", ");
|
|
2091
|
+
return `{ Object (${kstr}) }`;
|
|
2092
|
+
} else {
|
|
2093
|
+
return str;
|
|
2094
|
+
}
|
|
2095
|
+
}
|
|
2096
|
+
return str;
|
|
2097
|
+
}
|
|
2098
|
+
|
|
2099
|
+
// node_modules/@vitest/utils/dist/helpers.js
|
|
2100
|
+
function assertTypes(value, name, types) {
|
|
2101
|
+
const receivedType = typeof value;
|
|
2102
|
+
const pass = types.includes(receivedType);
|
|
2103
|
+
if (!pass) {
|
|
2104
|
+
throw new TypeError(`${name} value must be ${types.join(" or ")}, received "${receivedType}"`);
|
|
2105
|
+
}
|
|
2106
|
+
}
|
|
2107
|
+
function filterOutComments(s) {
|
|
2108
|
+
const result = [];
|
|
2109
|
+
let commentState = "none";
|
|
2110
|
+
for (let i2 = 0; i2 < s.length; ++i2) {
|
|
2111
|
+
if (commentState === "singleline") {
|
|
2112
|
+
if (s[i2] === "\n") {
|
|
2113
|
+
commentState = "none";
|
|
2114
|
+
}
|
|
2115
|
+
} else if (commentState === "multiline") {
|
|
2116
|
+
if (s[i2 - 1] === "*" && s[i2] === "/") {
|
|
2117
|
+
commentState = "none";
|
|
2118
|
+
}
|
|
2119
|
+
} else if (commentState === "none") {
|
|
2120
|
+
if (s[i2] === "/" && s[i2 + 1] === "/") {
|
|
2121
|
+
commentState = "singleline";
|
|
2122
|
+
} else if (s[i2] === "/" && s[i2 + 1] === "*") {
|
|
2123
|
+
commentState = "multiline";
|
|
2124
|
+
i2 += 2;
|
|
2125
|
+
} else {
|
|
2126
|
+
result.push(s[i2]);
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2130
|
+
return result.join("");
|
|
2131
|
+
}
|
|
2132
|
+
function toArray(array) {
|
|
2133
|
+
if (array === null || array === void 0) {
|
|
2134
|
+
array = [];
|
|
2135
|
+
}
|
|
2136
|
+
if (Array.isArray(array)) {
|
|
2137
|
+
return array;
|
|
2138
|
+
}
|
|
2139
|
+
return [array];
|
|
2140
|
+
}
|
|
2141
|
+
function isObject(item) {
|
|
2142
|
+
return item != null && typeof item === "object" && !Array.isArray(item);
|
|
2143
|
+
}
|
|
2144
|
+
function objectAttr(source, path, defaultValue = void 0) {
|
|
2145
|
+
const paths = path.replace(/\[(\d+)\]/g, ".$1").split(".");
|
|
2146
|
+
let result = source;
|
|
2147
|
+
for (const p of paths) {
|
|
2148
|
+
result = new Object(result)[p];
|
|
2149
|
+
if (result === void 0) {
|
|
2150
|
+
return defaultValue;
|
|
2151
|
+
}
|
|
2152
|
+
}
|
|
2153
|
+
return result;
|
|
2154
|
+
}
|
|
2155
|
+
function createDefer() {
|
|
2156
|
+
let resolve2 = null;
|
|
2157
|
+
let reject = null;
|
|
2158
|
+
const p = new Promise((_resolve, _reject) => {
|
|
2159
|
+
resolve2 = _resolve;
|
|
2160
|
+
reject = _reject;
|
|
2161
|
+
});
|
|
2162
|
+
p.resolve = resolve2;
|
|
2163
|
+
p.reject = reject;
|
|
2164
|
+
return p;
|
|
2165
|
+
}
|
|
2166
|
+
function isNegativeNaN(val) {
|
|
2167
|
+
if (!Number.isNaN(val)) {
|
|
2168
|
+
return false;
|
|
2169
|
+
}
|
|
2170
|
+
const f64 = new Float64Array(1);
|
|
2171
|
+
f64[0] = val;
|
|
2172
|
+
const u32 = new Uint32Array(f64.buffer);
|
|
2173
|
+
const isNegative = u32[1] >>> 31 === 1;
|
|
2174
|
+
return isNegative;
|
|
2175
|
+
}
|
|
2176
|
+
function ordinal(i2) {
|
|
2177
|
+
const j = i2 % 10;
|
|
2178
|
+
const k = i2 % 100;
|
|
2179
|
+
if (j === 1 && k !== 11) {
|
|
2180
|
+
return `${i2}st`;
|
|
2181
|
+
}
|
|
2182
|
+
if (j === 2 && k !== 12) {
|
|
2183
|
+
return `${i2}nd`;
|
|
2184
|
+
}
|
|
2185
|
+
if (j === 3 && k !== 13) {
|
|
2186
|
+
return `${i2}rd`;
|
|
2187
|
+
}
|
|
2188
|
+
return `${i2}th`;
|
|
2189
|
+
}
|
|
2190
|
+
function unique(array) {
|
|
2191
|
+
return Array.from(new Set(array));
|
|
2192
|
+
}
|
|
2193
|
+
|
|
2194
|
+
// node_modules/@vitest/utils/dist/timers.js
|
|
2195
|
+
var SAFE_TIMERS_SYMBOL = /* @__PURE__ */ Symbol("vitest:SAFE_TIMERS");
|
|
2196
|
+
function getSafeTimers() {
|
|
2197
|
+
const { setTimeout: safeSetTimeout, setInterval: safeSetInterval, clearInterval: safeClearInterval, clearTimeout: safeClearTimeout, setImmediate: safeSetImmediate, clearImmediate: safeClearImmediate, queueMicrotask: safeQueueMicrotask } = globalThis[SAFE_TIMERS_SYMBOL] || globalThis;
|
|
2198
|
+
const { nextTick: safeNextTick } = globalThis[SAFE_TIMERS_SYMBOL] || globalThis.process || {};
|
|
2199
|
+
return {
|
|
2200
|
+
nextTick: safeNextTick,
|
|
2201
|
+
setTimeout: safeSetTimeout,
|
|
2202
|
+
setInterval: safeSetInterval,
|
|
2203
|
+
clearInterval: safeClearInterval,
|
|
2204
|
+
clearTimeout: safeClearTimeout,
|
|
2205
|
+
setImmediate: safeSetImmediate,
|
|
2206
|
+
clearImmediate: safeClearImmediate,
|
|
2207
|
+
queueMicrotask: safeQueueMicrotask
|
|
2208
|
+
};
|
|
2209
|
+
}
|
|
2210
|
+
|
|
2211
|
+
// node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.js
|
|
2212
|
+
var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
2213
|
+
function normalizeWindowsPath(input = "") {
|
|
2214
|
+
if (!input) {
|
|
2215
|
+
return input;
|
|
2216
|
+
}
|
|
2217
|
+
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
2218
|
+
}
|
|
2219
|
+
var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
2220
|
+
function cwd() {
|
|
2221
|
+
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
|
2222
|
+
return process.cwd().replace(/\\/g, "/");
|
|
2223
|
+
}
|
|
2224
|
+
return "/";
|
|
2225
|
+
}
|
|
2226
|
+
var resolve = function(...arguments_) {
|
|
2227
|
+
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
2228
|
+
let resolvedPath = "";
|
|
2229
|
+
let resolvedAbsolute = false;
|
|
2230
|
+
for (let index2 = arguments_.length - 1; index2 >= -1 && !resolvedAbsolute; index2--) {
|
|
2231
|
+
const path = index2 >= 0 ? arguments_[index2] : cwd();
|
|
2232
|
+
if (!path || path.length === 0) {
|
|
2233
|
+
continue;
|
|
2234
|
+
}
|
|
2235
|
+
resolvedPath = `${path}/${resolvedPath}`;
|
|
2236
|
+
resolvedAbsolute = isAbsolute(path);
|
|
2237
|
+
}
|
|
2238
|
+
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
2239
|
+
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
|
|
2240
|
+
return `/${resolvedPath}`;
|
|
2241
|
+
}
|
|
2242
|
+
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
2243
|
+
};
|
|
2244
|
+
function normalizeString(path, allowAboveRoot) {
|
|
2245
|
+
let res = "";
|
|
2246
|
+
let lastSegmentLength = 0;
|
|
2247
|
+
let lastSlash = -1;
|
|
2248
|
+
let dots = 0;
|
|
2249
|
+
let char = null;
|
|
2250
|
+
for (let index2 = 0; index2 <= path.length; ++index2) {
|
|
2251
|
+
if (index2 < path.length) {
|
|
2252
|
+
char = path[index2];
|
|
2253
|
+
} else if (char === "/") {
|
|
2254
|
+
break;
|
|
2255
|
+
} else {
|
|
2256
|
+
char = "/";
|
|
2257
|
+
}
|
|
2258
|
+
if (char === "/") {
|
|
2259
|
+
if (lastSlash === index2 - 1 || dots === 1) ;
|
|
2260
|
+
else if (dots === 2) {
|
|
2261
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
2262
|
+
if (res.length > 2) {
|
|
2263
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
2264
|
+
if (lastSlashIndex === -1) {
|
|
2265
|
+
res = "";
|
|
2266
|
+
lastSegmentLength = 0;
|
|
2267
|
+
} else {
|
|
2268
|
+
res = res.slice(0, lastSlashIndex);
|
|
2269
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
2270
|
+
}
|
|
2271
|
+
lastSlash = index2;
|
|
2272
|
+
dots = 0;
|
|
2273
|
+
continue;
|
|
2274
|
+
} else if (res.length > 0) {
|
|
2275
|
+
res = "";
|
|
2276
|
+
lastSegmentLength = 0;
|
|
2277
|
+
lastSlash = index2;
|
|
2278
|
+
dots = 0;
|
|
2279
|
+
continue;
|
|
2280
|
+
}
|
|
2281
|
+
}
|
|
2282
|
+
if (allowAboveRoot) {
|
|
2283
|
+
res += res.length > 0 ? "/.." : "..";
|
|
2284
|
+
lastSegmentLength = 2;
|
|
2285
|
+
}
|
|
2286
|
+
} else {
|
|
2287
|
+
if (res.length > 0) {
|
|
2288
|
+
res += `/${path.slice(lastSlash + 1, index2)}`;
|
|
2289
|
+
} else {
|
|
2290
|
+
res = path.slice(lastSlash + 1, index2);
|
|
2291
|
+
}
|
|
2292
|
+
lastSegmentLength = index2 - lastSlash - 1;
|
|
2293
|
+
}
|
|
2294
|
+
lastSlash = index2;
|
|
2295
|
+
dots = 0;
|
|
2296
|
+
} else if (char === "." && dots !== -1) {
|
|
2297
|
+
++dots;
|
|
2298
|
+
} else {
|
|
2299
|
+
dots = -1;
|
|
2300
|
+
}
|
|
2301
|
+
}
|
|
2302
|
+
return res;
|
|
2303
|
+
}
|
|
2304
|
+
var isAbsolute = function(p) {
|
|
2305
|
+
return _IS_ABSOLUTE_RE.test(p);
|
|
2306
|
+
};
|
|
2307
|
+
|
|
2308
|
+
// node_modules/@vitest/utils/dist/source-map.js
|
|
2309
|
+
var comma = ",".charCodeAt(0);
|
|
2310
|
+
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
2311
|
+
var intToChar = new Uint8Array(64);
|
|
2312
|
+
var charToInt = new Uint8Array(128);
|
|
2313
|
+
for (let i2 = 0; i2 < chars.length; i2++) {
|
|
2314
|
+
const c = chars.charCodeAt(i2);
|
|
2315
|
+
intToChar[i2] = c;
|
|
2316
|
+
charToInt[c] = i2;
|
|
2317
|
+
}
|
|
2318
|
+
var CHROME_IE_STACK_REGEXP = /^\s*at .*(?:\S:\d+|\(native\))/m;
|
|
2319
|
+
var SAFARI_NATIVE_CODE_REGEXP = /^(?:eval@)?(?:\[native code\])?$/;
|
|
2320
|
+
var NOW_LENGTH = Date.now().toString().length;
|
|
2321
|
+
var REGEXP_VITEST = new RegExp(`vitest=\\d{${NOW_LENGTH}}`);
|
|
2322
|
+
function extractLocation(urlLike) {
|
|
2323
|
+
if (!urlLike.includes(":")) {
|
|
2324
|
+
return [urlLike];
|
|
2325
|
+
}
|
|
2326
|
+
const regExp = /(.+?)(?::(\d+))?(?::(\d+))?$/;
|
|
2327
|
+
const parts = regExp.exec(urlLike.replace(/^\(|\)$/g, ""));
|
|
2328
|
+
if (!parts) {
|
|
2329
|
+
return [urlLike];
|
|
2330
|
+
}
|
|
2331
|
+
let url = parts[1];
|
|
2332
|
+
if (url.startsWith("async ")) {
|
|
2333
|
+
url = url.slice(6);
|
|
2334
|
+
}
|
|
2335
|
+
if (url.startsWith("http:") || url.startsWith("https:")) {
|
|
2336
|
+
const urlObj = new URL(url);
|
|
2337
|
+
urlObj.searchParams.delete("import");
|
|
2338
|
+
urlObj.searchParams.delete("browserv");
|
|
2339
|
+
url = urlObj.pathname + urlObj.hash + urlObj.search;
|
|
2340
|
+
}
|
|
2341
|
+
if (url.startsWith("/@fs/")) {
|
|
2342
|
+
const isWindows2 = /^\/@fs\/[a-zA-Z]:\//.test(url);
|
|
2343
|
+
url = url.slice(isWindows2 ? 5 : 4);
|
|
2344
|
+
}
|
|
2345
|
+
if (url.includes("vitest=")) {
|
|
2346
|
+
url = url.replace(REGEXP_VITEST, "").replace(/[?&]$/, "");
|
|
2347
|
+
}
|
|
2348
|
+
return [
|
|
2349
|
+
url,
|
|
2350
|
+
parts[2] || void 0,
|
|
2351
|
+
parts[3] || void 0
|
|
2352
|
+
];
|
|
2353
|
+
}
|
|
2354
|
+
function parseSingleFFOrSafariStack(raw) {
|
|
2355
|
+
let line = raw.trim();
|
|
2356
|
+
if (SAFARI_NATIVE_CODE_REGEXP.test(line)) {
|
|
2357
|
+
return null;
|
|
2358
|
+
}
|
|
2359
|
+
if (line.includes(" > eval")) {
|
|
2360
|
+
line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ":$1");
|
|
2361
|
+
}
|
|
2362
|
+
if (!line.includes("@")) {
|
|
2363
|
+
return null;
|
|
2364
|
+
}
|
|
2365
|
+
let atIndex = -1;
|
|
2366
|
+
let locationPart = "";
|
|
2367
|
+
let functionName;
|
|
2368
|
+
for (let i2 = 0; i2 < line.length; i2++) {
|
|
2369
|
+
if (line[i2] === "@") {
|
|
2370
|
+
const candidateLocation = line.slice(i2 + 1);
|
|
2371
|
+
if (candidateLocation.includes(":") && candidateLocation.length >= 3) {
|
|
2372
|
+
atIndex = i2;
|
|
2373
|
+
locationPart = candidateLocation;
|
|
2374
|
+
functionName = i2 > 0 ? line.slice(0, i2) : void 0;
|
|
2375
|
+
break;
|
|
2376
|
+
}
|
|
2377
|
+
}
|
|
2378
|
+
}
|
|
2379
|
+
if (atIndex === -1 || !locationPart.includes(":") || locationPart.length < 3) {
|
|
2380
|
+
return null;
|
|
2381
|
+
}
|
|
2382
|
+
const [url, lineNumber, columnNumber] = extractLocation(locationPart);
|
|
2383
|
+
if (!url || !lineNumber || !columnNumber) {
|
|
2384
|
+
return null;
|
|
2385
|
+
}
|
|
2386
|
+
return {
|
|
2387
|
+
file: url,
|
|
2388
|
+
method: functionName || "",
|
|
2389
|
+
line: Number.parseInt(lineNumber),
|
|
2390
|
+
column: Number.parseInt(columnNumber)
|
|
2391
|
+
};
|
|
2392
|
+
}
|
|
2393
|
+
function parseSingleStack(raw) {
|
|
2394
|
+
const line = raw.trim();
|
|
2395
|
+
if (!CHROME_IE_STACK_REGEXP.test(line)) {
|
|
2396
|
+
return parseSingleFFOrSafariStack(line);
|
|
2397
|
+
}
|
|
2398
|
+
return parseSingleV8Stack(line);
|
|
2399
|
+
}
|
|
2400
|
+
function parseSingleV8Stack(raw) {
|
|
2401
|
+
let line = raw.trim();
|
|
2402
|
+
if (!CHROME_IE_STACK_REGEXP.test(line)) {
|
|
2403
|
+
return null;
|
|
2404
|
+
}
|
|
2405
|
+
if (line.includes("(eval ")) {
|
|
2406
|
+
line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, "");
|
|
2407
|
+
}
|
|
2408
|
+
let sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, "");
|
|
2409
|
+
const location = sanitizedLine.match(/ (\(.+\)$)/);
|
|
2410
|
+
sanitizedLine = location ? sanitizedLine.replace(location[0], "") : sanitizedLine;
|
|
2411
|
+
const [url, lineNumber, columnNumber] = extractLocation(location ? location[1] : sanitizedLine);
|
|
2412
|
+
let method = location && sanitizedLine || "";
|
|
2413
|
+
let file = url && ["eval", "<anonymous>"].includes(url) ? void 0 : url;
|
|
2414
|
+
if (!file || !lineNumber || !columnNumber) {
|
|
2415
|
+
return null;
|
|
2416
|
+
}
|
|
2417
|
+
if (method.startsWith("async ")) {
|
|
2418
|
+
method = method.slice(6);
|
|
2419
|
+
}
|
|
2420
|
+
if (file.startsWith("file://")) {
|
|
2421
|
+
file = file.slice(7);
|
|
2422
|
+
}
|
|
2423
|
+
file = file.startsWith("node:") || file.startsWith("internal:") ? file : resolve(file);
|
|
2424
|
+
if (method) {
|
|
2425
|
+
method = method.replace(/\(0\s?,\s?__vite_ssr_import_\d+__.(\w+)\)/g, "$1").replace(/__(vite_ssr_import|vi_import)_\d+__\./g, "").replace(/(Object\.)?__vite_ssr_export_default__\s?/g, "");
|
|
2426
|
+
}
|
|
2427
|
+
return {
|
|
2428
|
+
method,
|
|
2429
|
+
file,
|
|
2430
|
+
line: Number.parseInt(lineNumber),
|
|
2431
|
+
column: Number.parseInt(columnNumber)
|
|
2432
|
+
};
|
|
2433
|
+
}
|
|
2434
|
+
|
|
2435
|
+
// node_modules/@vitest/runner/dist/chunk-artifact.js
|
|
2436
|
+
var PendingError = class extends Error {
|
|
2437
|
+
code = "VITEST_PENDING";
|
|
2438
|
+
taskId;
|
|
2439
|
+
constructor(message, task, note) {
|
|
2440
|
+
super(message);
|
|
2441
|
+
this.message = message;
|
|
2442
|
+
this.note = note;
|
|
2443
|
+
this.taskId = task.id;
|
|
2444
|
+
}
|
|
2445
|
+
};
|
|
2446
|
+
var FixtureDependencyError = class extends Error {
|
|
2447
|
+
name = "FixtureDependencyError";
|
|
2448
|
+
};
|
|
2449
|
+
var FixtureAccessError = class extends Error {
|
|
2450
|
+
name = "FixtureAccessError";
|
|
2451
|
+
};
|
|
2452
|
+
var FixtureParseError = class extends Error {
|
|
2453
|
+
name = "FixtureParseError";
|
|
2454
|
+
};
|
|
2455
|
+
var fnMap = /* @__PURE__ */ new WeakMap();
|
|
2456
|
+
var testFixtureMap = /* @__PURE__ */ new WeakMap();
|
|
2457
|
+
var hooksMap = /* @__PURE__ */ new WeakMap();
|
|
2458
|
+
function setFn(key, fn) {
|
|
2459
|
+
fnMap.set(key, fn);
|
|
2460
|
+
}
|
|
2461
|
+
function setTestFixture(key, fixture) {
|
|
2462
|
+
testFixtureMap.set(key, fixture);
|
|
2463
|
+
}
|
|
2464
|
+
function getTestFixtures(key) {
|
|
2465
|
+
return testFixtureMap.get(key);
|
|
2466
|
+
}
|
|
2467
|
+
function setHooks(key, hooks) {
|
|
2468
|
+
hooksMap.set(key, hooks);
|
|
2469
|
+
}
|
|
2470
|
+
function getHooks(key) {
|
|
2471
|
+
return hooksMap.get(key);
|
|
2472
|
+
}
|
|
2473
|
+
var FIXTURE_STACK_TRACE_KEY = /* @__PURE__ */ Symbol.for("VITEST_FIXTURE_STACK_TRACE");
|
|
2474
|
+
var TestFixtures = class _TestFixtures {
|
|
2475
|
+
_suiteContexts;
|
|
2476
|
+
_overrides = /* @__PURE__ */ new WeakMap();
|
|
2477
|
+
_registrations;
|
|
2478
|
+
static _definitions = [];
|
|
2479
|
+
static _builtinFixtures = [
|
|
2480
|
+
"task",
|
|
2481
|
+
"signal",
|
|
2482
|
+
"onTestFailed",
|
|
2483
|
+
"onTestFinished",
|
|
2484
|
+
"skip",
|
|
2485
|
+
"annotate"
|
|
2486
|
+
];
|
|
2487
|
+
static _fixtureOptionKeys = [
|
|
2488
|
+
"auto",
|
|
2489
|
+
"injected",
|
|
2490
|
+
"scope"
|
|
2491
|
+
];
|
|
2492
|
+
static _fixtureScopes = [
|
|
2493
|
+
"test",
|
|
2494
|
+
"file",
|
|
2495
|
+
"worker"
|
|
2496
|
+
];
|
|
2497
|
+
static _workerContextSuite = { type: "worker" };
|
|
2498
|
+
static clearDefinitions() {
|
|
2499
|
+
_TestFixtures._definitions.length = 0;
|
|
2500
|
+
}
|
|
2501
|
+
static getWorkerContexts() {
|
|
2502
|
+
return _TestFixtures._definitions.map((f) => f.getWorkerContext());
|
|
2503
|
+
}
|
|
2504
|
+
static getFileContexts(file) {
|
|
2505
|
+
return _TestFixtures._definitions.map((f) => f.getFileContext(file));
|
|
2506
|
+
}
|
|
2507
|
+
static isFixtureOptions(obj) {
|
|
2508
|
+
return isObject(obj) && Object.keys(obj).some((key) => _TestFixtures._fixtureOptionKeys.includes(key));
|
|
2509
|
+
}
|
|
2510
|
+
constructor(registrations) {
|
|
2511
|
+
this._registrations = registrations ?? /* @__PURE__ */ new Map();
|
|
2512
|
+
this._suiteContexts = /* @__PURE__ */ new WeakMap();
|
|
2513
|
+
_TestFixtures._definitions.push(this);
|
|
2514
|
+
}
|
|
2515
|
+
extend(runner2, userFixtures) {
|
|
2516
|
+
const { suite: suite2 } = getCurrentSuite();
|
|
2517
|
+
const isTopLevel = !suite2 || suite2.file === suite2;
|
|
2518
|
+
const registrations = this.parseUserFixtures(runner2, userFixtures, isTopLevel);
|
|
2519
|
+
return new _TestFixtures(registrations);
|
|
2520
|
+
}
|
|
2521
|
+
get(suite2) {
|
|
2522
|
+
let currentSuite = suite2;
|
|
2523
|
+
while (currentSuite) {
|
|
2524
|
+
const overrides = this._overrides.get(currentSuite);
|
|
2525
|
+
if (overrides) {
|
|
2526
|
+
return overrides;
|
|
2527
|
+
}
|
|
2528
|
+
if (currentSuite === currentSuite.file) {
|
|
2529
|
+
break;
|
|
2530
|
+
}
|
|
2531
|
+
currentSuite = currentSuite.suite || currentSuite.file;
|
|
2532
|
+
}
|
|
2533
|
+
return this._registrations;
|
|
2534
|
+
}
|
|
2535
|
+
override(runner2, userFixtures) {
|
|
2536
|
+
const { suite: currentSuite, file } = getCurrentSuite();
|
|
2537
|
+
const suite2 = currentSuite || file;
|
|
2538
|
+
const isTopLevel = !currentSuite || currentSuite.file === currentSuite;
|
|
2539
|
+
const suiteRegistrations = new Map(this.get(suite2));
|
|
2540
|
+
const registrations = this.parseUserFixtures(runner2, userFixtures, isTopLevel, suiteRegistrations);
|
|
2541
|
+
if (isTopLevel) {
|
|
2542
|
+
this._registrations = registrations;
|
|
2543
|
+
} else {
|
|
2544
|
+
this._overrides.set(suite2, registrations);
|
|
2545
|
+
}
|
|
2546
|
+
}
|
|
2547
|
+
getFileContext(file) {
|
|
2548
|
+
if (!this._suiteContexts.has(file)) {
|
|
2549
|
+
this._suiteContexts.set(file, /* @__PURE__ */ Object.create(null));
|
|
2550
|
+
}
|
|
2551
|
+
return this._suiteContexts.get(file);
|
|
2552
|
+
}
|
|
2553
|
+
getWorkerContext() {
|
|
2554
|
+
if (!this._suiteContexts.has(_TestFixtures._workerContextSuite)) {
|
|
2555
|
+
this._suiteContexts.set(_TestFixtures._workerContextSuite, /* @__PURE__ */ Object.create(null));
|
|
2556
|
+
}
|
|
2557
|
+
return this._suiteContexts.get(_TestFixtures._workerContextSuite);
|
|
2558
|
+
}
|
|
2559
|
+
parseUserFixtures(runner2, userFixtures, supportNonTest, registrations = new Map(this._registrations)) {
|
|
2560
|
+
const errors = [];
|
|
2561
|
+
Object.entries(userFixtures).forEach(([name, fn]) => {
|
|
2562
|
+
let options;
|
|
2563
|
+
let value;
|
|
2564
|
+
let _options;
|
|
2565
|
+
if (Array.isArray(fn) && fn.length >= 2 && _TestFixtures.isFixtureOptions(fn[1])) {
|
|
2566
|
+
_options = fn[1];
|
|
2567
|
+
options = {
|
|
2568
|
+
auto: _options.auto ?? false,
|
|
2569
|
+
scope: _options.scope ?? "test",
|
|
2570
|
+
injected: _options.injected ?? false
|
|
2571
|
+
};
|
|
2572
|
+
value = options.injected ? runner2.injectValue?.(name) ?? fn[0] : fn[0];
|
|
2573
|
+
} else {
|
|
2574
|
+
value = fn;
|
|
2575
|
+
}
|
|
2576
|
+
const parent = registrations.get(name);
|
|
2577
|
+
if (parent && options) {
|
|
2578
|
+
if (parent.scope !== options.scope) {
|
|
2579
|
+
errors.push(new FixtureDependencyError(`The "${name}" fixture was already registered with a "${options.scope}" scope.`));
|
|
2580
|
+
}
|
|
2581
|
+
if (parent.auto !== options.auto) {
|
|
2582
|
+
errors.push(new FixtureDependencyError(`The "${name}" fixture was already registered as { auto: ${options.auto} }.`));
|
|
2583
|
+
}
|
|
2584
|
+
} else if (parent) {
|
|
2585
|
+
options = {
|
|
2586
|
+
auto: parent.auto,
|
|
2587
|
+
scope: parent.scope,
|
|
2588
|
+
injected: parent.injected
|
|
2589
|
+
};
|
|
2590
|
+
} else if (!options) {
|
|
2591
|
+
options = {
|
|
2592
|
+
auto: false,
|
|
2593
|
+
injected: false,
|
|
2594
|
+
scope: "test"
|
|
2595
|
+
};
|
|
2596
|
+
}
|
|
2597
|
+
if (options.scope && !_TestFixtures._fixtureScopes.includes(options.scope)) {
|
|
2598
|
+
errors.push(new FixtureDependencyError(`The "${name}" fixture has unknown scope "${options.scope}".`));
|
|
2599
|
+
}
|
|
2600
|
+
if (!supportNonTest && options.scope !== "test") {
|
|
2601
|
+
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.`));
|
|
2602
|
+
}
|
|
2603
|
+
const deps = isFixtureFunction(value) ? getUsedProps(value) : /* @__PURE__ */ new Set();
|
|
2604
|
+
const item = {
|
|
2605
|
+
name,
|
|
2606
|
+
value,
|
|
2607
|
+
auto: options.auto ?? false,
|
|
2608
|
+
injected: options.injected ?? false,
|
|
2609
|
+
scope: options.scope ?? "test",
|
|
2610
|
+
deps,
|
|
2611
|
+
parent
|
|
2612
|
+
};
|
|
2613
|
+
if (isFixtureFunction(value)) {
|
|
2614
|
+
Object.assign(value, { [FIXTURE_STACK_TRACE_KEY]: new Error("STACK_TRACE_ERROR") });
|
|
2615
|
+
}
|
|
2616
|
+
registrations.set(name, item);
|
|
2617
|
+
if (item.scope === "worker" && (runner2.pool === "vmThreads" || runner2.pool === "vmForks")) {
|
|
2618
|
+
item.scope = "file";
|
|
2619
|
+
}
|
|
2620
|
+
});
|
|
2621
|
+
for (const fixture of registrations.values()) {
|
|
2622
|
+
for (const depName of fixture.deps) {
|
|
2623
|
+
if (_TestFixtures._builtinFixtures.includes(depName)) {
|
|
2624
|
+
continue;
|
|
2625
|
+
}
|
|
2626
|
+
const dep = registrations.get(depName);
|
|
2627
|
+
if (!dep) {
|
|
2628
|
+
errors.push(new FixtureDependencyError(`The "${fixture.name}" fixture depends on unknown fixture "${depName}".`));
|
|
2629
|
+
continue;
|
|
2630
|
+
}
|
|
2631
|
+
if (depName === fixture.name && !fixture.parent) {
|
|
2632
|
+
errors.push(new FixtureDependencyError(`The "${fixture.name}" fixture depends on itself, but does not have a base implementation.`));
|
|
2633
|
+
continue;
|
|
2634
|
+
}
|
|
2635
|
+
if (_TestFixtures._fixtureScopes.indexOf(fixture.scope) > _TestFixtures._fixtureScopes.indexOf(dep.scope)) {
|
|
2636
|
+
errors.push(new FixtureDependencyError(`The ${fixture.scope} "${fixture.name}" fixture cannot depend on a ${dep.scope} fixture "${dep.name}".`));
|
|
2637
|
+
continue;
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2641
|
+
if (errors.length === 1) {
|
|
2642
|
+
throw errors[0];
|
|
2643
|
+
} else if (errors.length > 1) {
|
|
2644
|
+
throw new AggregateError(errors, "Cannot resolve user fixtures. See errors for more information.");
|
|
2645
|
+
}
|
|
2646
|
+
return registrations;
|
|
2647
|
+
}
|
|
2648
|
+
};
|
|
2649
|
+
var cleanupFnArrayMap = /* @__PURE__ */ new WeakMap();
|
|
2650
|
+
var contextHasFixturesCache = /* @__PURE__ */ new WeakMap();
|
|
2651
|
+
function withFixtures(fn, options) {
|
|
2652
|
+
const collector = getCurrentSuite();
|
|
2653
|
+
const suite2 = options?.suite || collector.suite || collector.file;
|
|
2654
|
+
return async (hookContext) => {
|
|
2655
|
+
const context = hookContext || options?.context;
|
|
2656
|
+
if (!context) {
|
|
2657
|
+
if (options?.suiteHook) {
|
|
2658
|
+
validateSuiteHook(fn, options.suiteHook, options.stackTraceError);
|
|
2659
|
+
}
|
|
2660
|
+
return fn({});
|
|
2661
|
+
}
|
|
2662
|
+
const fixtures = options?.fixtures || getTestFixtures(context);
|
|
2663
|
+
if (!fixtures) {
|
|
2664
|
+
return fn(context);
|
|
2665
|
+
}
|
|
2666
|
+
const registrations = fixtures.get(suite2);
|
|
2667
|
+
if (!registrations.size) {
|
|
2668
|
+
return fn(context);
|
|
2669
|
+
}
|
|
2670
|
+
const usedFixtures = [];
|
|
2671
|
+
const usedProps = getUsedProps(fn);
|
|
2672
|
+
for (const fixture of registrations.values()) {
|
|
2673
|
+
if (isAutoFixture(fixture, options) || usedProps.has(fixture.name)) {
|
|
2674
|
+
usedFixtures.push(fixture);
|
|
2675
|
+
}
|
|
2676
|
+
}
|
|
2677
|
+
if (!usedFixtures.length) {
|
|
2678
|
+
return fn(context);
|
|
2679
|
+
}
|
|
2680
|
+
if (!cleanupFnArrayMap.has(context)) {
|
|
2681
|
+
cleanupFnArrayMap.set(context, []);
|
|
2682
|
+
}
|
|
2683
|
+
const cleanupFnArray = cleanupFnArrayMap.get(context);
|
|
2684
|
+
const pendingFixtures = resolveDeps(usedFixtures, registrations);
|
|
2685
|
+
if (!pendingFixtures.length) {
|
|
2686
|
+
return fn(context);
|
|
2687
|
+
}
|
|
2688
|
+
if (options?.suiteHook) {
|
|
2689
|
+
const testScopedFixtures = pendingFixtures.filter((f) => f.scope === "test");
|
|
2690
|
+
if (testScopedFixtures.length > 0) {
|
|
2691
|
+
const fixtureNames = testScopedFixtures.map((f) => `"${f.name}"`).join(", ");
|
|
2692
|
+
const alternativeHook = {
|
|
2693
|
+
aroundAll: "aroundEach",
|
|
2694
|
+
beforeAll: "beforeEach",
|
|
2695
|
+
afterAll: "afterEach"
|
|
2696
|
+
};
|
|
2697
|
+
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.`);
|
|
2698
|
+
if (options.stackTraceError?.stack) {
|
|
2699
|
+
error.stack = error.message + options.stackTraceError.stack.replace(options.stackTraceError.message, "");
|
|
2700
|
+
}
|
|
2701
|
+
throw error;
|
|
2702
|
+
}
|
|
2703
|
+
}
|
|
2704
|
+
if (!contextHasFixturesCache.has(context)) {
|
|
2705
|
+
contextHasFixturesCache.set(context, /* @__PURE__ */ new WeakSet());
|
|
2706
|
+
}
|
|
2707
|
+
const cachedFixtures = contextHasFixturesCache.get(context);
|
|
2708
|
+
for (const fixture of pendingFixtures) {
|
|
2709
|
+
if (fixture.scope === "test") {
|
|
2710
|
+
if (cachedFixtures.has(fixture)) {
|
|
2711
|
+
continue;
|
|
2712
|
+
}
|
|
2713
|
+
cachedFixtures.add(fixture);
|
|
2714
|
+
const resolvedValue = await resolveTestFixtureValue(fixture, context, cleanupFnArray);
|
|
2715
|
+
context[fixture.name] = resolvedValue;
|
|
2716
|
+
cleanupFnArray.push(() => {
|
|
2717
|
+
cachedFixtures.delete(fixture);
|
|
2718
|
+
});
|
|
2719
|
+
} else {
|
|
2720
|
+
const resolvedValue = await resolveScopeFixtureValue(fixtures, suite2, fixture);
|
|
2721
|
+
context[fixture.name] = resolvedValue;
|
|
2722
|
+
}
|
|
2723
|
+
}
|
|
2724
|
+
return fn(context);
|
|
2725
|
+
};
|
|
2726
|
+
}
|
|
2727
|
+
function isAutoFixture(fixture, options) {
|
|
2728
|
+
if (!fixture.auto) {
|
|
2729
|
+
return false;
|
|
2730
|
+
}
|
|
2731
|
+
if (options?.suiteHook && fixture.scope === "test") {
|
|
2732
|
+
return false;
|
|
2733
|
+
}
|
|
2734
|
+
return true;
|
|
2735
|
+
}
|
|
2736
|
+
function isFixtureFunction(value) {
|
|
2737
|
+
return typeof value === "function";
|
|
2738
|
+
}
|
|
2739
|
+
function resolveTestFixtureValue(fixture, context, cleanupFnArray) {
|
|
2740
|
+
if (!isFixtureFunction(fixture.value)) {
|
|
2741
|
+
return fixture.value;
|
|
2742
|
+
}
|
|
2743
|
+
return resolveFixtureFunction(fixture.value, fixture.name, context, cleanupFnArray);
|
|
2744
|
+
}
|
|
2745
|
+
var scopedFixturePromiseCache = /* @__PURE__ */ new WeakMap();
|
|
2746
|
+
async function resolveScopeFixtureValue(fixtures, suite2, fixture) {
|
|
2747
|
+
const workerContext = fixtures.getWorkerContext();
|
|
2748
|
+
const fileContext = fixtures.getFileContext(suite2.file);
|
|
2749
|
+
const fixtureContext = fixture.scope === "worker" ? workerContext : fileContext;
|
|
2750
|
+
if (!isFixtureFunction(fixture.value)) {
|
|
2751
|
+
fixtureContext[fixture.name] = fixture.value;
|
|
2752
|
+
return fixture.value;
|
|
2753
|
+
}
|
|
2754
|
+
if (fixture.name in fixtureContext) {
|
|
2755
|
+
return fixtureContext[fixture.name];
|
|
2756
|
+
}
|
|
2757
|
+
if (scopedFixturePromiseCache.has(fixture)) {
|
|
2758
|
+
return scopedFixturePromiseCache.get(fixture);
|
|
2759
|
+
}
|
|
2760
|
+
if (!cleanupFnArrayMap.has(fixtureContext)) {
|
|
2761
|
+
cleanupFnArrayMap.set(fixtureContext, []);
|
|
2762
|
+
}
|
|
2763
|
+
const cleanupFnFileArray = cleanupFnArrayMap.get(fixtureContext);
|
|
2764
|
+
const promise = resolveFixtureFunction(fixture.value, fixture.name, fixture.scope === "file" ? {
|
|
2765
|
+
...workerContext,
|
|
2766
|
+
...fileContext
|
|
2767
|
+
} : fixtureContext, cleanupFnFileArray).then((value) => {
|
|
2768
|
+
fixtureContext[fixture.name] = value;
|
|
2769
|
+
scopedFixturePromiseCache.delete(fixture);
|
|
2770
|
+
return value;
|
|
2771
|
+
});
|
|
2772
|
+
scopedFixturePromiseCache.set(fixture, promise);
|
|
2773
|
+
return promise;
|
|
2774
|
+
}
|
|
2775
|
+
async function resolveFixtureFunction(fixtureFn, fixtureName, context, cleanupFnArray) {
|
|
2776
|
+
const useFnArgPromise = createDefer();
|
|
2777
|
+
const stackTraceError = FIXTURE_STACK_TRACE_KEY in fixtureFn && fixtureFn[FIXTURE_STACK_TRACE_KEY] instanceof Error ? fixtureFn[FIXTURE_STACK_TRACE_KEY] : void 0;
|
|
2778
|
+
let isUseFnArgResolved = false;
|
|
2779
|
+
const fixtureReturn = fixtureFn(context, async (useFnArg) => {
|
|
2780
|
+
isUseFnArgResolved = true;
|
|
2781
|
+
useFnArgPromise.resolve(useFnArg);
|
|
2782
|
+
const useReturnPromise = createDefer();
|
|
2783
|
+
cleanupFnArray.push(async () => {
|
|
2784
|
+
useReturnPromise.resolve();
|
|
2785
|
+
await fixtureReturn;
|
|
2786
|
+
});
|
|
2787
|
+
await useReturnPromise;
|
|
2788
|
+
}).then(() => {
|
|
2789
|
+
if (!isUseFnArgResolved) {
|
|
2790
|
+
const error = new Error(`Fixture "${fixtureName}" returned without calling "use". Make sure to call "use" in every code path of the fixture function.`);
|
|
2791
|
+
if (stackTraceError?.stack) {
|
|
2792
|
+
error.stack = error.message + stackTraceError.stack.replace(stackTraceError.message, "");
|
|
2793
|
+
}
|
|
2794
|
+
useFnArgPromise.reject(error);
|
|
2795
|
+
}
|
|
2796
|
+
}).catch((e) => {
|
|
2797
|
+
if (!isUseFnArgResolved) {
|
|
2798
|
+
useFnArgPromise.reject(e);
|
|
2799
|
+
return;
|
|
2800
|
+
}
|
|
2801
|
+
throw e;
|
|
2802
|
+
});
|
|
2803
|
+
return useFnArgPromise;
|
|
2804
|
+
}
|
|
2805
|
+
function resolveDeps(usedFixtures, registrations, depSet = /* @__PURE__ */ new Set(), pendingFixtures = []) {
|
|
2806
|
+
usedFixtures.forEach((fixture) => {
|
|
2807
|
+
if (pendingFixtures.includes(fixture)) {
|
|
2808
|
+
return;
|
|
2809
|
+
}
|
|
2810
|
+
if (!isFixtureFunction(fixture.value) || !fixture.deps) {
|
|
2811
|
+
pendingFixtures.push(fixture);
|
|
2812
|
+
return;
|
|
2813
|
+
}
|
|
2814
|
+
if (depSet.has(fixture)) {
|
|
2815
|
+
if (fixture.parent) {
|
|
2816
|
+
fixture = fixture.parent;
|
|
2817
|
+
} else {
|
|
2818
|
+
throw new Error(`Circular fixture dependency detected: ${fixture.name} <- ${[...depSet].reverse().map((d2) => d2.name).join(" <- ")}`);
|
|
2819
|
+
}
|
|
2820
|
+
}
|
|
2821
|
+
depSet.add(fixture);
|
|
2822
|
+
resolveDeps([...fixture.deps].map((n) => n === fixture.name ? fixture.parent : registrations.get(n)).filter((n) => !!n), registrations, depSet, pendingFixtures);
|
|
2823
|
+
pendingFixtures.push(fixture);
|
|
2824
|
+
depSet.clear();
|
|
2825
|
+
});
|
|
2826
|
+
return pendingFixtures;
|
|
2827
|
+
}
|
|
2828
|
+
function validateSuiteHook(fn, hook, suiteError) {
|
|
2829
|
+
const usedProps = getUsedProps(fn, {
|
|
2830
|
+
sourceError: suiteError,
|
|
2831
|
+
suiteHook: hook
|
|
2832
|
+
});
|
|
2833
|
+
if (usedProps.size) {
|
|
2834
|
+
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}()"?
|
|
2835
|
+
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`);
|
|
2836
|
+
if (suiteError) {
|
|
2837
|
+
error.stack = suiteError.stack?.replace(suiteError.message, error.message);
|
|
2838
|
+
}
|
|
2839
|
+
throw error;
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2842
|
+
var kPropsSymbol = /* @__PURE__ */ Symbol("$vitest:fixture-props");
|
|
2843
|
+
var kPropNamesSymbol = /* @__PURE__ */ Symbol("$vitest:fixture-prop-names");
|
|
2844
|
+
function configureProps(fn, options) {
|
|
2845
|
+
Object.defineProperty(fn, kPropsSymbol, {
|
|
2846
|
+
value: options,
|
|
2847
|
+
enumerable: false
|
|
2848
|
+
});
|
|
2849
|
+
}
|
|
2850
|
+
function memoProps(fn, props) {
|
|
2851
|
+
fn[kPropNamesSymbol] = props;
|
|
2852
|
+
return props;
|
|
2853
|
+
}
|
|
2854
|
+
function getUsedProps(fn, { sourceError, suiteHook } = {}) {
|
|
2855
|
+
if (kPropNamesSymbol in fn) {
|
|
2856
|
+
return fn[kPropNamesSymbol];
|
|
2857
|
+
}
|
|
2858
|
+
const { index: fixturesIndex = 0, original: implementation = fn } = kPropsSymbol in fn ? fn[kPropsSymbol] : {};
|
|
2859
|
+
let fnString = filterOutComments(implementation.toString());
|
|
2860
|
+
if (/__async\((?:this|null), (?:null|arguments|\[[_0-9, ]*\]), function\*/.test(fnString)) {
|
|
2861
|
+
fnString = fnString.split(/__async\((?:this|null),/)[1];
|
|
2862
|
+
}
|
|
2863
|
+
const match = fnString.match(/[^(]*\(([^)]*)/);
|
|
2864
|
+
if (!match) {
|
|
2865
|
+
return memoProps(fn, /* @__PURE__ */ new Set());
|
|
2866
|
+
}
|
|
2867
|
+
const args = splitByComma(match[1]);
|
|
2868
|
+
if (!args.length) {
|
|
2869
|
+
return memoProps(fn, /* @__PURE__ */ new Set());
|
|
2870
|
+
}
|
|
2871
|
+
const fixturesArgument = args[fixturesIndex];
|
|
2872
|
+
if (!fixturesArgument) {
|
|
2873
|
+
return memoProps(fn, /* @__PURE__ */ new Set());
|
|
2874
|
+
}
|
|
2875
|
+
if (!(fixturesArgument[0] === "{" && fixturesArgument.endsWith("}"))) {
|
|
2876
|
+
const ordinalArgument = ordinal(fixturesIndex + 1);
|
|
2877
|
+
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.` : ""}`);
|
|
2878
|
+
if (sourceError) {
|
|
2879
|
+
error.stack = sourceError.stack?.replace(sourceError.message, error.message);
|
|
2880
|
+
}
|
|
2881
|
+
throw error;
|
|
2882
|
+
}
|
|
2883
|
+
const _first = fixturesArgument.slice(1, -1).replace(/\s/g, "");
|
|
2884
|
+
const props = splitByComma(_first).map((prop) => {
|
|
2885
|
+
return prop.replace(/:.*|=.*/g, "");
|
|
2886
|
+
});
|
|
2887
|
+
const last = props.at(-1);
|
|
2888
|
+
if (last && last.startsWith("...")) {
|
|
2889
|
+
const error = new FixtureParseError(`Rest parameters are not supported in fixtures, received "${last}".`);
|
|
2890
|
+
if (sourceError) {
|
|
2891
|
+
error.stack = sourceError.stack?.replace(sourceError.message, error.message);
|
|
2892
|
+
}
|
|
2893
|
+
throw error;
|
|
2894
|
+
}
|
|
2895
|
+
return memoProps(fn, new Set(props));
|
|
2896
|
+
}
|
|
2897
|
+
function splitByComma(s) {
|
|
2898
|
+
const result = [];
|
|
2899
|
+
const stack = [];
|
|
2900
|
+
let start = 0;
|
|
2901
|
+
for (let i2 = 0; i2 < s.length; i2++) {
|
|
2902
|
+
if (s[i2] === "{" || s[i2] === "[") {
|
|
2903
|
+
stack.push(s[i2] === "{" ? "}" : "]");
|
|
2904
|
+
} else if (s[i2] === stack.at(-1)) {
|
|
2905
|
+
stack.pop();
|
|
2906
|
+
} else if (!stack.length && s[i2] === ",") {
|
|
2907
|
+
const token = s.substring(start, i2).trim();
|
|
2908
|
+
if (token) {
|
|
2909
|
+
result.push(token);
|
|
2910
|
+
}
|
|
2911
|
+
start = i2 + 1;
|
|
2912
|
+
}
|
|
2913
|
+
}
|
|
2914
|
+
const lastToken = s.substring(start).trim();
|
|
2915
|
+
if (lastToken) {
|
|
2916
|
+
result.push(lastToken);
|
|
2917
|
+
}
|
|
2918
|
+
return result;
|
|
2919
|
+
}
|
|
2920
|
+
var _test;
|
|
2921
|
+
function getCurrentTest() {
|
|
2922
|
+
return _test;
|
|
2923
|
+
}
|
|
2924
|
+
var kChainableContext = /* @__PURE__ */ Symbol("kChainableContext");
|
|
2925
|
+
function getChainableContext(chainable) {
|
|
2926
|
+
return chainable?.[kChainableContext];
|
|
2927
|
+
}
|
|
2928
|
+
function createChainable(keys, fn, context) {
|
|
2929
|
+
function create(context2) {
|
|
2930
|
+
const chain2 = function(...args) {
|
|
2931
|
+
return fn.apply(context2, args);
|
|
2932
|
+
};
|
|
2933
|
+
Object.assign(chain2, fn);
|
|
2934
|
+
Object.defineProperty(chain2, kChainableContext, {
|
|
2935
|
+
value: {
|
|
2936
|
+
withContext: () => chain2.bind(context2),
|
|
2937
|
+
getFixtures: () => context2.fixtures,
|
|
2938
|
+
setContext: (key, value) => {
|
|
2939
|
+
context2[key] = value;
|
|
2940
|
+
},
|
|
2941
|
+
mergeContext: (ctx) => {
|
|
2942
|
+
Object.assign(context2, ctx);
|
|
2943
|
+
}
|
|
2944
|
+
},
|
|
2945
|
+
enumerable: false
|
|
2946
|
+
});
|
|
2947
|
+
for (const key of keys) {
|
|
2948
|
+
Object.defineProperty(chain2, key, { get() {
|
|
2949
|
+
return create({
|
|
2950
|
+
...context2,
|
|
2951
|
+
[key]: true
|
|
2952
|
+
});
|
|
2953
|
+
} });
|
|
2954
|
+
}
|
|
2955
|
+
return chain2;
|
|
2956
|
+
}
|
|
2957
|
+
const chain = create(context ?? {});
|
|
2958
|
+
Object.defineProperty(chain, "fn", {
|
|
2959
|
+
value: fn,
|
|
2960
|
+
enumerable: false
|
|
2961
|
+
});
|
|
2962
|
+
return chain;
|
|
2963
|
+
}
|
|
2964
|
+
function getDefaultHookTimeout() {
|
|
2965
|
+
return getRunner().config.hookTimeout;
|
|
2966
|
+
}
|
|
2967
|
+
var CLEANUP_TIMEOUT_KEY = /* @__PURE__ */ Symbol.for("VITEST_CLEANUP_TIMEOUT");
|
|
2968
|
+
var CLEANUP_STACK_TRACE_KEY = /* @__PURE__ */ Symbol.for("VITEST_CLEANUP_STACK_TRACE");
|
|
2969
|
+
var AROUND_TIMEOUT_KEY = /* @__PURE__ */ Symbol.for("VITEST_AROUND_TIMEOUT");
|
|
2970
|
+
var AROUND_STACK_TRACE_KEY = /* @__PURE__ */ Symbol.for("VITEST_AROUND_STACK_TRACE");
|
|
2971
|
+
function beforeAll(fn, timeout = getDefaultHookTimeout()) {
|
|
2972
|
+
assertTypes(fn, '"beforeAll" callback', ["function"]);
|
|
2973
|
+
const stackTraceError = new Error("STACK_TRACE_ERROR");
|
|
2974
|
+
const context = getChainableContext(this);
|
|
2975
|
+
return getCurrentSuite().on("beforeAll", Object.assign(withTimeout(withSuiteFixtures("beforeAll", fn, context, stackTraceError), timeout, true, stackTraceError), {
|
|
2976
|
+
[CLEANUP_TIMEOUT_KEY]: timeout,
|
|
2977
|
+
[CLEANUP_STACK_TRACE_KEY]: stackTraceError
|
|
2978
|
+
}));
|
|
2979
|
+
}
|
|
2980
|
+
function afterAll(fn, timeout) {
|
|
2981
|
+
assertTypes(fn, '"afterAll" callback', ["function"]);
|
|
2982
|
+
const context = getChainableContext(this);
|
|
2983
|
+
const stackTraceError = new Error("STACK_TRACE_ERROR");
|
|
2984
|
+
return getCurrentSuite().on("afterAll", withTimeout(withSuiteFixtures("afterAll", fn, context, stackTraceError), timeout ?? getDefaultHookTimeout(), true, stackTraceError));
|
|
2985
|
+
}
|
|
2986
|
+
function beforeEach(fn, timeout = getDefaultHookTimeout()) {
|
|
2987
|
+
assertTypes(fn, '"beforeEach" callback', ["function"]);
|
|
2988
|
+
const stackTraceError = new Error("STACK_TRACE_ERROR");
|
|
2989
|
+
const wrapper = (context, suite2) => {
|
|
2990
|
+
const fixtureResolver = withFixtures(fn, { suite: suite2 });
|
|
2991
|
+
return fixtureResolver(context);
|
|
2992
|
+
};
|
|
2993
|
+
return getCurrentSuite().on("beforeEach", Object.assign(withTimeout(wrapper, timeout ?? getDefaultHookTimeout(), true, stackTraceError, abortIfTimeout), {
|
|
2994
|
+
[CLEANUP_TIMEOUT_KEY]: timeout,
|
|
2995
|
+
[CLEANUP_STACK_TRACE_KEY]: stackTraceError
|
|
2996
|
+
}));
|
|
2997
|
+
}
|
|
2998
|
+
function afterEach(fn, timeout) {
|
|
2999
|
+
assertTypes(fn, '"afterEach" callback', ["function"]);
|
|
3000
|
+
const wrapper = (context, suite2) => {
|
|
3001
|
+
const fixtureResolver = withFixtures(fn, { suite: suite2 });
|
|
3002
|
+
return fixtureResolver(context);
|
|
3003
|
+
};
|
|
3004
|
+
return getCurrentSuite().on("afterEach", withTimeout(wrapper, timeout ?? getDefaultHookTimeout(), true, new Error("STACK_TRACE_ERROR"), abortIfTimeout));
|
|
3005
|
+
}
|
|
3006
|
+
var onTestFailed = createTestHook("onTestFailed", (test3, handler, timeout) => {
|
|
3007
|
+
test3.onFailed ||= [];
|
|
3008
|
+
test3.onFailed.push(withTimeout(handler, timeout ?? getDefaultHookTimeout(), true, new Error("STACK_TRACE_ERROR"), abortIfTimeout));
|
|
3009
|
+
});
|
|
3010
|
+
var onTestFinished = createTestHook("onTestFinished", (test3, handler, timeout) => {
|
|
3011
|
+
test3.onFinished ||= [];
|
|
3012
|
+
test3.onFinished.push(withTimeout(handler, timeout ?? getDefaultHookTimeout(), true, new Error("STACK_TRACE_ERROR"), abortIfTimeout));
|
|
3013
|
+
});
|
|
3014
|
+
function aroundAll(fn, timeout) {
|
|
3015
|
+
assertTypes(fn, '"aroundAll" callback', ["function"]);
|
|
3016
|
+
const stackTraceError = new Error("STACK_TRACE_ERROR");
|
|
3017
|
+
const resolvedTimeout = timeout ?? getDefaultHookTimeout();
|
|
3018
|
+
const context = getChainableContext(this);
|
|
3019
|
+
return getCurrentSuite().on("aroundAll", Object.assign(withSuiteFixtures("aroundAll", fn, context, stackTraceError, 1), {
|
|
3020
|
+
[AROUND_TIMEOUT_KEY]: resolvedTimeout,
|
|
3021
|
+
[AROUND_STACK_TRACE_KEY]: stackTraceError
|
|
3022
|
+
}));
|
|
3023
|
+
}
|
|
3024
|
+
function aroundEach(fn, timeout) {
|
|
3025
|
+
assertTypes(fn, '"aroundEach" callback', ["function"]);
|
|
3026
|
+
const stackTraceError = new Error("STACK_TRACE_ERROR");
|
|
3027
|
+
const resolvedTimeout = timeout ?? getDefaultHookTimeout();
|
|
3028
|
+
const wrapper = (runTest, context, suite2) => {
|
|
3029
|
+
const innerFn = (ctx) => fn(runTest, ctx, suite2);
|
|
3030
|
+
configureProps(innerFn, {
|
|
3031
|
+
index: 1,
|
|
3032
|
+
original: fn
|
|
3033
|
+
});
|
|
3034
|
+
const fixtureResolver = withFixtures(innerFn, { suite: suite2 });
|
|
3035
|
+
return fixtureResolver(context);
|
|
3036
|
+
};
|
|
3037
|
+
return getCurrentSuite().on("aroundEach", Object.assign(wrapper, {
|
|
3038
|
+
[AROUND_TIMEOUT_KEY]: resolvedTimeout,
|
|
3039
|
+
[AROUND_STACK_TRACE_KEY]: stackTraceError
|
|
3040
|
+
}));
|
|
3041
|
+
}
|
|
3042
|
+
function withSuiteFixtures(suiteHook, fn, context, stackTraceError, contextIndex = 0) {
|
|
3043
|
+
return (...args) => {
|
|
3044
|
+
const suite2 = args.at(-1);
|
|
3045
|
+
const prefix = args.slice(0, -1);
|
|
3046
|
+
const wrapper = (ctx) => fn(...prefix, ctx, suite2);
|
|
3047
|
+
configureProps(wrapper, {
|
|
3048
|
+
index: contextIndex,
|
|
3049
|
+
original: fn
|
|
3050
|
+
});
|
|
3051
|
+
const fixtures = context?.getFixtures();
|
|
3052
|
+
const fileContext = fixtures?.getFileContext(suite2.file);
|
|
3053
|
+
const fixtured = withFixtures(wrapper, {
|
|
3054
|
+
suiteHook,
|
|
3055
|
+
fixtures,
|
|
3056
|
+
context: fileContext,
|
|
3057
|
+
stackTraceError
|
|
3058
|
+
});
|
|
3059
|
+
return fixtured();
|
|
3060
|
+
};
|
|
3061
|
+
}
|
|
3062
|
+
function createTestHook(name, handler) {
|
|
3063
|
+
return (fn, timeout) => {
|
|
3064
|
+
assertTypes(fn, `"${name}" callback`, ["function"]);
|
|
3065
|
+
const current = getCurrentTest();
|
|
3066
|
+
if (!current) {
|
|
3067
|
+
throw new Error(`Hook ${name}() can only be called inside a test`);
|
|
3068
|
+
}
|
|
3069
|
+
return handler(current, fn, timeout);
|
|
3070
|
+
};
|
|
3071
|
+
}
|
|
3072
|
+
function findTestFileStackTrace(testFilePath, error) {
|
|
3073
|
+
const lines = error.split("\n").slice(1);
|
|
3074
|
+
for (const line of lines) {
|
|
3075
|
+
const stack = parseSingleStack(line);
|
|
3076
|
+
if (stack && stack.file === testFilePath) {
|
|
3077
|
+
return stack;
|
|
3078
|
+
}
|
|
3079
|
+
}
|
|
3080
|
+
}
|
|
3081
|
+
function validateTags(config, tags) {
|
|
3082
|
+
if (!config.strictTags) {
|
|
3083
|
+
return;
|
|
3084
|
+
}
|
|
3085
|
+
const availableTags = new Set(config.tags.map((tag) => tag.name));
|
|
3086
|
+
for (const tag of tags) {
|
|
3087
|
+
if (!availableTags.has(tag)) {
|
|
3088
|
+
throw createNoTagsError(config.tags, tag);
|
|
3089
|
+
}
|
|
3090
|
+
}
|
|
3091
|
+
}
|
|
3092
|
+
function createNoTagsError(availableTags, tag, prefix = "tag") {
|
|
3093
|
+
if (!availableTags.length) {
|
|
3094
|
+
throw new Error(`The Vitest config does't define any "tags", cannot apply "${tag}" ${prefix} for this test. See: https://vitest.dev/guide/test-tags`);
|
|
3095
|
+
}
|
|
3096
|
+
throw new Error(`The ${prefix} "${tag}" is not defined in the configuration. Available tags are:
|
|
3097
|
+
${availableTags.map((t) => `- ${t.name}${t.description ? `: ${t.description}` : ""}`).join("\n")}`);
|
|
3098
|
+
}
|
|
3099
|
+
function createTaskName(names, separator = " > ") {
|
|
3100
|
+
return names.filter((name) => name !== void 0).join(separator);
|
|
3101
|
+
}
|
|
3102
|
+
var suite = createSuite();
|
|
3103
|
+
var test2 = createTest(function(name, optionsOrFn, optionsOrTest) {
|
|
3104
|
+
if (getCurrentTest()) {
|
|
3105
|
+
throw new Error('Calling the test function inside another test function is not allowed. Please put it inside "describe" or "suite" so it can be properly collected.');
|
|
3106
|
+
}
|
|
3107
|
+
getCurrentSuite().test.fn.call(this, formatName(name), optionsOrFn, optionsOrTest);
|
|
3108
|
+
});
|
|
3109
|
+
var runner;
|
|
3110
|
+
var defaultSuite;
|
|
3111
|
+
var currentTestFilepath;
|
|
3112
|
+
function assert(condition, message) {
|
|
3113
|
+
if (!condition) {
|
|
3114
|
+
throw new Error(`Vitest failed to find ${message}. One of the following is possible:
|
|
3115
|
+
- "vitest" is imported directly without running "vitest" command
|
|
3116
|
+
- "vitest" is imported inside "globalSetup" (to fix this, use "setupFiles" instead, because "globalSetup" runs in a different context)
|
|
3117
|
+
- "vitest" is imported inside Vite / Vitest config file
|
|
3118
|
+
- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues
|
|
3119
|
+
`);
|
|
3120
|
+
}
|
|
3121
|
+
}
|
|
3122
|
+
function getRunner() {
|
|
3123
|
+
assert(runner, "the runner");
|
|
3124
|
+
return runner;
|
|
3125
|
+
}
|
|
3126
|
+
function getCurrentSuite() {
|
|
3127
|
+
const currentSuite = collectorContext.currentSuite || defaultSuite;
|
|
3128
|
+
assert(currentSuite, "the current suite");
|
|
3129
|
+
return currentSuite;
|
|
3130
|
+
}
|
|
3131
|
+
function createSuiteHooks() {
|
|
3132
|
+
return {
|
|
3133
|
+
beforeAll: [],
|
|
3134
|
+
afterAll: [],
|
|
3135
|
+
beforeEach: [],
|
|
3136
|
+
afterEach: [],
|
|
3137
|
+
aroundEach: [],
|
|
3138
|
+
aroundAll: []
|
|
3139
|
+
};
|
|
3140
|
+
}
|
|
3141
|
+
var POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
|
|
3142
|
+
function parseArguments(optionsOrFn, timeoutOrTest) {
|
|
3143
|
+
if (timeoutOrTest != null && typeof timeoutOrTest === "object") {
|
|
3144
|
+
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.`);
|
|
3145
|
+
}
|
|
3146
|
+
let options = {};
|
|
3147
|
+
let fn;
|
|
3148
|
+
if (typeof timeoutOrTest === "number") {
|
|
3149
|
+
options = { timeout: timeoutOrTest };
|
|
3150
|
+
} else if (typeof optionsOrFn === "object") {
|
|
3151
|
+
options = optionsOrFn;
|
|
3152
|
+
}
|
|
3153
|
+
if (typeof optionsOrFn === "function") {
|
|
3154
|
+
if (typeof timeoutOrTest === "function") {
|
|
3155
|
+
throw new TypeError("Cannot use two functions as arguments. Please use the second argument for options.");
|
|
3156
|
+
}
|
|
3157
|
+
fn = optionsOrFn;
|
|
3158
|
+
} else if (typeof timeoutOrTest === "function") {
|
|
3159
|
+
fn = timeoutOrTest;
|
|
3160
|
+
}
|
|
3161
|
+
return {
|
|
3162
|
+
options,
|
|
3163
|
+
handler: fn
|
|
3164
|
+
};
|
|
3165
|
+
}
|
|
3166
|
+
function createSuiteCollector(name, factory = () => {
|
|
3167
|
+
}, mode, each, suiteOptions) {
|
|
3168
|
+
const tasks = [];
|
|
3169
|
+
let suite2;
|
|
3170
|
+
initSuite(true);
|
|
3171
|
+
const task = function(name2 = "", options = {}) {
|
|
3172
|
+
const currentSuite = collectorContext.currentSuite?.suite;
|
|
3173
|
+
const parentTask = currentSuite ?? collectorContext.currentSuite?.file;
|
|
3174
|
+
const parentTags = parentTask?.tags || [];
|
|
3175
|
+
const testTags = unique([...parentTags, ...toArray(options.tags)]);
|
|
3176
|
+
const tagsOptions = testTags.map((tag) => {
|
|
3177
|
+
const tagDefinition = runner.config.tags?.find((t) => t.name === tag);
|
|
3178
|
+
if (!tagDefinition && runner.config.strictTags) {
|
|
3179
|
+
throw createNoTagsError(runner.config.tags, tag);
|
|
3180
|
+
}
|
|
3181
|
+
return tagDefinition;
|
|
3182
|
+
}).filter((r) => r != null).sort((tag1, tag2) => (tag2.priority ?? POSITIVE_INFINITY) - (tag1.priority ?? POSITIVE_INFINITY)).reduce((acc, tag) => {
|
|
3183
|
+
const { name: name3, description, priority, meta, ...options2 } = tag;
|
|
3184
|
+
Object.assign(acc, options2);
|
|
3185
|
+
if (meta) {
|
|
3186
|
+
acc.meta = Object.assign(acc.meta ?? /* @__PURE__ */ Object.create(null), meta);
|
|
3187
|
+
}
|
|
3188
|
+
return acc;
|
|
3189
|
+
}, {});
|
|
3190
|
+
const testOwnMeta = options.meta;
|
|
3191
|
+
options = {
|
|
3192
|
+
...tagsOptions,
|
|
3193
|
+
...options
|
|
3194
|
+
};
|
|
3195
|
+
const timeout = options.timeout ?? runner.config.testTimeout;
|
|
3196
|
+
const parentMeta = currentSuite?.meta;
|
|
3197
|
+
const tagMeta = tagsOptions.meta;
|
|
3198
|
+
const testMeta = /* @__PURE__ */ Object.create(null);
|
|
3199
|
+
if (tagMeta) {
|
|
3200
|
+
Object.assign(testMeta, tagMeta);
|
|
3201
|
+
}
|
|
3202
|
+
if (parentMeta) {
|
|
3203
|
+
Object.assign(testMeta, parentMeta);
|
|
3204
|
+
}
|
|
3205
|
+
if (testOwnMeta) {
|
|
3206
|
+
Object.assign(testMeta, testOwnMeta);
|
|
3207
|
+
}
|
|
3208
|
+
const task2 = {
|
|
3209
|
+
id: "",
|
|
3210
|
+
name: name2,
|
|
3211
|
+
fullName: createTaskName([currentSuite?.fullName ?? collectorContext.currentSuite?.file?.fullName, name2]),
|
|
3212
|
+
fullTestName: createTaskName([currentSuite?.fullTestName, name2]),
|
|
3213
|
+
suite: currentSuite,
|
|
3214
|
+
each: options.each,
|
|
3215
|
+
fails: options.fails,
|
|
3216
|
+
context: void 0,
|
|
3217
|
+
type: "test",
|
|
3218
|
+
file: currentSuite?.file ?? collectorContext.currentSuite?.file,
|
|
3219
|
+
timeout,
|
|
3220
|
+
retry: options.retry ?? runner.config.retry,
|
|
3221
|
+
repeats: options.repeats,
|
|
3222
|
+
mode: options.only ? "only" : options.skip ? "skip" : options.todo ? "todo" : "run",
|
|
3223
|
+
meta: testMeta,
|
|
3224
|
+
annotations: [],
|
|
3225
|
+
artifacts: [],
|
|
3226
|
+
tags: testTags
|
|
3227
|
+
};
|
|
3228
|
+
const handler = options.handler;
|
|
3229
|
+
if (task2.mode === "run" && !handler) {
|
|
3230
|
+
task2.mode = "todo";
|
|
3231
|
+
}
|
|
3232
|
+
if (options.concurrent ?? (!options.sequential && runner.config.sequence.concurrent)) {
|
|
3233
|
+
task2.concurrent = true;
|
|
3234
|
+
}
|
|
3235
|
+
task2.shuffle = suiteOptions?.shuffle;
|
|
3236
|
+
const context = createTestContext(task2, runner);
|
|
3237
|
+
Object.defineProperty(task2, "context", {
|
|
3238
|
+
value: context,
|
|
3239
|
+
enumerable: false
|
|
3240
|
+
});
|
|
3241
|
+
setTestFixture(context, options.fixtures ?? new TestFixtures());
|
|
3242
|
+
const limit = Error.stackTraceLimit;
|
|
3243
|
+
Error.stackTraceLimit = 10;
|
|
3244
|
+
const stackTraceError = new Error("STACK_TRACE_ERROR");
|
|
3245
|
+
Error.stackTraceLimit = limit;
|
|
3246
|
+
if (handler) {
|
|
3247
|
+
setFn(task2, withTimeout(withCancel(withAwaitAsyncAssertions(withFixtures(handler, { context }), task2), task2.context.signal), timeout, false, stackTraceError, (_, error) => abortIfTimeout([context], error)));
|
|
3248
|
+
}
|
|
3249
|
+
if (runner.config.includeTaskLocation) {
|
|
3250
|
+
const error = stackTraceError.stack;
|
|
3251
|
+
const stack = findTestFileStackTrace(currentTestFilepath, error);
|
|
3252
|
+
if (stack) {
|
|
3253
|
+
task2.location = {
|
|
3254
|
+
line: stack.line,
|
|
3255
|
+
column: stack.column
|
|
3256
|
+
};
|
|
3257
|
+
}
|
|
3258
|
+
}
|
|
3259
|
+
tasks.push(task2);
|
|
3260
|
+
return task2;
|
|
3261
|
+
};
|
|
3262
|
+
const test3 = createTest(function(name2, optionsOrFn, timeoutOrTest) {
|
|
3263
|
+
let { options, handler } = parseArguments(optionsOrFn, timeoutOrTest);
|
|
3264
|
+
if (typeof suiteOptions === "object") {
|
|
3265
|
+
options = Object.assign({}, suiteOptions, options);
|
|
3266
|
+
}
|
|
3267
|
+
const concurrent = this.concurrent ?? (!this.sequential && options?.concurrent);
|
|
3268
|
+
if (options.concurrent != null && concurrent != null) {
|
|
3269
|
+
options.concurrent = concurrent;
|
|
3270
|
+
}
|
|
3271
|
+
const sequential = this.sequential ?? (!this.concurrent && options?.sequential);
|
|
3272
|
+
if (options.sequential != null && sequential != null) {
|
|
3273
|
+
options.sequential = sequential;
|
|
3274
|
+
}
|
|
3275
|
+
const test4 = task(formatName(name2), {
|
|
3276
|
+
...this,
|
|
3277
|
+
...options,
|
|
3278
|
+
handler
|
|
3279
|
+
});
|
|
3280
|
+
test4.type = "test";
|
|
3281
|
+
});
|
|
3282
|
+
const collector = {
|
|
3283
|
+
type: "collector",
|
|
3284
|
+
name,
|
|
3285
|
+
mode,
|
|
3286
|
+
suite: suite2,
|
|
3287
|
+
options: suiteOptions,
|
|
3288
|
+
test: test3,
|
|
3289
|
+
file: suite2.file,
|
|
3290
|
+
tasks,
|
|
3291
|
+
collect,
|
|
3292
|
+
task,
|
|
3293
|
+
clear,
|
|
3294
|
+
on: addHook
|
|
3295
|
+
};
|
|
3296
|
+
function addHook(name2, ...fn) {
|
|
3297
|
+
getHooks(suite2)[name2].push(...fn);
|
|
3298
|
+
}
|
|
3299
|
+
function initSuite(includeLocation) {
|
|
3300
|
+
if (typeof suiteOptions === "number") {
|
|
3301
|
+
suiteOptions = { timeout: suiteOptions };
|
|
3302
|
+
}
|
|
3303
|
+
const currentSuite = collectorContext.currentSuite?.suite;
|
|
3304
|
+
const parentTask = currentSuite ?? collectorContext.currentSuite?.file;
|
|
3305
|
+
const suiteTags = toArray(suiteOptions?.tags);
|
|
3306
|
+
validateTags(runner.config, suiteTags);
|
|
3307
|
+
suite2 = {
|
|
3308
|
+
id: "",
|
|
3309
|
+
type: "suite",
|
|
3310
|
+
name,
|
|
3311
|
+
fullName: createTaskName([currentSuite?.fullName ?? collectorContext.currentSuite?.file?.fullName, name]),
|
|
3312
|
+
fullTestName: createTaskName([currentSuite?.fullTestName, name]),
|
|
3313
|
+
suite: currentSuite,
|
|
3314
|
+
mode,
|
|
3315
|
+
each,
|
|
3316
|
+
file: currentSuite?.file ?? collectorContext.currentSuite?.file,
|
|
3317
|
+
shuffle: suiteOptions?.shuffle,
|
|
3318
|
+
tasks: [],
|
|
3319
|
+
meta: suiteOptions?.meta ?? /* @__PURE__ */ Object.create(null),
|
|
3320
|
+
concurrent: suiteOptions?.concurrent,
|
|
3321
|
+
tags: unique([...parentTask?.tags || [], ...suiteTags])
|
|
3322
|
+
};
|
|
3323
|
+
if (runner && includeLocation && runner.config.includeTaskLocation) {
|
|
3324
|
+
const limit = Error.stackTraceLimit;
|
|
3325
|
+
Error.stackTraceLimit = 15;
|
|
3326
|
+
const error = new Error("stacktrace").stack;
|
|
3327
|
+
Error.stackTraceLimit = limit;
|
|
3328
|
+
const stack = findTestFileStackTrace(currentTestFilepath, error);
|
|
3329
|
+
if (stack) {
|
|
3330
|
+
suite2.location = {
|
|
3331
|
+
line: stack.line,
|
|
3332
|
+
column: stack.column
|
|
3333
|
+
};
|
|
3334
|
+
}
|
|
3335
|
+
}
|
|
3336
|
+
setHooks(suite2, createSuiteHooks());
|
|
3337
|
+
}
|
|
3338
|
+
function clear() {
|
|
3339
|
+
tasks.length = 0;
|
|
3340
|
+
initSuite(false);
|
|
3341
|
+
}
|
|
3342
|
+
async function collect(file) {
|
|
3343
|
+
if (!file) {
|
|
3344
|
+
throw new TypeError("File is required to collect tasks.");
|
|
3345
|
+
}
|
|
3346
|
+
if (factory) {
|
|
3347
|
+
await runWithSuite(collector, () => factory(test3));
|
|
3348
|
+
}
|
|
3349
|
+
const allChildren = [];
|
|
3350
|
+
for (const i2 of tasks) {
|
|
3351
|
+
allChildren.push(i2.type === "collector" ? await i2.collect(file) : i2);
|
|
3352
|
+
}
|
|
3353
|
+
suite2.tasks = allChildren;
|
|
3354
|
+
return suite2;
|
|
3355
|
+
}
|
|
3356
|
+
collectTask(collector);
|
|
3357
|
+
return collector;
|
|
3358
|
+
}
|
|
3359
|
+
function withAwaitAsyncAssertions(fn, task) {
|
|
3360
|
+
return (async (...args) => {
|
|
3361
|
+
const fnResult = await fn(...args);
|
|
3362
|
+
if (task.promises) {
|
|
3363
|
+
const result = await Promise.allSettled(task.promises);
|
|
3364
|
+
const errors = result.map((r) => r.status === "rejected" ? r.reason : void 0).filter(Boolean);
|
|
3365
|
+
if (errors.length) {
|
|
3366
|
+
throw errors;
|
|
3367
|
+
}
|
|
3368
|
+
}
|
|
3369
|
+
return fnResult;
|
|
3370
|
+
});
|
|
3371
|
+
}
|
|
3372
|
+
function createSuite() {
|
|
3373
|
+
function suiteFn(name, factoryOrOptions, optionsOrFactory) {
|
|
3374
|
+
if (getCurrentTest()) {
|
|
3375
|
+
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.");
|
|
3376
|
+
}
|
|
3377
|
+
const currentSuite = collectorContext.currentSuite || defaultSuite;
|
|
3378
|
+
let { options, handler: factory } = parseArguments(factoryOrOptions, optionsOrFactory);
|
|
3379
|
+
const isConcurrentSpecified = options.concurrent || this.concurrent || options.sequential === false;
|
|
3380
|
+
const isSequentialSpecified = options.sequential || this.sequential || options.concurrent === false;
|
|
3381
|
+
const { meta: parentMeta, ...parentOptions } = currentSuite?.options || {};
|
|
3382
|
+
options = {
|
|
3383
|
+
...parentOptions,
|
|
3384
|
+
...options
|
|
3385
|
+
};
|
|
3386
|
+
const shuffle2 = this.shuffle ?? options.shuffle ?? currentSuite?.options?.shuffle ?? runner?.config.sequence.shuffle;
|
|
3387
|
+
if (shuffle2 != null) {
|
|
3388
|
+
options.shuffle = shuffle2;
|
|
3389
|
+
}
|
|
3390
|
+
let mode = this.only ?? options.only ? "only" : this.skip ?? options.skip ? "skip" : this.todo ?? options.todo ? "todo" : "run";
|
|
3391
|
+
if (mode === "run" && !factory) {
|
|
3392
|
+
mode = "todo";
|
|
3393
|
+
}
|
|
3394
|
+
const isConcurrent = isConcurrentSpecified || options.concurrent && !isSequentialSpecified;
|
|
3395
|
+
const isSequential = isSequentialSpecified || options.sequential && !isConcurrentSpecified;
|
|
3396
|
+
if (isConcurrent != null) {
|
|
3397
|
+
options.concurrent = isConcurrent && !isSequential;
|
|
3398
|
+
}
|
|
3399
|
+
if (isSequential != null) {
|
|
3400
|
+
options.sequential = isSequential && !isConcurrent;
|
|
3401
|
+
}
|
|
3402
|
+
if (parentMeta) {
|
|
3403
|
+
options.meta = Object.assign(/* @__PURE__ */ Object.create(null), parentMeta, options.meta);
|
|
3404
|
+
}
|
|
3405
|
+
return createSuiteCollector(formatName(name), factory, mode, this.each, options);
|
|
3406
|
+
}
|
|
3407
|
+
suiteFn.each = function(cases, ...args) {
|
|
3408
|
+
const context = getChainableContext(this);
|
|
3409
|
+
const suite2 = context.withContext();
|
|
3410
|
+
context.setContext("each", true);
|
|
3411
|
+
if (Array.isArray(cases) && args.length) {
|
|
3412
|
+
cases = formatTemplateString(cases, args);
|
|
3413
|
+
}
|
|
3414
|
+
return (name, optionsOrFn, fnOrOptions) => {
|
|
3415
|
+
const _name = formatName(name);
|
|
3416
|
+
const arrayOnlyCases = cases.every(Array.isArray);
|
|
3417
|
+
const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
|
|
3418
|
+
const fnFirst = typeof optionsOrFn === "function";
|
|
3419
|
+
cases.forEach((i2, idx) => {
|
|
3420
|
+
const items = Array.isArray(i2) ? i2 : [i2];
|
|
3421
|
+
if (fnFirst) {
|
|
3422
|
+
if (arrayOnlyCases) {
|
|
3423
|
+
suite2(formatTitle(_name, items, idx), handler ? () => handler(...items) : void 0, options.timeout);
|
|
3424
|
+
} else {
|
|
3425
|
+
suite2(formatTitle(_name, items, idx), handler ? () => handler(i2) : void 0, options.timeout);
|
|
3426
|
+
}
|
|
3427
|
+
} else {
|
|
3428
|
+
if (arrayOnlyCases) {
|
|
3429
|
+
suite2(formatTitle(_name, items, idx), options, handler ? () => handler(...items) : void 0);
|
|
3430
|
+
} else {
|
|
3431
|
+
suite2(formatTitle(_name, items, idx), options, handler ? () => handler(i2) : void 0);
|
|
3432
|
+
}
|
|
3433
|
+
}
|
|
3434
|
+
});
|
|
3435
|
+
context.setContext("each", void 0);
|
|
3436
|
+
};
|
|
3437
|
+
};
|
|
3438
|
+
suiteFn.for = function(cases, ...args) {
|
|
3439
|
+
if (Array.isArray(cases) && args.length) {
|
|
3440
|
+
cases = formatTemplateString(cases, args);
|
|
3441
|
+
}
|
|
3442
|
+
return (name, optionsOrFn, fnOrOptions) => {
|
|
3443
|
+
const name_ = formatName(name);
|
|
3444
|
+
const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
|
|
3445
|
+
cases.forEach((item, idx) => {
|
|
3446
|
+
suite(formatTitle(name_, toArray(item), idx), options, handler ? () => handler(item) : void 0);
|
|
3447
|
+
});
|
|
3448
|
+
};
|
|
3449
|
+
};
|
|
3450
|
+
suiteFn.skipIf = (condition) => condition ? suite.skip : suite;
|
|
3451
|
+
suiteFn.runIf = (condition) => condition ? suite : suite.skip;
|
|
3452
|
+
return createChainable([
|
|
3453
|
+
"concurrent",
|
|
3454
|
+
"sequential",
|
|
3455
|
+
"shuffle",
|
|
3456
|
+
"skip",
|
|
3457
|
+
"only",
|
|
3458
|
+
"todo"
|
|
3459
|
+
], suiteFn);
|
|
3460
|
+
}
|
|
3461
|
+
function createTaskCollector(fn) {
|
|
3462
|
+
const taskFn = fn;
|
|
3463
|
+
taskFn.each = function(cases, ...args) {
|
|
3464
|
+
const context = getChainableContext(this);
|
|
3465
|
+
const test3 = context.withContext();
|
|
3466
|
+
context.setContext("each", true);
|
|
3467
|
+
if (Array.isArray(cases) && args.length) {
|
|
3468
|
+
cases = formatTemplateString(cases, args);
|
|
3469
|
+
}
|
|
3470
|
+
return (name, optionsOrFn, fnOrOptions) => {
|
|
3471
|
+
const _name = formatName(name);
|
|
3472
|
+
const arrayOnlyCases = cases.every(Array.isArray);
|
|
3473
|
+
const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
|
|
3474
|
+
const fnFirst = typeof optionsOrFn === "function";
|
|
3475
|
+
cases.forEach((i2, idx) => {
|
|
3476
|
+
const items = Array.isArray(i2) ? i2 : [i2];
|
|
3477
|
+
if (fnFirst) {
|
|
3478
|
+
if (arrayOnlyCases) {
|
|
3479
|
+
test3(formatTitle(_name, items, idx), handler ? () => handler(...items) : void 0, options.timeout);
|
|
3480
|
+
} else {
|
|
3481
|
+
test3(formatTitle(_name, items, idx), handler ? () => handler(i2) : void 0, options.timeout);
|
|
3482
|
+
}
|
|
3483
|
+
} else {
|
|
3484
|
+
if (arrayOnlyCases) {
|
|
3485
|
+
test3(formatTitle(_name, items, idx), options, handler ? () => handler(...items) : void 0);
|
|
3486
|
+
} else {
|
|
3487
|
+
test3(formatTitle(_name, items, idx), options, handler ? () => handler(i2) : void 0);
|
|
3488
|
+
}
|
|
3489
|
+
}
|
|
3490
|
+
});
|
|
3491
|
+
context.setContext("each", void 0);
|
|
3492
|
+
};
|
|
3493
|
+
};
|
|
3494
|
+
taskFn.for = function(cases, ...args) {
|
|
3495
|
+
const context = getChainableContext(this);
|
|
3496
|
+
const test3 = context.withContext();
|
|
3497
|
+
if (Array.isArray(cases) && args.length) {
|
|
3498
|
+
cases = formatTemplateString(cases, args);
|
|
3499
|
+
}
|
|
3500
|
+
return (name, optionsOrFn, fnOrOptions) => {
|
|
3501
|
+
const _name = formatName(name);
|
|
3502
|
+
const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
|
|
3503
|
+
cases.forEach((item, idx) => {
|
|
3504
|
+
const handlerWrapper = handler ? (ctx) => handler(item, ctx) : void 0;
|
|
3505
|
+
if (handlerWrapper) {
|
|
3506
|
+
configureProps(handlerWrapper, {
|
|
3507
|
+
index: 1,
|
|
3508
|
+
original: handler
|
|
3509
|
+
});
|
|
3510
|
+
}
|
|
3511
|
+
test3(formatTitle(_name, toArray(item), idx), options, handlerWrapper);
|
|
3512
|
+
});
|
|
3513
|
+
};
|
|
3514
|
+
};
|
|
3515
|
+
taskFn.skipIf = function(condition) {
|
|
3516
|
+
return condition ? this.skip : this;
|
|
3517
|
+
};
|
|
3518
|
+
taskFn.runIf = function(condition) {
|
|
3519
|
+
return condition ? this : this.skip;
|
|
3520
|
+
};
|
|
3521
|
+
function parseBuilderFixtures(fixturesOrName, optionsOrFn, maybeFn) {
|
|
3522
|
+
if (typeof fixturesOrName !== "string") {
|
|
3523
|
+
return fixturesOrName;
|
|
3524
|
+
}
|
|
3525
|
+
const fixtureName = fixturesOrName;
|
|
3526
|
+
let fixtureOptions;
|
|
3527
|
+
let fixtureValue;
|
|
3528
|
+
if (maybeFn !== void 0) {
|
|
3529
|
+
fixtureOptions = optionsOrFn;
|
|
3530
|
+
fixtureValue = maybeFn;
|
|
3531
|
+
} else {
|
|
3532
|
+
if (optionsOrFn !== null && typeof optionsOrFn === "object" && !Array.isArray(optionsOrFn) && TestFixtures.isFixtureOptions(optionsOrFn)) {
|
|
3533
|
+
fixtureOptions = optionsOrFn;
|
|
3534
|
+
fixtureValue = {};
|
|
3535
|
+
} else {
|
|
3536
|
+
fixtureOptions = void 0;
|
|
3537
|
+
fixtureValue = optionsOrFn;
|
|
3538
|
+
}
|
|
3539
|
+
}
|
|
3540
|
+
if (typeof fixtureValue === "function") {
|
|
3541
|
+
const builderFn = fixtureValue;
|
|
3542
|
+
const fixture = async (ctx, use) => {
|
|
3543
|
+
let cleanup;
|
|
3544
|
+
const onCleanup = (fn2) => {
|
|
3545
|
+
if (cleanup !== void 0) {
|
|
3546
|
+
throw new Error(`onCleanup can only be called once per fixture. Define separate fixtures if you need multiple cleanup functions.`);
|
|
3547
|
+
}
|
|
3548
|
+
cleanup = fn2;
|
|
3549
|
+
};
|
|
3550
|
+
const value = await builderFn(ctx, { onCleanup });
|
|
3551
|
+
await use(value);
|
|
3552
|
+
if (cleanup) {
|
|
3553
|
+
await cleanup();
|
|
3554
|
+
}
|
|
3555
|
+
};
|
|
3556
|
+
configureProps(fixture, { original: builderFn });
|
|
3557
|
+
if (fixtureOptions) {
|
|
3558
|
+
return { [fixtureName]: [fixture, fixtureOptions] };
|
|
3559
|
+
}
|
|
3560
|
+
return { [fixtureName]: fixture };
|
|
3561
|
+
}
|
|
3562
|
+
if (fixtureOptions) {
|
|
3563
|
+
return { [fixtureName]: [fixtureValue, fixtureOptions] };
|
|
3564
|
+
}
|
|
3565
|
+
return { [fixtureName]: fixtureValue };
|
|
3566
|
+
}
|
|
3567
|
+
taskFn.override = function(fixturesOrName, optionsOrFn, maybeFn) {
|
|
3568
|
+
const userFixtures = parseBuilderFixtures(fixturesOrName, optionsOrFn, maybeFn);
|
|
3569
|
+
getChainableContext(this).getFixtures().override(runner, userFixtures);
|
|
3570
|
+
return this;
|
|
3571
|
+
};
|
|
3572
|
+
taskFn.scoped = function(fixtures) {
|
|
3573
|
+
console.warn(`test.scoped() is deprecated and will be removed in future versions. Please use test.override() instead.`);
|
|
3574
|
+
return this.override(fixtures);
|
|
3575
|
+
};
|
|
3576
|
+
taskFn.extend = function(fixturesOrName, optionsOrFn, maybeFn) {
|
|
3577
|
+
const userFixtures = parseBuilderFixtures(fixturesOrName, optionsOrFn, maybeFn);
|
|
3578
|
+
const fixtures = getChainableContext(this).getFixtures().extend(runner, userFixtures);
|
|
3579
|
+
const _test3 = createTest(function(name, optionsOrFn2, optionsOrTest) {
|
|
3580
|
+
fn.call(this, formatName(name), optionsOrFn2, optionsOrTest);
|
|
3581
|
+
});
|
|
3582
|
+
getChainableContext(_test3).mergeContext({ fixtures });
|
|
3583
|
+
return _test3;
|
|
3584
|
+
};
|
|
3585
|
+
taskFn.describe = suite;
|
|
3586
|
+
taskFn.suite = suite;
|
|
3587
|
+
taskFn.beforeEach = beforeEach;
|
|
3588
|
+
taskFn.afterEach = afterEach;
|
|
3589
|
+
taskFn.beforeAll = beforeAll;
|
|
3590
|
+
taskFn.afterAll = afterAll;
|
|
3591
|
+
taskFn.aroundEach = aroundEach;
|
|
3592
|
+
taskFn.aroundAll = aroundAll;
|
|
3593
|
+
const _test2 = createChainable([
|
|
3594
|
+
"concurrent",
|
|
3595
|
+
"sequential",
|
|
3596
|
+
"skip",
|
|
3597
|
+
"only",
|
|
3598
|
+
"todo",
|
|
3599
|
+
"fails"
|
|
3600
|
+
], taskFn, { fixtures: new TestFixtures() });
|
|
3601
|
+
return _test2;
|
|
3602
|
+
}
|
|
3603
|
+
function createTest(fn) {
|
|
3604
|
+
return createTaskCollector(fn);
|
|
3605
|
+
}
|
|
3606
|
+
function formatName(name) {
|
|
3607
|
+
return typeof name === "string" ? name : typeof name === "function" ? name.name || "<anonymous>" : String(name);
|
|
3608
|
+
}
|
|
3609
|
+
function formatTitle(template, items, idx) {
|
|
3610
|
+
if (template.includes("%#") || template.includes("%$")) {
|
|
3611
|
+
template = template.replace(/%%/g, "__vitest_escaped_%__").replace(/%#/g, `${idx}`).replace(/%\$/g, `${idx + 1}`).replace(/__vitest_escaped_%__/g, "%%");
|
|
3612
|
+
}
|
|
3613
|
+
const count = template.split("%").length - 1;
|
|
3614
|
+
if (template.includes("%f")) {
|
|
3615
|
+
const placeholders = template.match(/%f/g) || [];
|
|
3616
|
+
placeholders.forEach((_, i3) => {
|
|
3617
|
+
if (isNegativeNaN(items[i3]) || Object.is(items[i3], -0)) {
|
|
3618
|
+
let occurrence = 0;
|
|
3619
|
+
template = template.replace(/%f/g, (match) => {
|
|
3620
|
+
occurrence++;
|
|
3621
|
+
return occurrence === i3 + 1 ? "-%f" : match;
|
|
3622
|
+
});
|
|
3623
|
+
}
|
|
3624
|
+
});
|
|
3625
|
+
}
|
|
3626
|
+
const isObjectItem = isObject(items[0]);
|
|
3627
|
+
function formatAttribute(s) {
|
|
3628
|
+
return s.replace(/\$([$\w.]+)/g, (_, key) => {
|
|
3629
|
+
const isArrayKey = /^\d+$/.test(key);
|
|
3630
|
+
if (!isObjectItem && !isArrayKey) {
|
|
3631
|
+
return `$${key}`;
|
|
3632
|
+
}
|
|
3633
|
+
const arrayElement = isArrayKey ? objectAttr(items, key) : void 0;
|
|
3634
|
+
const value = isObjectItem ? objectAttr(items[0], key, arrayElement) : arrayElement;
|
|
3635
|
+
return objDisplay(value, { truncate: runner?.config?.chaiConfig?.truncateThreshold });
|
|
3636
|
+
});
|
|
3637
|
+
}
|
|
3638
|
+
let output = "";
|
|
3639
|
+
let i2 = 0;
|
|
3640
|
+
handleRegexMatch(
|
|
3641
|
+
template,
|
|
3642
|
+
formatRegExp,
|
|
3643
|
+
// format "%"
|
|
3644
|
+
(match) => {
|
|
3645
|
+
if (i2 < count) {
|
|
3646
|
+
output += format2(match[0], items[i2++]);
|
|
3647
|
+
} else {
|
|
3648
|
+
output += match[0];
|
|
3649
|
+
}
|
|
3650
|
+
},
|
|
3651
|
+
// format "$"
|
|
3652
|
+
(nonMatch) => {
|
|
3653
|
+
output += formatAttribute(nonMatch);
|
|
3654
|
+
}
|
|
3655
|
+
);
|
|
3656
|
+
return output;
|
|
3657
|
+
}
|
|
3658
|
+
function handleRegexMatch(input, regex, onMatch, onNonMatch) {
|
|
3659
|
+
let lastIndex = 0;
|
|
3660
|
+
for (const m of input.matchAll(regex)) {
|
|
3661
|
+
if (lastIndex < m.index) {
|
|
3662
|
+
onNonMatch(input.slice(lastIndex, m.index));
|
|
3663
|
+
}
|
|
3664
|
+
onMatch(m);
|
|
3665
|
+
lastIndex = m.index + m[0].length;
|
|
3666
|
+
}
|
|
3667
|
+
if (lastIndex < input.length) {
|
|
3668
|
+
onNonMatch(input.slice(lastIndex));
|
|
3669
|
+
}
|
|
3670
|
+
}
|
|
3671
|
+
function formatTemplateString(cases, args) {
|
|
3672
|
+
const header = cases.join("").trim().replace(/ /g, "").split("\n").map((i2) => i2.split("|"))[0];
|
|
3673
|
+
const res = [];
|
|
3674
|
+
for (let i2 = 0; i2 < Math.floor(args.length / header.length); i2++) {
|
|
3675
|
+
const oneCase = {};
|
|
3676
|
+
for (let j = 0; j < header.length; j++) {
|
|
3677
|
+
oneCase[header[j]] = args[i2 * header.length + j];
|
|
3678
|
+
}
|
|
3679
|
+
res.push(oneCase);
|
|
3680
|
+
}
|
|
3681
|
+
return res;
|
|
3682
|
+
}
|
|
3683
|
+
var now$2 = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
|
|
3684
|
+
var collectorContext = {
|
|
3685
|
+
tasks: [],
|
|
3686
|
+
currentSuite: null
|
|
3687
|
+
};
|
|
3688
|
+
function collectTask(task) {
|
|
3689
|
+
collectorContext.currentSuite?.tasks.push(task);
|
|
3690
|
+
}
|
|
3691
|
+
async function runWithSuite(suite2, fn) {
|
|
3692
|
+
const prev = collectorContext.currentSuite;
|
|
3693
|
+
collectorContext.currentSuite = suite2;
|
|
3694
|
+
await fn();
|
|
3695
|
+
collectorContext.currentSuite = prev;
|
|
3696
|
+
}
|
|
3697
|
+
function withTimeout(fn, timeout, isHook = false, stackTraceError, onTimeout) {
|
|
3698
|
+
if (timeout <= 0 || timeout === Number.POSITIVE_INFINITY) {
|
|
3699
|
+
return fn;
|
|
3700
|
+
}
|
|
3701
|
+
const { setTimeout: setTimeout3, clearTimeout: clearTimeout3 } = getSafeTimers();
|
|
3702
|
+
return (function runWithTimeout(...args) {
|
|
3703
|
+
const startTime = now$2();
|
|
3704
|
+
const runner2 = getRunner();
|
|
3705
|
+
runner2._currentTaskStartTime = startTime;
|
|
3706
|
+
runner2._currentTaskTimeout = timeout;
|
|
3707
|
+
return new Promise((resolve_, reject_) => {
|
|
3708
|
+
const timer = setTimeout3(() => {
|
|
3709
|
+
clearTimeout3(timer);
|
|
3710
|
+
rejectTimeoutError();
|
|
3711
|
+
}, timeout);
|
|
3712
|
+
timer.unref?.();
|
|
3713
|
+
function rejectTimeoutError() {
|
|
3714
|
+
const error = makeTimeoutError(isHook, timeout, stackTraceError);
|
|
3715
|
+
onTimeout?.(args, error);
|
|
3716
|
+
reject_(error);
|
|
3717
|
+
}
|
|
3718
|
+
function resolve2(result) {
|
|
3719
|
+
runner2._currentTaskStartTime = void 0;
|
|
3720
|
+
runner2._currentTaskTimeout = void 0;
|
|
3721
|
+
clearTimeout3(timer);
|
|
3722
|
+
if (now$2() - startTime >= timeout) {
|
|
3723
|
+
rejectTimeoutError();
|
|
3724
|
+
return;
|
|
3725
|
+
}
|
|
3726
|
+
resolve_(result);
|
|
3727
|
+
}
|
|
3728
|
+
function reject(error) {
|
|
3729
|
+
runner2._currentTaskStartTime = void 0;
|
|
3730
|
+
runner2._currentTaskTimeout = void 0;
|
|
3731
|
+
clearTimeout3(timer);
|
|
3732
|
+
reject_(error);
|
|
3733
|
+
}
|
|
3734
|
+
try {
|
|
3735
|
+
const result = fn(...args);
|
|
3736
|
+
if (typeof result === "object" && result != null && typeof result.then === "function") {
|
|
3737
|
+
result.then(resolve2, reject);
|
|
3738
|
+
} else {
|
|
3739
|
+
resolve2(result);
|
|
3740
|
+
}
|
|
3741
|
+
} catch (error) {
|
|
3742
|
+
reject(error);
|
|
3743
|
+
}
|
|
3744
|
+
});
|
|
3745
|
+
});
|
|
3746
|
+
}
|
|
3747
|
+
function withCancel(fn, signal) {
|
|
3748
|
+
return (function runWithCancel(...args) {
|
|
3749
|
+
return new Promise((resolve2, reject) => {
|
|
3750
|
+
signal.addEventListener("abort", () => reject(signal.reason));
|
|
3751
|
+
try {
|
|
3752
|
+
const result = fn(...args);
|
|
3753
|
+
if (typeof result === "object" && result != null && typeof result.then === "function") {
|
|
3754
|
+
result.then(resolve2, reject);
|
|
3755
|
+
} else {
|
|
3756
|
+
resolve2(result);
|
|
3757
|
+
}
|
|
3758
|
+
} catch (error) {
|
|
3759
|
+
reject(error);
|
|
3760
|
+
}
|
|
3761
|
+
});
|
|
3762
|
+
});
|
|
3763
|
+
}
|
|
3764
|
+
var abortControllers = /* @__PURE__ */ new WeakMap();
|
|
3765
|
+
function abortIfTimeout([context], error) {
|
|
3766
|
+
if (context) {
|
|
3767
|
+
abortContextSignal(context, error);
|
|
3768
|
+
}
|
|
3769
|
+
}
|
|
3770
|
+
function abortContextSignal(context, error) {
|
|
3771
|
+
const abortController = abortControllers.get(context);
|
|
3772
|
+
abortController?.abort(error);
|
|
3773
|
+
}
|
|
3774
|
+
function createTestContext(test3, runner2) {
|
|
3775
|
+
const context = function() {
|
|
3776
|
+
throw new Error("done() callback is deprecated, use promise instead");
|
|
3777
|
+
};
|
|
3778
|
+
let abortController = abortControllers.get(context);
|
|
3779
|
+
if (!abortController) {
|
|
3780
|
+
abortController = new AbortController();
|
|
3781
|
+
abortControllers.set(context, abortController);
|
|
3782
|
+
}
|
|
3783
|
+
context.signal = abortController.signal;
|
|
3784
|
+
context.task = test3;
|
|
3785
|
+
context.skip = (condition, note) => {
|
|
3786
|
+
if (condition === false) {
|
|
3787
|
+
return void 0;
|
|
3788
|
+
}
|
|
3789
|
+
test3.result ??= { state: "skip" };
|
|
3790
|
+
test3.result.pending = true;
|
|
3791
|
+
throw new PendingError("test is skipped; abort execution", test3, typeof condition === "string" ? condition : note);
|
|
3792
|
+
};
|
|
3793
|
+
context.annotate = ((message, type, attachment) => {
|
|
3794
|
+
if (test3.result && test3.result.state !== "run") {
|
|
3795
|
+
throw new Error(`Cannot annotate tests outside of the test run. The test "${test3.name}" finished running with the "${test3.result.state}" state already.`);
|
|
3796
|
+
}
|
|
3797
|
+
const annotation = {
|
|
3798
|
+
message,
|
|
3799
|
+
type: typeof type === "object" || type === void 0 ? "notice" : type
|
|
3800
|
+
};
|
|
3801
|
+
const annotationAttachment = typeof type === "object" ? type : attachment;
|
|
3802
|
+
if (annotationAttachment) {
|
|
3803
|
+
annotation.attachment = annotationAttachment;
|
|
3804
|
+
manageArtifactAttachment(annotation.attachment);
|
|
3805
|
+
}
|
|
3806
|
+
return recordAsyncOperation(test3, recordArtifact(test3, {
|
|
3807
|
+
type: "internal:annotation",
|
|
3808
|
+
annotation
|
|
3809
|
+
}).then(async ({ annotation: annotation2 }) => {
|
|
3810
|
+
if (!runner2.onTestAnnotate) {
|
|
3811
|
+
throw new Error(`Test runner doesn't support test annotations.`);
|
|
3812
|
+
}
|
|
3813
|
+
await finishSendTasksUpdate(runner2);
|
|
3814
|
+
const resolvedAnnotation = await runner2.onTestAnnotate(test3, annotation2);
|
|
3815
|
+
test3.annotations.push(resolvedAnnotation);
|
|
3816
|
+
return resolvedAnnotation;
|
|
3817
|
+
}));
|
|
3818
|
+
});
|
|
3819
|
+
context.onTestFailed = (handler, timeout) => {
|
|
3820
|
+
test3.onFailed ||= [];
|
|
3821
|
+
test3.onFailed.push(withTimeout(handler, timeout ?? runner2.config.hookTimeout, true, new Error("STACK_TRACE_ERROR"), (_, error) => abortController.abort(error)));
|
|
3822
|
+
};
|
|
3823
|
+
context.onTestFinished = (handler, timeout) => {
|
|
3824
|
+
test3.onFinished ||= [];
|
|
3825
|
+
test3.onFinished.push(withTimeout(handler, timeout ?? runner2.config.hookTimeout, true, new Error("STACK_TRACE_ERROR"), (_, error) => abortController.abort(error)));
|
|
3826
|
+
};
|
|
3827
|
+
return runner2.extendTaskContext?.(context) || context;
|
|
3828
|
+
}
|
|
3829
|
+
function makeTimeoutError(isHook, timeout, stackTraceError) {
|
|
3830
|
+
const message = `${isHook ? "Hook" : "Test"} timed out in ${timeout}ms.
|
|
3831
|
+
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"}".`;
|
|
3832
|
+
const error = new Error(message);
|
|
3833
|
+
if (stackTraceError?.stack) {
|
|
3834
|
+
error.stack = stackTraceError.stack.replace(error.message, stackTraceError.message);
|
|
3835
|
+
}
|
|
3836
|
+
return error;
|
|
3837
|
+
}
|
|
3838
|
+
var now$1 = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
|
|
3839
|
+
var now = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
|
|
3840
|
+
var unixNow = Date.now;
|
|
3841
|
+
var { clearTimeout: clearTimeout2, setTimeout: setTimeout2 } = getSafeTimers();
|
|
3842
|
+
var packs = /* @__PURE__ */ new Map();
|
|
3843
|
+
var eventsPacks = [];
|
|
3844
|
+
var pendingTasksUpdates = [];
|
|
3845
|
+
function sendTasksUpdate(runner2) {
|
|
3846
|
+
if (packs.size) {
|
|
3847
|
+
const taskPacks = Array.from(packs).map(([id, task]) => {
|
|
3848
|
+
return [
|
|
3849
|
+
id,
|
|
3850
|
+
task[0],
|
|
3851
|
+
task[1]
|
|
3852
|
+
];
|
|
3853
|
+
});
|
|
3854
|
+
const p = runner2.onTaskUpdate?.(taskPacks, eventsPacks);
|
|
3855
|
+
if (p) {
|
|
3856
|
+
pendingTasksUpdates.push(p);
|
|
3857
|
+
p.then(() => pendingTasksUpdates.splice(pendingTasksUpdates.indexOf(p), 1), () => {
|
|
3858
|
+
});
|
|
3859
|
+
}
|
|
3860
|
+
eventsPacks.length = 0;
|
|
3861
|
+
packs.clear();
|
|
3862
|
+
}
|
|
3863
|
+
}
|
|
3864
|
+
async function finishSendTasksUpdate(runner2) {
|
|
3865
|
+
sendTasksUpdate(runner2);
|
|
3866
|
+
await Promise.all(pendingTasksUpdates);
|
|
3867
|
+
}
|
|
3868
|
+
function throttle(fn, ms) {
|
|
3869
|
+
let last = 0;
|
|
3870
|
+
let pendingCall;
|
|
3871
|
+
return function call(...args) {
|
|
3872
|
+
const now2 = unixNow();
|
|
3873
|
+
if (now2 - last > ms) {
|
|
3874
|
+
last = now2;
|
|
3875
|
+
clearTimeout2(pendingCall);
|
|
3876
|
+
pendingCall = void 0;
|
|
3877
|
+
return fn.apply(this, args);
|
|
3878
|
+
}
|
|
3879
|
+
pendingCall ??= setTimeout2(() => call.bind(this)(...args), ms);
|
|
3880
|
+
};
|
|
3881
|
+
}
|
|
3882
|
+
var sendTasksUpdateThrottled = throttle(sendTasksUpdate, 100);
|
|
3883
|
+
async function recordArtifact(task, artifact) {
|
|
3884
|
+
const runner2 = getRunner();
|
|
3885
|
+
const stack = findTestFileStackTrace(task.file.filepath, new Error("STACK_TRACE").stack);
|
|
3886
|
+
if (stack) {
|
|
3887
|
+
artifact.location = {
|
|
3888
|
+
file: stack.file,
|
|
3889
|
+
line: stack.line,
|
|
3890
|
+
column: stack.column
|
|
3891
|
+
};
|
|
3892
|
+
if (artifact.type === "internal:annotation") {
|
|
3893
|
+
artifact.annotation.location = artifact.location;
|
|
3894
|
+
}
|
|
3895
|
+
}
|
|
3896
|
+
if (Array.isArray(artifact.attachments)) {
|
|
3897
|
+
for (const attachment of artifact.attachments) {
|
|
3898
|
+
manageArtifactAttachment(attachment);
|
|
3899
|
+
}
|
|
3900
|
+
}
|
|
3901
|
+
if (artifact.type === "internal:annotation") {
|
|
3902
|
+
return artifact;
|
|
3903
|
+
}
|
|
3904
|
+
if (!runner2.onTestArtifactRecord) {
|
|
3905
|
+
throw new Error(`Test runner doesn't support test artifacts.`);
|
|
3906
|
+
}
|
|
3907
|
+
await finishSendTasksUpdate(runner2);
|
|
3908
|
+
const resolvedArtifact = await runner2.onTestArtifactRecord(task, artifact);
|
|
3909
|
+
task.artifacts.push(resolvedArtifact);
|
|
3910
|
+
return resolvedArtifact;
|
|
3911
|
+
}
|
|
3912
|
+
var table = [];
|
|
3913
|
+
for (let i2 = 65; i2 < 91; i2++) {
|
|
3914
|
+
table.push(String.fromCharCode(i2));
|
|
3915
|
+
}
|
|
3916
|
+
for (let i2 = 97; i2 < 123; i2++) {
|
|
3917
|
+
table.push(String.fromCharCode(i2));
|
|
3918
|
+
}
|
|
3919
|
+
for (let i2 = 0; i2 < 10; i2++) {
|
|
3920
|
+
table.push(i2.toString(10));
|
|
3921
|
+
}
|
|
3922
|
+
table.push("+", "/");
|
|
3923
|
+
function encodeUint8Array(bytes) {
|
|
3924
|
+
let base64 = "";
|
|
3925
|
+
const len = bytes.byteLength;
|
|
3926
|
+
for (let i2 = 0; i2 < len; i2 += 3) {
|
|
3927
|
+
if (len === i2 + 1) {
|
|
3928
|
+
const a = (bytes[i2] & 252) >> 2;
|
|
3929
|
+
const b2 = (bytes[i2] & 3) << 4;
|
|
3930
|
+
base64 += table[a];
|
|
3931
|
+
base64 += table[b2];
|
|
3932
|
+
base64 += "==";
|
|
3933
|
+
} else if (len === i2 + 2) {
|
|
3934
|
+
const a = (bytes[i2] & 252) >> 2;
|
|
3935
|
+
const b2 = (bytes[i2] & 3) << 4 | (bytes[i2 + 1] & 240) >> 4;
|
|
3936
|
+
const c = (bytes[i2 + 1] & 15) << 2;
|
|
3937
|
+
base64 += table[a];
|
|
3938
|
+
base64 += table[b2];
|
|
3939
|
+
base64 += table[c];
|
|
3940
|
+
base64 += "=";
|
|
3941
|
+
} else {
|
|
3942
|
+
const a = (bytes[i2] & 252) >> 2;
|
|
3943
|
+
const b2 = (bytes[i2] & 3) << 4 | (bytes[i2 + 1] & 240) >> 4;
|
|
3944
|
+
const c = (bytes[i2 + 1] & 15) << 2 | (bytes[i2 + 2] & 192) >> 6;
|
|
3945
|
+
const d2 = bytes[i2 + 2] & 63;
|
|
3946
|
+
base64 += table[a];
|
|
3947
|
+
base64 += table[b2];
|
|
3948
|
+
base64 += table[c];
|
|
3949
|
+
base64 += table[d2];
|
|
3950
|
+
}
|
|
3951
|
+
}
|
|
3952
|
+
return base64;
|
|
3953
|
+
}
|
|
3954
|
+
function recordAsyncOperation(test3, promise) {
|
|
3955
|
+
promise = promise.finally(() => {
|
|
3956
|
+
if (!test3.promises) {
|
|
3957
|
+
return;
|
|
3958
|
+
}
|
|
3959
|
+
const index2 = test3.promises.indexOf(promise);
|
|
3960
|
+
if (index2 !== -1) {
|
|
3961
|
+
test3.promises.splice(index2, 1);
|
|
3962
|
+
}
|
|
3963
|
+
});
|
|
3964
|
+
if (!test3.promises) {
|
|
3965
|
+
test3.promises = [];
|
|
3966
|
+
}
|
|
3967
|
+
test3.promises.push(promise);
|
|
3968
|
+
return promise;
|
|
3969
|
+
}
|
|
3970
|
+
function manageArtifactAttachment(attachment) {
|
|
3971
|
+
if (attachment.body == null && !attachment.path) {
|
|
3972
|
+
throw new TypeError(`Test attachment requires "body" or "path" to be set. Both are missing.`);
|
|
3973
|
+
}
|
|
3974
|
+
if (attachment.body && attachment.path) {
|
|
3975
|
+
throw new TypeError(`Test attachment requires only one of "body" or "path" to be set. Both are specified.`);
|
|
3976
|
+
}
|
|
3977
|
+
if (attachment.path && attachment.bodyEncoding) {
|
|
3978
|
+
throw new TypeError(`Test attachment with "path" should not have "bodyEncoding" specified.`);
|
|
3979
|
+
}
|
|
3980
|
+
if (attachment.body instanceof Uint8Array) {
|
|
3981
|
+
attachment.body = encodeUint8Array(attachment.body);
|
|
3982
|
+
}
|
|
3983
|
+
if (attachment.body != null) {
|
|
3984
|
+
attachment.bodyEncoding ??= "base64";
|
|
3985
|
+
}
|
|
3986
|
+
}
|
|
3987
|
+
|
|
3988
|
+
// node_modules/vitest/node_modules/vite/dist/node/module-runner.js
|
|
3989
|
+
var SOURCEMAPPING_URL = "sourceMa";
|
|
3990
|
+
SOURCEMAPPING_URL += "ppingURL";
|
|
3991
|
+
var isWindows = typeof process < "u" && process.platform === "win32";
|
|
3992
|
+
var AsyncFunction = async function() {
|
|
3993
|
+
}.constructor;
|
|
3994
|
+
var textDecoder = new TextDecoder();
|
|
3995
|
+
var decodeBase64 = (() => {
|
|
3996
|
+
let capturedBuffer = typeof Buffer == "function" ? Buffer : void 0;
|
|
3997
|
+
return capturedBuffer && typeof capturedBuffer.from == "function" ? (base64) => capturedBuffer.from(base64, "base64").toString("utf-8") : (base64) => textDecoder.decode(Uint8Array.from(atob(base64), (c) => c.charCodeAt(0)));
|
|
3998
|
+
})();
|
|
3999
|
+
var chars2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
4000
|
+
var intToChar2 = /* @__PURE__ */ new Uint8Array(64);
|
|
4001
|
+
var charToInt2 = /* @__PURE__ */ new Uint8Array(128);
|
|
4002
|
+
for (let i2 = 0; i2 < chars2.length; i2++) {
|
|
4003
|
+
let c = chars2.charCodeAt(i2);
|
|
4004
|
+
intToChar2[i2] = c, charToInt2[c] = i2;
|
|
4005
|
+
}
|
|
4006
|
+
var MODULE_RUNNER_SOURCEMAPPING_REGEXP = RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json;base64,(.+)`);
|
|
4007
|
+
var retrieveFileHandlers = /* @__PURE__ */ new Set();
|
|
4008
|
+
var retrieveSourceMapHandlers = /* @__PURE__ */ new Set();
|
|
4009
|
+
var createExecHandlers = (handlers) => ((...args) => {
|
|
4010
|
+
for (let handler of handlers) {
|
|
4011
|
+
let result = handler(...args);
|
|
4012
|
+
if (result) return result;
|
|
4013
|
+
}
|
|
4014
|
+
return null;
|
|
4015
|
+
});
|
|
4016
|
+
var retrieveFileFromHandlers = createExecHandlers(retrieveFileHandlers);
|
|
4017
|
+
var retrieveSourceMapFromHandlers = createExecHandlers(retrieveSourceMapHandlers);
|
|
4018
|
+
var originalPrepare = Error.prepareStackTrace;
|
|
4019
|
+
var customizationHookNamespace = "vite-module-runner:import-meta-resolve/v1/";
|
|
4020
|
+
var customizationHooksModule = `
|
|
4021
|
+
|
|
4022
|
+
export async function resolve(specifier, context, nextResolve) {
|
|
4023
|
+
if (specifier.startsWith(${JSON.stringify(customizationHookNamespace)})) {
|
|
4024
|
+
const data = specifier.slice(${JSON.stringify(customizationHookNamespace)}.length)
|
|
4025
|
+
const [parsedSpecifier, parsedImporter] = JSON.parse(data)
|
|
4026
|
+
specifier = parsedSpecifier
|
|
4027
|
+
context.parentURL = parsedImporter
|
|
4028
|
+
}
|
|
4029
|
+
return nextResolve(specifier, context)
|
|
4030
|
+
}
|
|
4031
|
+
|
|
4032
|
+
`;
|
|
4033
|
+
var envProxy = new Proxy({}, { get(_, p) {
|
|
4034
|
+
throw Error(`[module runner] Dynamic access of "import.meta.env" is not supported. Please, use "import.meta.env.${String(p)}" instead.`);
|
|
4035
|
+
} });
|
|
4036
|
+
|
|
4037
|
+
// node_modules/vitest/dist/index.js
|
|
4038
|
+
var import_expect_type = __toESM(require_dist(), 1);
|
|
4039
|
+
|
|
4040
|
+
// core/testing/criterion.ts
|
|
4041
|
+
var stableId = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
4042
|
+
var criterionId = /^AC-[A-Z0-9]+(?:-[A-Z0-9]+)*$/;
|
|
4043
|
+
function validateRequirements(requirements) {
|
|
4044
|
+
const byId = /* @__PURE__ */ new Map();
|
|
4045
|
+
for (const requirement of requirements) {
|
|
4046
|
+
if (byId.has(requirement.id)) {
|
|
4047
|
+
throw new TestingError([testingDiagnostic(
|
|
4048
|
+
"SH_TEST_REQUIREMENT_DUPLICATE",
|
|
4049
|
+
`Requirement ${requirement.id} is duplicated in testing metadata.`,
|
|
4050
|
+
"Provide one current parsed requirement per stable ID.",
|
|
4051
|
+
requirement.id
|
|
4052
|
+
)]);
|
|
4053
|
+
}
|
|
4054
|
+
byId.set(requirement.id, requirement);
|
|
4055
|
+
}
|
|
4056
|
+
return byId;
|
|
4057
|
+
}
|
|
4058
|
+
function createRegistry(options) {
|
|
4059
|
+
const requirements = validateRequirements(options.requirements);
|
|
4060
|
+
const register = options.register ?? ((definition) => test2(definition.name, { skip: definition.skip }, definition.fn));
|
|
4061
|
+
const descriptors = /* @__PURE__ */ new Map();
|
|
4062
|
+
return Object.freeze({
|
|
4063
|
+
criterionTest(spec) {
|
|
4064
|
+
const diagnostics = [];
|
|
4065
|
+
const requirement = requirements.get(spec.requirementId);
|
|
4066
|
+
if (!stableId.test(spec.id)) {
|
|
4067
|
+
diagnostics.push(testingDiagnostic(
|
|
4068
|
+
"SH_TEST_ID_INVALID",
|
|
4069
|
+
`Test ID ${spec.id || "<empty>"} is not stable.`,
|
|
4070
|
+
"Use a non-empty ID containing letters, numbers, dots, underscores, or hyphens.",
|
|
4071
|
+
spec.id
|
|
4072
|
+
));
|
|
4073
|
+
}
|
|
4074
|
+
if (descriptors.has(spec.id)) {
|
|
4075
|
+
diagnostics.push(testingDiagnostic(
|
|
4076
|
+
"SH_TEST_ID_DUPLICATE",
|
|
4077
|
+
`Test ID ${spec.id} is already registered.`,
|
|
4078
|
+
"Give every governed test a globally unique stable ID.",
|
|
4079
|
+
spec.id
|
|
4080
|
+
));
|
|
4081
|
+
}
|
|
4082
|
+
if (!requirement) {
|
|
4083
|
+
diagnostics.push(testingDiagnostic(
|
|
4084
|
+
"SH_TEST_REQUIREMENT_UNKNOWN",
|
|
4085
|
+
`Test ${spec.id} names unknown requirement ${spec.requirementId}.`,
|
|
4086
|
+
"Use a requirement from the approved parsed inventory.",
|
|
4087
|
+
spec.id
|
|
4088
|
+
));
|
|
4089
|
+
} else {
|
|
4090
|
+
const approval = requirement.approval;
|
|
4091
|
+
const validApproval = requirement.status !== "draft" && approval?.valid && approval.digest === requirement.governedContentDigest;
|
|
4092
|
+
if (!validApproval) {
|
|
4093
|
+
diagnostics.push(testingDiagnostic(
|
|
4094
|
+
"SH_TEST_REQUIREMENT_NOT_APPROVED",
|
|
4095
|
+
`Requirement ${requirement.id} has ${requirement.status} lifecycle state and no valid current approval for test generation.`,
|
|
4096
|
+
"Obtain exact-content approval for the current requirement and bounded criteria.",
|
|
4097
|
+
requirement.id
|
|
4098
|
+
));
|
|
4099
|
+
}
|
|
4100
|
+
}
|
|
4101
|
+
if (spec.name.trim() === "") {
|
|
4102
|
+
diagnostics.push(testingDiagnostic(
|
|
4103
|
+
"SH_TEST_NAME_REQUIRED",
|
|
4104
|
+
`Test ${spec.id} has an empty human-readable name.`,
|
|
4105
|
+
"Describe the observable behavior in the test name.",
|
|
4106
|
+
spec.id
|
|
4107
|
+
));
|
|
4108
|
+
}
|
|
4109
|
+
if (spec.sourcePath.trim() === "") {
|
|
4110
|
+
diagnostics.push(testingDiagnostic(
|
|
4111
|
+
"SH_TEST_SOURCE_REQUIRED",
|
|
4112
|
+
`Test ${spec.id} has no source path.`,
|
|
4113
|
+
"Record the repository-relative test source path.",
|
|
4114
|
+
spec.id
|
|
4115
|
+
));
|
|
4116
|
+
}
|
|
4117
|
+
if (spec.criteria.length === 0 || spec.criteria.some((id) => !criterionId.test(id))) {
|
|
4118
|
+
diagnostics.push(testingDiagnostic(
|
|
4119
|
+
"SH_TEST_CRITERIA_INVALID",
|
|
4120
|
+
`Test ${spec.id} must name at least one stable acceptance criterion.`,
|
|
4121
|
+
"Use unique IDs such as AC-BOOKMARKS-001.",
|
|
4122
|
+
spec.id
|
|
4123
|
+
));
|
|
4124
|
+
}
|
|
4125
|
+
if (new Set(spec.criteria).size !== spec.criteria.length) {
|
|
4126
|
+
diagnostics.push(testingDiagnostic(
|
|
4127
|
+
"SH_TEST_CRITERIA_DUPLICATE",
|
|
4128
|
+
`Test ${spec.id} repeats a criterion mapping.`,
|
|
4129
|
+
"List each mapped criterion exactly once.",
|
|
4130
|
+
spec.id
|
|
4131
|
+
));
|
|
4132
|
+
}
|
|
4133
|
+
if (requirement) {
|
|
4134
|
+
const declared = new Set(requirement.criteria.map((item) => item.id));
|
|
4135
|
+
const approved = new Set(requirement.approval?.criteria ?? []);
|
|
4136
|
+
for (const id of spec.criteria) {
|
|
4137
|
+
if (!declared.has(id) || !approved.has(id)) {
|
|
4138
|
+
diagnostics.push(testingDiagnostic(
|
|
4139
|
+
"SH_TEST_CRITERION_NOT_APPROVED",
|
|
4140
|
+
`Test ${spec.id} maps criterion ${id}, which is not bounded by the current approval.`,
|
|
4141
|
+
"Map only current declared and approved criteria.",
|
|
4142
|
+
spec.id
|
|
4143
|
+
));
|
|
4144
|
+
}
|
|
4145
|
+
}
|
|
4146
|
+
}
|
|
4147
|
+
if (diagnostics.length > 0) throw new TestingError(diagnostics);
|
|
4148
|
+
const registeredName = `${spec.criteria.join(" ")} \xB7 ${spec.name.trim()}`;
|
|
4149
|
+
const descriptor = Object.freeze({
|
|
4150
|
+
id: spec.id,
|
|
4151
|
+
requirementId: spec.requirementId,
|
|
4152
|
+
criteria: Object.freeze([...spec.criteria]),
|
|
4153
|
+
name: spec.name.trim(),
|
|
4154
|
+
registeredName,
|
|
4155
|
+
sourcePath: spec.sourcePath
|
|
4156
|
+
});
|
|
4157
|
+
register({
|
|
4158
|
+
name: registeredName,
|
|
4159
|
+
fn: spec.fn,
|
|
4160
|
+
skip: spec.ignore
|
|
4161
|
+
});
|
|
4162
|
+
descriptors.set(spec.id, descriptor);
|
|
4163
|
+
return descriptor;
|
|
4164
|
+
},
|
|
4165
|
+
descriptors() {
|
|
4166
|
+
return Object.freeze([...descriptors.values()]);
|
|
4167
|
+
}
|
|
4168
|
+
});
|
|
4169
|
+
}
|
|
4170
|
+
function manifest(options) {
|
|
4171
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4172
|
+
const tests = options.descriptors.map((descriptor) => {
|
|
4173
|
+
if (seen.has(descriptor.id)) {
|
|
4174
|
+
throw new TestingError([testingDiagnostic(
|
|
4175
|
+
"SH_TEST_ID_DUPLICATE",
|
|
4176
|
+
`Manifest contains duplicate test ID ${descriptor.id}.`,
|
|
4177
|
+
"Give every governed test one globally unique ID.",
|
|
4178
|
+
descriptor.id
|
|
4179
|
+
)]);
|
|
4180
|
+
}
|
|
4181
|
+
seen.add(descriptor.id);
|
|
4182
|
+
const source = options.sources[descriptor.sourcePath];
|
|
4183
|
+
if (source === void 0) {
|
|
4184
|
+
throw new TestingError([testingDiagnostic(
|
|
4185
|
+
"SH_TEST_SOURCE_MISSING",
|
|
4186
|
+
`Manifest cannot read source ${descriptor.sourcePath} for ${descriptor.id}.`,
|
|
4187
|
+
"Provide the exact UTF-8 test source before recording its manifest.",
|
|
4188
|
+
descriptor.id
|
|
4189
|
+
)]);
|
|
4190
|
+
}
|
|
4191
|
+
return Object.freeze({
|
|
4192
|
+
...descriptor,
|
|
4193
|
+
criteria: Object.freeze([...descriptor.criteria]),
|
|
4194
|
+
sourceDigest: createHash("sha256").update(source, "utf8").digest("hex")
|
|
4195
|
+
});
|
|
4196
|
+
}).sort(
|
|
4197
|
+
(left, right) => left.requirementId.localeCompare(right.requirementId) || left.id.localeCompare(right.id)
|
|
4198
|
+
);
|
|
4199
|
+
return Object.freeze({
|
|
4200
|
+
schema: "sleepy-hollow-test-manifest/v1",
|
|
4201
|
+
tests: Object.freeze(tests)
|
|
4202
|
+
});
|
|
4203
|
+
}
|
|
4204
|
+
|
|
4205
|
+
// core/testing/red_state.ts
|
|
4206
|
+
function redState(options) {
|
|
4207
|
+
const criteria = [...options.requirement.criteria.map((item) => item.id)].sort();
|
|
4208
|
+
const base = {
|
|
4209
|
+
requirementId: options.requirement.id,
|
|
4210
|
+
requirementDigest: options.requirement.governedContentDigest,
|
|
4211
|
+
baselineRevision: options.baselineRevision,
|
|
4212
|
+
runner: options.runner,
|
|
4213
|
+
environment: options.environment,
|
|
4214
|
+
criteria: Object.freeze(criteria),
|
|
4215
|
+
tests: Object.freeze([...options.tests])
|
|
4216
|
+
};
|
|
4217
|
+
const failedBaseline = options.baselineChecks.filter(
|
|
4218
|
+
(check) => check.status === "failed"
|
|
4219
|
+
);
|
|
4220
|
+
if (failedBaseline.length > 0) {
|
|
4221
|
+
return Object.freeze({
|
|
4222
|
+
...base,
|
|
4223
|
+
kind: "broken-baseline",
|
|
4224
|
+
valid: false,
|
|
4225
|
+
diagnostics: Object.freeze(
|
|
4226
|
+
failedBaseline.map(
|
|
4227
|
+
(check) => testingDiagnostic(
|
|
4228
|
+
"SH_TEST_BASELINE_BROKEN",
|
|
4229
|
+
`Baseline ${check.kind} check ${check.id} failed${check.evidence ? `: ${check.evidence}` : ""}.`,
|
|
4230
|
+
"Repair or isolate the unrelated baseline failure before recording red evidence.",
|
|
4231
|
+
check.id
|
|
4232
|
+
)
|
|
4233
|
+
)
|
|
4234
|
+
)
|
|
4235
|
+
});
|
|
4236
|
+
}
|
|
4237
|
+
const diagnostics = [];
|
|
4238
|
+
const approval = options.requirement.approval;
|
|
4239
|
+
if (options.requirement.status === "draft" || !approval?.valid || approval.digest !== options.requirement.governedContentDigest) {
|
|
4240
|
+
diagnostics.push(testingDiagnostic(
|
|
4241
|
+
"SH_TEST_RED_APPROVAL_INVALID",
|
|
4242
|
+
`Requirement ${options.requirement.id} lacks approval for current content.`,
|
|
4243
|
+
"Obtain current exact-content approval before treating failures as governed red evidence.",
|
|
4244
|
+
options.requirement.id
|
|
4245
|
+
));
|
|
4246
|
+
}
|
|
4247
|
+
const reached = /* @__PURE__ */ new Set();
|
|
4248
|
+
for (const test3 of options.tests) {
|
|
4249
|
+
if (test3.status !== "failed" || test3.failureKind !== "missing-behavior" || !test3.expectedReason?.trim() || !test3.evidence?.trim() || !test3.testDigest.trim()) {
|
|
4250
|
+
diagnostics.push(testingDiagnostic(
|
|
4251
|
+
"SH_TEST_RED_FAILURE_INVALID",
|
|
4252
|
+
`Test ${test3.testId} did not fail solely for documented missing approved behavior.`,
|
|
4253
|
+
"Separate compile, assertion, permission, startup, dependency, unrelated, passing, and skipped outcomes from expected red evidence.",
|
|
4254
|
+
test3.testId
|
|
4255
|
+
));
|
|
4256
|
+
continue;
|
|
4257
|
+
}
|
|
4258
|
+
test3.criterionIds.forEach((id) => reached.add(id));
|
|
4259
|
+
}
|
|
4260
|
+
for (const criterion of criteria) {
|
|
4261
|
+
if (!reached.has(criterion)) {
|
|
4262
|
+
diagnostics.push(testingDiagnostic(
|
|
4263
|
+
"SH_TEST_RED_CRITERION_MISSING",
|
|
4264
|
+
`Criterion ${criterion} has no expected missing-behavior failure.`,
|
|
4265
|
+
"Run at least one mapped acceptance test before implementation and record its expected failure.",
|
|
4266
|
+
criterion
|
|
4267
|
+
));
|
|
4268
|
+
}
|
|
4269
|
+
}
|
|
4270
|
+
return Object.freeze({
|
|
4271
|
+
...base,
|
|
4272
|
+
kind: diagnostics.length === 0 ? "expected-red" : "invalid-red",
|
|
4273
|
+
valid: diagnostics.length === 0,
|
|
4274
|
+
diagnostics: Object.freeze(diagnostics)
|
|
4275
|
+
});
|
|
4276
|
+
}
|
|
4277
|
+
|
|
4278
|
+
// core/testing/selection.ts
|
|
4279
|
+
var sorted = (values) => [...new Set(values)].sort();
|
|
4280
|
+
function selection(options) {
|
|
4281
|
+
const diagnostics = [];
|
|
4282
|
+
const requirements = /* @__PURE__ */ new Map();
|
|
4283
|
+
for (const requirement of options.requirements) {
|
|
4284
|
+
if (requirements.has(requirement.id)) {
|
|
4285
|
+
diagnostics.push(testingDiagnostic(
|
|
4286
|
+
"SH_TEST_SELECTION_REQUIREMENT_DUPLICATE",
|
|
4287
|
+
`Requirement ${requirement.id} is duplicated.`,
|
|
4288
|
+
"Resolve requirement identity before targeted selection.",
|
|
4289
|
+
requirement.id
|
|
4290
|
+
));
|
|
4291
|
+
}
|
|
4292
|
+
requirements.set(requirement.id, requirement);
|
|
4293
|
+
}
|
|
4294
|
+
const testIds = /* @__PURE__ */ new Set();
|
|
4295
|
+
for (const test3 of options.tests) {
|
|
4296
|
+
if (testIds.has(test3.id)) {
|
|
4297
|
+
diagnostics.push(testingDiagnostic(
|
|
4298
|
+
"SH_TEST_SELECTION_TEST_DUPLICATE",
|
|
4299
|
+
`Test ${test3.id} is duplicated.`,
|
|
4300
|
+
"Resolve test identity before targeted selection.",
|
|
4301
|
+
test3.id
|
|
4302
|
+
));
|
|
4303
|
+
}
|
|
4304
|
+
testIds.add(test3.id);
|
|
4305
|
+
if (!requirements.has(test3.requirementId)) {
|
|
4306
|
+
diagnostics.push(testingDiagnostic(
|
|
4307
|
+
"SH_TEST_SELECTION_TEST_UNMAPPED",
|
|
4308
|
+
`Test ${test3.id} names unknown requirement ${test3.requirementId}.`,
|
|
4309
|
+
"Map every governed test to a known requirement or run the full suite.",
|
|
4310
|
+
test3.id
|
|
4311
|
+
));
|
|
4312
|
+
}
|
|
4313
|
+
}
|
|
4314
|
+
for (const target of options.targets) {
|
|
4315
|
+
if (!requirements.has(target)) {
|
|
4316
|
+
diagnostics.push(testingDiagnostic(
|
|
4317
|
+
"SH_TEST_SELECTION_TARGET_UNKNOWN",
|
|
4318
|
+
`Target requirement ${target} is unknown.`,
|
|
4319
|
+
"Choose a requirement from the parsed inventory.",
|
|
4320
|
+
target
|
|
4321
|
+
));
|
|
4322
|
+
}
|
|
4323
|
+
}
|
|
4324
|
+
for (const requirement of requirements.values()) {
|
|
4325
|
+
for (const dependency of requirement.dependsOn) {
|
|
4326
|
+
if (!requirements.has(dependency)) {
|
|
4327
|
+
diagnostics.push(testingDiagnostic(
|
|
4328
|
+
"SH_TEST_SELECTION_DEPENDENCY_MISSING",
|
|
4329
|
+
`Requirement ${requirement.id} has missing dependency ${dependency}.`,
|
|
4330
|
+
"Resolve the dependency graph before targeted selection.",
|
|
4331
|
+
requirement.id
|
|
4332
|
+
));
|
|
4333
|
+
}
|
|
4334
|
+
}
|
|
4335
|
+
}
|
|
4336
|
+
const visiting = /* @__PURE__ */ new Set();
|
|
4337
|
+
const visited = /* @__PURE__ */ new Set();
|
|
4338
|
+
const visit = (id) => {
|
|
4339
|
+
if (visited.has(id) || !requirements.has(id)) return;
|
|
4340
|
+
if (visiting.has(id)) {
|
|
4341
|
+
diagnostics.push(testingDiagnostic(
|
|
4342
|
+
"SH_TEST_SELECTION_DEPENDENCY_CYCLE",
|
|
4343
|
+
`Requirement dependency cycle includes ${id}.`,
|
|
4344
|
+
"Resolve the cycle before targeted selection.",
|
|
4345
|
+
id
|
|
4346
|
+
));
|
|
4347
|
+
return;
|
|
4348
|
+
}
|
|
4349
|
+
visiting.add(id);
|
|
4350
|
+
for (const dependency of requirements.get(id)?.dependsOn ?? []) {
|
|
4351
|
+
visit(dependency);
|
|
4352
|
+
}
|
|
4353
|
+
visiting.delete(id);
|
|
4354
|
+
visited.add(id);
|
|
4355
|
+
};
|
|
4356
|
+
requirements.forEach((_value, id) => visit(id));
|
|
4357
|
+
if (options.hasUnownedSharedChange) {
|
|
4358
|
+
diagnostics.push(testingDiagnostic(
|
|
4359
|
+
"SH_TEST_SELECTION_SHARED_OWNER_UNKNOWN",
|
|
4360
|
+
"A changed shared artifact has no complete requirement ownership mapping.",
|
|
4361
|
+
"Run the full relevant suite and define ownership before future targeting."
|
|
4362
|
+
));
|
|
4363
|
+
}
|
|
4364
|
+
const allRequirements = sorted(requirements.keys());
|
|
4365
|
+
const allTests = sorted(options.tests.map((test3) => test3.id));
|
|
4366
|
+
if (diagnostics.length > 0 || options.targets.length === 0) {
|
|
4367
|
+
if (options.targets.length === 0) {
|
|
4368
|
+
diagnostics.push(testingDiagnostic(
|
|
4369
|
+
"SH_TEST_SELECTION_TARGET_REQUIRED",
|
|
4370
|
+
"Targeted selection requires at least one requirement ID.",
|
|
4371
|
+
"Name a target or run the full suite explicitly."
|
|
4372
|
+
));
|
|
4373
|
+
}
|
|
4374
|
+
return Object.freeze({
|
|
4375
|
+
mode: "full",
|
|
4376
|
+
requirementIds: Object.freeze(allRequirements),
|
|
4377
|
+
testIds: Object.freeze(allTests),
|
|
4378
|
+
reasons: Object.freeze(Object.fromEntries(
|
|
4379
|
+
allRequirements.map((id) => [id, Object.freeze(["full-suite-escalation"])])
|
|
4380
|
+
)),
|
|
4381
|
+
diagnostics: Object.freeze(diagnostics)
|
|
4382
|
+
});
|
|
4383
|
+
}
|
|
4384
|
+
const selected = new Set(options.targets);
|
|
4385
|
+
const reasons = /* @__PURE__ */ new Map();
|
|
4386
|
+
options.targets.forEach((id) => reasons.set(id, /* @__PURE__ */ new Set(["target"])));
|
|
4387
|
+
let changed = true;
|
|
4388
|
+
while (changed) {
|
|
4389
|
+
changed = false;
|
|
4390
|
+
for (const requirement of requirements.values()) {
|
|
4391
|
+
if (selected.has(requirement.id)) {
|
|
4392
|
+
for (const dependency of requirement.dependsOn) {
|
|
4393
|
+
if (!selected.has(dependency)) changed = true;
|
|
4394
|
+
selected.add(dependency);
|
|
4395
|
+
const current = reasons.get(dependency) ?? /* @__PURE__ */ new Set();
|
|
4396
|
+
current.add(`dependency-of:${requirement.id}`);
|
|
4397
|
+
reasons.set(dependency, current);
|
|
4398
|
+
}
|
|
4399
|
+
}
|
|
4400
|
+
if (!selected.has(requirement.id) && requirement.dependsOn.some((dependency) => selected.has(dependency))) {
|
|
4401
|
+
selected.add(requirement.id);
|
|
4402
|
+
changed = true;
|
|
4403
|
+
const current = reasons.get(requirement.id) ?? /* @__PURE__ */ new Set();
|
|
4404
|
+
for (const dependency of requirement.dependsOn) {
|
|
4405
|
+
if (selected.has(dependency)) {
|
|
4406
|
+
current.add(`dependent-of:${dependency}`);
|
|
4407
|
+
}
|
|
4408
|
+
}
|
|
4409
|
+
reasons.set(requirement.id, current);
|
|
4410
|
+
}
|
|
4411
|
+
}
|
|
4412
|
+
}
|
|
4413
|
+
const requirementIds = sorted(selected);
|
|
4414
|
+
const selectedTests = sorted(
|
|
4415
|
+
options.tests.filter((test3) => selected.has(test3.requirementId)).map((test3) => test3.id)
|
|
4416
|
+
);
|
|
4417
|
+
return Object.freeze({
|
|
4418
|
+
mode: "targeted",
|
|
4419
|
+
requirementIds: Object.freeze(requirementIds),
|
|
4420
|
+
testIds: Object.freeze(selectedTests),
|
|
4421
|
+
reasons: Object.freeze(Object.fromEntries(
|
|
4422
|
+
requirementIds.map((id) => [id, Object.freeze(sorted(reasons.get(id) ?? []))])
|
|
4423
|
+
)),
|
|
4424
|
+
diagnostics: Object.freeze([])
|
|
4425
|
+
});
|
|
4426
|
+
}
|
|
4427
|
+
|
|
4428
|
+
// core/testing/traceability.ts
|
|
4429
|
+
var sorted2 = (values) => [...new Set(values)].sort();
|
|
4430
|
+
function traceability(options) {
|
|
4431
|
+
const requirements = new Map(
|
|
4432
|
+
options.requirements.map((requirement) => [requirement.id, requirement])
|
|
4433
|
+
);
|
|
4434
|
+
const results = new Map(
|
|
4435
|
+
options.results.map((result) => [result.testId, result])
|
|
4436
|
+
);
|
|
4437
|
+
const testsByCriterion = /* @__PURE__ */ new Map();
|
|
4438
|
+
const unmappedTests = [];
|
|
4439
|
+
for (const test3 of options.manifest.tests) {
|
|
4440
|
+
const requirement = requirements.get(test3.requirementId);
|
|
4441
|
+
const approved = new Set(requirement?.approval?.criteria ?? []);
|
|
4442
|
+
let mapped = Boolean(requirement && test3.criteria.length > 0);
|
|
4443
|
+
for (const id of test3.criteria) {
|
|
4444
|
+
if (!approved.has(id)) mapped = false;
|
|
4445
|
+
const key = `${test3.requirementId}\0${id}`;
|
|
4446
|
+
const current2 = testsByCriterion.get(key) ?? [];
|
|
4447
|
+
current2.push(test3.id);
|
|
4448
|
+
testsByCriterion.set(key, current2);
|
|
4449
|
+
}
|
|
4450
|
+
if (!mapped) unmappedTests.push(test3.id);
|
|
4451
|
+
}
|
|
4452
|
+
const traces = [];
|
|
4453
|
+
for (const requirement of [...options.requirements].sort(
|
|
4454
|
+
(left, right) => left.id.localeCompare(right.id)
|
|
4455
|
+
)) {
|
|
4456
|
+
for (const criterion of [...requirement.criteria].sort(
|
|
4457
|
+
(left, right) => left.id.localeCompare(right.id)
|
|
4458
|
+
)) {
|
|
4459
|
+
const testIds = sorted2(
|
|
4460
|
+
testsByCriterion.get(`${requirement.id}\0${criterion.id}`) ?? []
|
|
4461
|
+
);
|
|
4462
|
+
const statuses = testIds.map(
|
|
4463
|
+
(id) => results.get(id)?.status ?? "skipped"
|
|
4464
|
+
);
|
|
4465
|
+
const status = testIds.length === 0 ? "unmapped" : statuses.includes("failed") ? "failing" : statuses.includes("skipped") ? "skipped" : "passing";
|
|
4466
|
+
traces.push(Object.freeze({
|
|
4467
|
+
requirementId: requirement.id,
|
|
4468
|
+
criterionId: criterion.id,
|
|
4469
|
+
testIds: Object.freeze(testIds),
|
|
4470
|
+
status
|
|
4471
|
+
}));
|
|
4472
|
+
}
|
|
4473
|
+
}
|
|
4474
|
+
const previous = new Map(
|
|
4475
|
+
(options.previousManifest?.tests ?? []).map((test3) => [test3.id, test3])
|
|
4476
|
+
);
|
|
4477
|
+
const current = new Map(
|
|
4478
|
+
options.manifest.tests.map((test3) => [test3.id, test3])
|
|
4479
|
+
);
|
|
4480
|
+
const reviewed = new Set(options.reviewedTestIds ?? []);
|
|
4481
|
+
const removedTests = sorted2(
|
|
4482
|
+
[...previous.keys()].filter((id) => !current.has(id))
|
|
4483
|
+
);
|
|
4484
|
+
const changedTests = sorted2(
|
|
4485
|
+
[...current].filter(([id, test3]) => {
|
|
4486
|
+
const prior = previous.get(id);
|
|
4487
|
+
return prior && prior.sourceDigest !== test3.sourceDigest && !reviewed.has(id);
|
|
4488
|
+
}).map(([id]) => id)
|
|
4489
|
+
);
|
|
4490
|
+
const weakenedMappings = sorted2(
|
|
4491
|
+
[...current].filter(([id, test3]) => {
|
|
4492
|
+
const prior = previous.get(id);
|
|
4493
|
+
if (!prior) return false;
|
|
4494
|
+
const mappings = new Set(test3.criteria);
|
|
4495
|
+
return prior.criteria.some((criterion) => !mappings.has(criterion));
|
|
4496
|
+
}).map(([id]) => id)
|
|
4497
|
+
);
|
|
4498
|
+
const passingCriteria = traces.filter((item) => item.status === "passing").map(
|
|
4499
|
+
(item) => item.criterionId
|
|
4500
|
+
);
|
|
4501
|
+
const failingCriteria = traces.filter((item) => item.status === "failing").map(
|
|
4502
|
+
(item) => item.criterionId
|
|
4503
|
+
);
|
|
4504
|
+
const skippedCriteria = traces.filter((item) => item.status === "skipped").map(
|
|
4505
|
+
(item) => item.criterionId
|
|
4506
|
+
);
|
|
4507
|
+
const unmappedCriteria = traces.filter((item) => item.status === "unmapped").map(
|
|
4508
|
+
(item) => item.criterionId
|
|
4509
|
+
);
|
|
4510
|
+
const eligibleForVerification = traces.length > 0 && traces.every((item) => item.status === "passing") && unmappedTests.length === 0 && removedTests.length === 0 && changedTests.length === 0 && weakenedMappings.length === 0;
|
|
4511
|
+
return Object.freeze({
|
|
4512
|
+
schema: "sleepy-hollow-traceability/v1",
|
|
4513
|
+
criteria: Object.freeze(traces),
|
|
4514
|
+
passingCriteria: Object.freeze(passingCriteria),
|
|
4515
|
+
failingCriteria: Object.freeze(failingCriteria),
|
|
4516
|
+
skippedCriteria: Object.freeze(skippedCriteria),
|
|
4517
|
+
unmappedCriteria: Object.freeze(unmappedCriteria),
|
|
4518
|
+
unmappedTests: Object.freeze(sorted2(unmappedTests)),
|
|
4519
|
+
removedTests: Object.freeze(removedTests),
|
|
4520
|
+
changedTests: Object.freeze(changedTests),
|
|
4521
|
+
weakenedMappings: Object.freeze(weakenedMappings),
|
|
4522
|
+
eligibleForVerification
|
|
4523
|
+
});
|
|
4524
|
+
}
|
|
4525
|
+
|
|
4526
|
+
// core/testing/mod.ts
|
|
4527
|
+
function createCriterionRegistry(options) {
|
|
4528
|
+
return createRegistry(options);
|
|
4529
|
+
}
|
|
4530
|
+
function criterionTest(spec, options) {
|
|
4531
|
+
return createRegistry(options).criterionTest(spec);
|
|
4532
|
+
}
|
|
4533
|
+
function createTestManifest(options) {
|
|
4534
|
+
return manifest(options);
|
|
4535
|
+
}
|
|
4536
|
+
function createTraceabilityReport(options) {
|
|
4537
|
+
return traceability(options);
|
|
4538
|
+
}
|
|
4539
|
+
function classifyRedState(options) {
|
|
4540
|
+
return redState(options);
|
|
4541
|
+
}
|
|
4542
|
+
function createTestApplication(options) {
|
|
4543
|
+
return testApplication(options);
|
|
4544
|
+
}
|
|
4545
|
+
function assertProblem(response, expectation) {
|
|
4546
|
+
return problem(response, expectation);
|
|
4547
|
+
}
|
|
4548
|
+
function selectAffectedTests(options) {
|
|
4549
|
+
return selection(options);
|
|
4550
|
+
}
|
|
4551
|
+
|
|
4552
|
+
export {
|
|
4553
|
+
TestingError,
|
|
4554
|
+
createCriterionRegistry,
|
|
4555
|
+
criterionTest,
|
|
4556
|
+
createTestManifest,
|
|
4557
|
+
createTraceabilityReport,
|
|
4558
|
+
classifyRedState,
|
|
4559
|
+
createTestApplication,
|
|
4560
|
+
assertProblem,
|
|
4561
|
+
selectAffectedTests
|
|
4562
|
+
};
|
|
4563
|
+
/*! Bundled license information:
|
|
4564
|
+
|
|
4565
|
+
@vitest/pretty-format/dist/index.js:
|
|
4566
|
+
(**
|
|
4567
|
+
* @license React
|
|
4568
|
+
* react-is.production.js
|
|
4569
|
+
*
|
|
4570
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4571
|
+
*
|
|
4572
|
+
* This source code is licensed under the MIT license found in the
|
|
4573
|
+
* LICENSE file in the root directory of this source tree.
|
|
4574
|
+
*)
|
|
4575
|
+
(**
|
|
4576
|
+
* @license React
|
|
4577
|
+
* react-is.production.min.js
|
|
4578
|
+
*
|
|
4579
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4580
|
+
*
|
|
4581
|
+
* This source code is licensed under the MIT license found in the
|
|
4582
|
+
* LICENSE file in the root directory of this source tree.
|
|
4583
|
+
*)
|
|
4584
|
+
*/
|
|
4585
|
+
//# sourceMappingURL=chunk-D4U3ZY4O.js.map
|