@procore/hammer-test-jest 0.3.0 → 0.5.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/README.md +4 -1
- package/dist/index.d.mts +8 -17
- package/dist/index.d.ts +8 -17
- package/dist/index.js +7 -30
- package/dist/index.mjs +7 -29
- package/dist/transforms/file.test.js +207 -109
- package/dist/transforms/file.test.mjs +207 -109
- package/dist/transforms/reactSvg.test.js +207 -109
- package/dist/transforms/reactSvg.test.mjs +207 -109
- package/package.json +19 -20
|
@@ -7777,7 +7777,14 @@ function clone(val, seen, options = defaultCloneOptions) {
|
|
|
7777
7777
|
if (!descriptor)
|
|
7778
7778
|
continue;
|
|
7779
7779
|
const cloned = clone(val[k22], seen, options);
|
|
7780
|
-
if (
|
|
7780
|
+
if (options.forceWritable) {
|
|
7781
|
+
Object.defineProperty(out, k22, {
|
|
7782
|
+
enumerable: descriptor.enumerable,
|
|
7783
|
+
configurable: true,
|
|
7784
|
+
writable: true,
|
|
7785
|
+
value: cloned
|
|
7786
|
+
});
|
|
7787
|
+
} else if ("get" in descriptor) {
|
|
7781
7788
|
Object.defineProperty(out, k22, {
|
|
7782
7789
|
...descriptor,
|
|
7783
7790
|
get() {
|
|
@@ -7787,7 +7794,6 @@ function clone(val, seen, options = defaultCloneOptions) {
|
|
|
7787
7794
|
} else {
|
|
7788
7795
|
Object.defineProperty(out, k22, {
|
|
7789
7796
|
...descriptor,
|
|
7790
|
-
writable: options.forceWritable ? true : descriptor.writable,
|
|
7791
7797
|
value: cloned
|
|
7792
7798
|
});
|
|
7793
7799
|
}
|
|
@@ -7949,7 +7955,7 @@ function objDisplay(obj, options = {}) {
|
|
|
7949
7955
|
if (options.truncate && str.length >= options.truncate) {
|
|
7950
7956
|
if (type2 === "[object Function]") {
|
|
7951
7957
|
const fn2 = obj;
|
|
7952
|
-
return !fn2.name
|
|
7958
|
+
return !fn2.name ? "[Function]" : `[Function: ${fn2.name}]`;
|
|
7953
7959
|
} else if (type2 === "[object Array]") {
|
|
7954
7960
|
return `[ Array(${obj.length}) ]`;
|
|
7955
7961
|
} else if (type2 === "[object Object]") {
|
|
@@ -8389,6 +8395,7 @@ function joinAlignedDiffsExpand(diffs, options) {
|
|
|
8389
8395
|
}
|
|
8390
8396
|
var noColor = (string3) => string3;
|
|
8391
8397
|
var DIFF_CONTEXT_DEFAULT = 5;
|
|
8398
|
+
var DIFF_TRUNCATE_THRESHOLD_DEFAULT = 0;
|
|
8392
8399
|
function getDefaultOptions() {
|
|
8393
8400
|
const c2 = getColors();
|
|
8394
8401
|
return {
|
|
@@ -8409,7 +8416,10 @@ function getDefaultOptions() {
|
|
|
8409
8416
|
expand: true,
|
|
8410
8417
|
includeChangeCounts: false,
|
|
8411
8418
|
omitAnnotationLines: false,
|
|
8412
|
-
patchColor: c2.yellow
|
|
8419
|
+
patchColor: c2.yellow,
|
|
8420
|
+
truncateThreshold: DIFF_TRUNCATE_THRESHOLD_DEFAULT,
|
|
8421
|
+
truncateAnnotation: "... Diff result is truncated",
|
|
8422
|
+
truncateAnnotationColor: noColor
|
|
8413
8423
|
};
|
|
8414
8424
|
}
|
|
8415
8425
|
function getCompareKeys(compareKeys) {
|
|
@@ -8477,16 +8487,21 @@ ${bColor(b2)}
|
|
|
8477
8487
|
|
|
8478
8488
|
`;
|
|
8479
8489
|
}
|
|
8480
|
-
function printDiffLines(diffs, options) {
|
|
8481
|
-
return printAnnotation(options, countChanges(diffs)) + (options.expand ? joinAlignedDiffsExpand(diffs, options) : joinAlignedDiffsNoExpand(diffs, options))
|
|
8490
|
+
function printDiffLines(diffs, truncated, options) {
|
|
8491
|
+
return printAnnotation(options, countChanges(diffs)) + (options.expand ? joinAlignedDiffsExpand(diffs, options) : joinAlignedDiffsNoExpand(diffs, options)) + (truncated ? options.truncateAnnotationColor(`
|
|
8492
|
+
${options.truncateAnnotation}`) : "");
|
|
8482
8493
|
}
|
|
8483
8494
|
function diffLinesUnified(aLines, bLines, options) {
|
|
8495
|
+
const normalizedOptions = normalizeDiffOptions(options);
|
|
8496
|
+
const [diffs, truncated] = diffLinesRaw(
|
|
8497
|
+
isEmptyString(aLines) ? [] : aLines,
|
|
8498
|
+
isEmptyString(bLines) ? [] : bLines,
|
|
8499
|
+
normalizedOptions
|
|
8500
|
+
);
|
|
8484
8501
|
return printDiffLines(
|
|
8485
|
-
|
|
8486
|
-
|
|
8487
|
-
|
|
8488
|
-
),
|
|
8489
|
-
normalizeDiffOptions(options)
|
|
8502
|
+
diffs,
|
|
8503
|
+
truncated,
|
|
8504
|
+
normalizedOptions
|
|
8490
8505
|
);
|
|
8491
8506
|
}
|
|
8492
8507
|
function diffLinesUnified2(aLinesDisplay, bLinesDisplay, aLinesCompare, bLinesCompare, options) {
|
|
@@ -8501,7 +8516,7 @@ function diffLinesUnified2(aLinesDisplay, bLinesDisplay, aLinesCompare, bLinesCo
|
|
|
8501
8516
|
if (aLinesDisplay.length !== aLinesCompare.length || bLinesDisplay.length !== bLinesCompare.length) {
|
|
8502
8517
|
return diffLinesUnified(aLinesDisplay, bLinesDisplay, options);
|
|
8503
8518
|
}
|
|
8504
|
-
const diffs = diffLinesRaw(aLinesCompare, bLinesCompare);
|
|
8519
|
+
const [diffs, truncated] = diffLinesRaw(aLinesCompare, bLinesCompare, options);
|
|
8505
8520
|
let aIndex = 0;
|
|
8506
8521
|
let bIndex = 0;
|
|
8507
8522
|
diffs.forEach((diff2) => {
|
|
@@ -8520,11 +8535,14 @@ function diffLinesUnified2(aLinesDisplay, bLinesDisplay, aLinesCompare, bLinesCo
|
|
|
8520
8535
|
bIndex += 1;
|
|
8521
8536
|
}
|
|
8522
8537
|
});
|
|
8523
|
-
return printDiffLines(diffs, normalizeDiffOptions(options));
|
|
8524
|
-
}
|
|
8525
|
-
function diffLinesRaw(aLines, bLines) {
|
|
8526
|
-
const
|
|
8527
|
-
const
|
|
8538
|
+
return printDiffLines(diffs, truncated, normalizeDiffOptions(options));
|
|
8539
|
+
}
|
|
8540
|
+
function diffLinesRaw(aLines, bLines, options) {
|
|
8541
|
+
const truncate2 = (options == null ? void 0 : options.truncateThreshold) ?? false;
|
|
8542
|
+
const truncateThreshold = Math.max(Math.floor((options == null ? void 0 : options.truncateThreshold) ?? 0), 0);
|
|
8543
|
+
const aLength = truncate2 ? Math.min(aLines.length, truncateThreshold) : aLines.length;
|
|
8544
|
+
const bLength = truncate2 ? Math.min(bLines.length, truncateThreshold) : bLines.length;
|
|
8545
|
+
const truncated = aLength !== aLines.length || bLength !== bLines.length;
|
|
8528
8546
|
const isCommon = (aIndex2, bIndex2) => aLines[aIndex2] === bLines[bIndex2];
|
|
8529
8547
|
const diffs = [];
|
|
8530
8548
|
let aIndex = 0;
|
|
@@ -8543,7 +8561,7 @@ function diffLinesRaw(aLines, bLines) {
|
|
|
8543
8561
|
diffs.push(new Diff(DIFF_DELETE, aLines[aIndex]));
|
|
8544
8562
|
for (; bIndex !== bLength; bIndex += 1)
|
|
8545
8563
|
diffs.push(new Diff(DIFF_INSERT, bLines[bIndex]));
|
|
8546
|
-
return diffs;
|
|
8564
|
+
return [diffs, truncated];
|
|
8547
8565
|
}
|
|
8548
8566
|
function getCommonMessage(message, options) {
|
|
8549
8567
|
const { commonColor } = normalizeDiffOptions(options);
|
|
@@ -8713,6 +8731,8 @@ function serializeError(val, seen = /* @__PURE__ */ new WeakMap()) {
|
|
|
8713
8731
|
return val.tagName;
|
|
8714
8732
|
if (typeof val.asymmetricMatch === "function")
|
|
8715
8733
|
return `${val.toString()} ${format(val.sample)}`;
|
|
8734
|
+
if (typeof val.toJSON === "function")
|
|
8735
|
+
return val.toJSON();
|
|
8716
8736
|
if (seen.has(val))
|
|
8717
8737
|
return seen.get(val);
|
|
8718
8738
|
if (Array.isArray(val)) {
|
|
@@ -9445,8 +9465,8 @@ var collectorContext = {
|
|
|
9445
9465
|
currentSuite: null
|
|
9446
9466
|
};
|
|
9447
9467
|
function collectTask(task) {
|
|
9448
|
-
var
|
|
9449
|
-
(
|
|
9468
|
+
var _a;
|
|
9469
|
+
(_a = collectorContext.currentSuite) == null ? void 0 : _a.tasks.push(task);
|
|
9450
9470
|
}
|
|
9451
9471
|
async function runWithSuite(suite2, fn2) {
|
|
9452
9472
|
const prev = collectorContext.currentSuite;
|
|
@@ -9460,17 +9480,17 @@ function withTimeout(fn2, timeout, isHook = false) {
|
|
|
9460
9480
|
const { setTimeout, clearTimeout } = getSafeTimers();
|
|
9461
9481
|
return (...args) => {
|
|
9462
9482
|
return Promise.race([fn2(...args), new Promise((resolve3, reject) => {
|
|
9463
|
-
var
|
|
9483
|
+
var _a;
|
|
9464
9484
|
const timer = setTimeout(() => {
|
|
9465
9485
|
clearTimeout(timer);
|
|
9466
9486
|
reject(new Error(makeTimeoutMsg(isHook, timeout)));
|
|
9467
9487
|
}, timeout);
|
|
9468
|
-
(
|
|
9488
|
+
(_a = timer.unref) == null ? void 0 : _a.call(timer);
|
|
9469
9489
|
})]);
|
|
9470
9490
|
};
|
|
9471
9491
|
}
|
|
9472
9492
|
function createTestContext(test3, runner2) {
|
|
9473
|
-
var
|
|
9493
|
+
var _a;
|
|
9474
9494
|
const context = function() {
|
|
9475
9495
|
throw new Error("done() callback is deprecated, use promise instead");
|
|
9476
9496
|
};
|
|
@@ -9487,7 +9507,7 @@ function createTestContext(test3, runner2) {
|
|
|
9487
9507
|
test3.onFinished || (test3.onFinished = []);
|
|
9488
9508
|
test3.onFinished.push(fn2);
|
|
9489
9509
|
};
|
|
9490
|
-
return ((
|
|
9510
|
+
return ((_a = runner2.extendTaskContext) == null ? void 0 : _a.call(runner2, context)) || context;
|
|
9491
9511
|
}
|
|
9492
9512
|
function makeTimeoutMsg(isHook, timeout) {
|
|
9493
9513
|
return `${isHook ? "Hook" : "Test"} timed out in ${timeout}ms.
|
|
@@ -9733,10 +9753,10 @@ function createSuiteCollector(name, factory = () => {
|
|
|
9733
9753
|
}
|
|
9734
9754
|
if (runner.config.includeTaskLocation) {
|
|
9735
9755
|
const limit = Error.stackTraceLimit;
|
|
9736
|
-
Error.stackTraceLimit =
|
|
9756
|
+
Error.stackTraceLimit = 15;
|
|
9737
9757
|
const error = new Error("stacktrace").stack;
|
|
9738
9758
|
Error.stackTraceLimit = limit;
|
|
9739
|
-
const stack =
|
|
9759
|
+
const stack = findTestFileStackTrace(error, task2.each ?? false);
|
|
9740
9760
|
if (stack)
|
|
9741
9761
|
task2.location = stack;
|
|
9742
9762
|
}
|
|
@@ -9789,18 +9809,12 @@ function createSuiteCollector(name, factory = () => {
|
|
|
9789
9809
|
};
|
|
9790
9810
|
if (runner && includeLocation && runner.config.includeTaskLocation) {
|
|
9791
9811
|
const limit = Error.stackTraceLimit;
|
|
9792
|
-
Error.stackTraceLimit =
|
|
9812
|
+
Error.stackTraceLimit = 15;
|
|
9793
9813
|
const error = new Error("stacktrace").stack;
|
|
9794
9814
|
Error.stackTraceLimit = limit;
|
|
9795
|
-
const stack =
|
|
9796
|
-
if (stack)
|
|
9797
|
-
suite2.location =
|
|
9798
|
-
line: stack.line,
|
|
9799
|
-
// because source map is boundary based, this line leads to ")" in test.each()[(]),
|
|
9800
|
-
// but it should be the next opening bracket - here we assume it's on the same line
|
|
9801
|
-
column: each ? stack.column + 1 : stack.column
|
|
9802
|
-
};
|
|
9803
|
-
}
|
|
9815
|
+
const stack = findTestFileStackTrace(error, suite2.each ?? false);
|
|
9816
|
+
if (stack)
|
|
9817
|
+
suite2.location = stack;
|
|
9804
9818
|
}
|
|
9805
9819
|
setHooks(suite2, createSuiteHooks());
|
|
9806
9820
|
}
|
|
@@ -9854,9 +9868,14 @@ function createSuite() {
|
|
|
9854
9868
|
optionsOrFn,
|
|
9855
9869
|
fnOrOptions
|
|
9856
9870
|
);
|
|
9871
|
+
const fnFirst = typeof optionsOrFn === "function";
|
|
9857
9872
|
cases.forEach((i2, idx) => {
|
|
9858
9873
|
const items = Array.isArray(i2) ? i2 : [i2];
|
|
9859
|
-
|
|
9874
|
+
if (fnFirst) {
|
|
9875
|
+
arrayOnlyCases ? suite2(formatTitle(_name, items, idx), () => handler(...items), options) : suite2(formatTitle(_name, items, idx), () => handler(i2), options);
|
|
9876
|
+
} else {
|
|
9877
|
+
arrayOnlyCases ? suite2(formatTitle(_name, items, idx), options, () => handler(...items)) : suite2(formatTitle(_name, items, idx), options, () => handler(i2));
|
|
9878
|
+
}
|
|
9860
9879
|
});
|
|
9861
9880
|
this.setContext("each", void 0);
|
|
9862
9881
|
};
|
|
@@ -9882,9 +9901,14 @@ function createTaskCollector(fn2, context) {
|
|
|
9882
9901
|
optionsOrFn,
|
|
9883
9902
|
fnOrOptions
|
|
9884
9903
|
);
|
|
9904
|
+
const fnFirst = typeof optionsOrFn === "function";
|
|
9885
9905
|
cases.forEach((i2, idx) => {
|
|
9886
9906
|
const items = Array.isArray(i2) ? i2 : [i2];
|
|
9887
|
-
|
|
9907
|
+
if (fnFirst) {
|
|
9908
|
+
arrayOnlyCases ? test22(formatTitle(_name, items, idx), () => handler(...items), options) : test22(formatTitle(_name, items, idx), () => handler(i2), options);
|
|
9909
|
+
} else {
|
|
9910
|
+
arrayOnlyCases ? test22(formatTitle(_name, items, idx), options, () => handler(...items)) : test22(formatTitle(_name, items, idx), options, () => handler(i2));
|
|
9911
|
+
}
|
|
9888
9912
|
});
|
|
9889
9913
|
this.setContext("each", void 0);
|
|
9890
9914
|
};
|
|
@@ -9926,8 +9950,8 @@ function formatTitle(template, items, idx) {
|
|
|
9926
9950
|
/\$([$\w_.]+)/g,
|
|
9927
9951
|
// https://github.com/chaijs/chai/pull/1490
|
|
9928
9952
|
(_, key) => {
|
|
9929
|
-
var
|
|
9930
|
-
return objDisplay(objectAttr(items[0], key), { truncate: (_b = (
|
|
9953
|
+
var _a, _b;
|
|
9954
|
+
return objDisplay(objectAttr(items[0], key), { truncate: (_b = (_a = runner == null ? void 0 : runner.config) == null ? void 0 : _a.chaiConfig) == null ? void 0 : _b.truncateThreshold });
|
|
9931
9955
|
}
|
|
9932
9956
|
);
|
|
9933
9957
|
}
|
|
@@ -9944,8 +9968,8 @@ function formatTemplateString(cases, args) {
|
|
|
9944
9968
|
}
|
|
9945
9969
|
return res;
|
|
9946
9970
|
}
|
|
9947
|
-
function
|
|
9948
|
-
const lines = error.split("\n").slice(
|
|
9971
|
+
function findTestFileStackTrace(error, each) {
|
|
9972
|
+
const lines = error.split("\n").slice(1);
|
|
9949
9973
|
for (const line of lines) {
|
|
9950
9974
|
const stack = parseSingleStack(line);
|
|
9951
9975
|
if (stack && stack.file === getTestFilepath()) {
|
|
@@ -9996,13 +10020,13 @@ function createTestHook(name, handler) {
|
|
|
9996
10020
|
};
|
|
9997
10021
|
}
|
|
9998
10022
|
|
|
9999
|
-
// ../../node_modules/vitest/dist/vendor/benchmark.
|
|
10023
|
+
// ../../node_modules/vitest/dist/vendor/benchmark.yGkUTKnC.js
|
|
10000
10024
|
init_cjs_shims();
|
|
10001
10025
|
|
|
10002
10026
|
// ../../node_modules/@vitest/runner/dist/utils.js
|
|
10003
10027
|
init_cjs_shims();
|
|
10004
10028
|
|
|
10005
|
-
// ../../node_modules/vitest/dist/vendor/index.
|
|
10029
|
+
// ../../node_modules/vitest/dist/vendor/index.SMVOaj7F.js
|
|
10006
10030
|
init_cjs_shims();
|
|
10007
10031
|
|
|
10008
10032
|
// ../../node_modules/vitest/dist/vendor/global.CkGT_TMy.js
|
|
@@ -10020,10 +10044,7 @@ function getCurrentEnvironment() {
|
|
|
10020
10044
|
return state == null ? void 0 : state.environment.name;
|
|
10021
10045
|
}
|
|
10022
10046
|
|
|
10023
|
-
// ../../node_modules/vitest/dist/vendor/index.
|
|
10024
|
-
var _a;
|
|
10025
|
-
var isNode = typeof process < "u" && typeof process.stdout < "u" && !((_a = process.versions) == null ? void 0 : _a.deno) && !globalThis.window;
|
|
10026
|
-
var isWindows = isNode && process.platform === "win32";
|
|
10047
|
+
// ../../node_modules/vitest/dist/vendor/index.SMVOaj7F.js
|
|
10027
10048
|
function getRunMode() {
|
|
10028
10049
|
return getWorkerState().config.mode;
|
|
10029
10050
|
}
|
|
@@ -10031,7 +10052,7 @@ function isRunningInBenchmark() {
|
|
|
10031
10052
|
return getRunMode() === "benchmark";
|
|
10032
10053
|
}
|
|
10033
10054
|
|
|
10034
|
-
// ../../node_modules/vitest/dist/vendor/benchmark.
|
|
10055
|
+
// ../../node_modules/vitest/dist/vendor/benchmark.yGkUTKnC.js
|
|
10035
10056
|
var benchFns = /* @__PURE__ */ new WeakMap();
|
|
10036
10057
|
var benchOptsMap = /* @__PURE__ */ new WeakMap();
|
|
10037
10058
|
var bench = createBenchmark(
|
|
@@ -10084,7 +10105,7 @@ function isFirstRun() {
|
|
|
10084
10105
|
return firstRun;
|
|
10085
10106
|
}
|
|
10086
10107
|
|
|
10087
|
-
// ../../node_modules/vitest/dist/vendor/vi.
|
|
10108
|
+
// ../../node_modules/vitest/dist/vendor/vi.YFlodzP_.js
|
|
10088
10109
|
init_cjs_shims();
|
|
10089
10110
|
|
|
10090
10111
|
// ../../node_modules/chai/index.mjs
|
|
@@ -10612,7 +10633,7 @@ function iterableEquality(a, b2, customTesters = [], aStack = [], bStack = []) {
|
|
|
10612
10633
|
return iterableEquality(
|
|
10613
10634
|
a2,
|
|
10614
10635
|
b22,
|
|
10615
|
-
[...
|
|
10636
|
+
[...customTesters],
|
|
10616
10637
|
[...aStack],
|
|
10617
10638
|
[...bStack]
|
|
10618
10639
|
);
|
|
@@ -10671,6 +10692,10 @@ function iterableEquality(a, b2, customTesters = [], aStack = [], bStack = []) {
|
|
|
10671
10692
|
}
|
|
10672
10693
|
if (!bIterator.next().done)
|
|
10673
10694
|
return false;
|
|
10695
|
+
const aEntries = Object.entries(a);
|
|
10696
|
+
const bEntries = Object.entries(b2);
|
|
10697
|
+
if (!equals(aEntries, bEntries))
|
|
10698
|
+
return false;
|
|
10674
10699
|
aStack.pop();
|
|
10675
10700
|
bStack.pop();
|
|
10676
10701
|
return true;
|
|
@@ -10690,7 +10715,7 @@ function subsetEquality(object2, subset, customTesters = []) {
|
|
|
10690
10715
|
if (!isObjectWithKeys(subset2))
|
|
10691
10716
|
return void 0;
|
|
10692
10717
|
return Object.keys(subset2).every((key) => {
|
|
10693
|
-
if (
|
|
10718
|
+
if (subset2[key] != null && typeof subset2[key] === "object") {
|
|
10694
10719
|
if (seenReferences.has(subset2[key]))
|
|
10695
10720
|
return equals(object22[key], subset2[key], filteredCustomTesters);
|
|
10696
10721
|
seenReferences.set(subset2[key], true);
|
|
@@ -10754,6 +10779,57 @@ Received: serializes to the same string
|
|
|
10754
10779
|
function pluralize(word, count) {
|
|
10755
10780
|
return `${count} ${word}${count === 1 ? "" : "s"}`;
|
|
10756
10781
|
}
|
|
10782
|
+
function getObjectKeys(object2) {
|
|
10783
|
+
return [
|
|
10784
|
+
...Object.keys(object2),
|
|
10785
|
+
...Object.getOwnPropertySymbols(object2).filter(
|
|
10786
|
+
(s) => {
|
|
10787
|
+
var _a;
|
|
10788
|
+
return (_a = Object.getOwnPropertyDescriptor(object2, s)) == null ? void 0 : _a.enumerable;
|
|
10789
|
+
}
|
|
10790
|
+
)
|
|
10791
|
+
];
|
|
10792
|
+
}
|
|
10793
|
+
function getObjectSubset(object2, subset, customTesters = []) {
|
|
10794
|
+
let stripped = 0;
|
|
10795
|
+
const getObjectSubsetWithContext = (seenReferences = /* @__PURE__ */ new WeakMap()) => (object22, subset2) => {
|
|
10796
|
+
if (Array.isArray(object22)) {
|
|
10797
|
+
if (Array.isArray(subset2) && subset2.length === object22.length) {
|
|
10798
|
+
return subset2.map(
|
|
10799
|
+
(sub, i2) => getObjectSubsetWithContext(seenReferences)(object22[i2], sub)
|
|
10800
|
+
);
|
|
10801
|
+
}
|
|
10802
|
+
} else if (object22 instanceof Date) {
|
|
10803
|
+
return object22;
|
|
10804
|
+
} else if (isObject(object22) && isObject(subset2)) {
|
|
10805
|
+
if (equals(object22, subset2, [
|
|
10806
|
+
...customTesters,
|
|
10807
|
+
iterableEquality,
|
|
10808
|
+
subsetEquality
|
|
10809
|
+
])) {
|
|
10810
|
+
return subset2;
|
|
10811
|
+
}
|
|
10812
|
+
const trimmed = {};
|
|
10813
|
+
seenReferences.set(object22, trimmed);
|
|
10814
|
+
for (const key of getObjectKeys(object22)) {
|
|
10815
|
+
if (hasPropertyInObject(subset2, key)) {
|
|
10816
|
+
trimmed[key] = seenReferences.has(object22[key]) ? seenReferences.get(object22[key]) : getObjectSubsetWithContext(seenReferences)(object22[key], subset2[key]);
|
|
10817
|
+
} else {
|
|
10818
|
+
if (!seenReferences.has(object22[key])) {
|
|
10819
|
+
stripped += 1;
|
|
10820
|
+
if (isObject(object22[key]))
|
|
10821
|
+
stripped += getObjectKeys(object22[key]).length;
|
|
10822
|
+
getObjectSubsetWithContext(seenReferences)(object22[key], subset2[key]);
|
|
10823
|
+
}
|
|
10824
|
+
}
|
|
10825
|
+
}
|
|
10826
|
+
if (getObjectKeys(trimmed).length > 0)
|
|
10827
|
+
return trimmed;
|
|
10828
|
+
}
|
|
10829
|
+
return object22;
|
|
10830
|
+
};
|
|
10831
|
+
return { subset: getObjectSubsetWithContext()(object2, subset), stripped };
|
|
10832
|
+
}
|
|
10757
10833
|
var AsymmetricMatcher3 = class {
|
|
10758
10834
|
constructor(sample, inverse = false) {
|
|
10759
10835
|
this.sample = sample;
|
|
@@ -11044,7 +11120,7 @@ function recordAsyncExpect(test3, promise) {
|
|
|
11044
11120
|
}
|
|
11045
11121
|
function wrapSoft(utils, fn2) {
|
|
11046
11122
|
return function(...args) {
|
|
11047
|
-
var
|
|
11123
|
+
var _a;
|
|
11048
11124
|
const test3 = utils.flag(this, "vitest-test");
|
|
11049
11125
|
const state = (test3 == null ? void 0 : test3.context._local) ? test3.context.expect.getState() : getState(globalThis[GLOBAL_EXPECT]);
|
|
11050
11126
|
if (!state.soft)
|
|
@@ -11056,7 +11132,7 @@ function wrapSoft(utils, fn2) {
|
|
|
11056
11132
|
} catch (err) {
|
|
11057
11133
|
test3.result || (test3.result = { state: "fail" });
|
|
11058
11134
|
test3.result.state = "fail";
|
|
11059
|
-
(
|
|
11135
|
+
(_a = test3.result).errors || (_a.errors = []);
|
|
11060
11136
|
test3.result.errors.push(processError(err));
|
|
11061
11137
|
}
|
|
11062
11138
|
};
|
|
@@ -11181,16 +11257,30 @@ var JestChaiExpect = (chai3, utils) => {
|
|
|
11181
11257
|
});
|
|
11182
11258
|
def("toMatchObject", function(expected) {
|
|
11183
11259
|
const actual = this._obj;
|
|
11184
|
-
|
|
11185
|
-
|
|
11186
|
-
|
|
11187
|
-
|
|
11188
|
-
|
|
11189
|
-
|
|
11190
|
-
|
|
11260
|
+
const pass = equals(actual, expected, [...customTesters, iterableEquality, subsetEquality]);
|
|
11261
|
+
const isNot = utils.flag(this, "negate");
|
|
11262
|
+
const { subset: actualSubset, stripped } = getObjectSubset(actual, expected);
|
|
11263
|
+
if (pass && isNot || !pass && !isNot) {
|
|
11264
|
+
const msg = utils.getMessage(
|
|
11265
|
+
this,
|
|
11266
|
+
[
|
|
11267
|
+
pass,
|
|
11268
|
+
"expected #{this} to match object #{exp}",
|
|
11269
|
+
"expected #{this} to not match object #{exp}",
|
|
11270
|
+
expected,
|
|
11271
|
+
actualSubset,
|
|
11272
|
+
false
|
|
11273
|
+
]
|
|
11274
|
+
);
|
|
11275
|
+
const message = stripped === 0 ? msg : `${msg}
|
|
11276
|
+
(${stripped} matching ${stripped === 1 ? "property" : "properties"} omitted from actual)`;
|
|
11277
|
+
throw new AssertionError2(message, { showDiff: true, expected, actual: actualSubset });
|
|
11278
|
+
}
|
|
11191
11279
|
});
|
|
11192
11280
|
def("toMatch", function(expected) {
|
|
11193
11281
|
const actual = this._obj;
|
|
11282
|
+
if (typeof actual !== "string")
|
|
11283
|
+
throw new TypeError(`.toMatch() expects to receive a string, but got ${typeof actual}`);
|
|
11194
11284
|
return this.assert(
|
|
11195
11285
|
typeof expected === "string" ? actual.includes(expected) : actual.match(expected),
|
|
11196
11286
|
`expected #{this} to match #{exp}`,
|
|
@@ -11532,12 +11622,15 @@ Number of calls: ${c2().bold(spy.mock.calls.length)}
|
|
|
11532
11622
|
const spy = getSpy(this);
|
|
11533
11623
|
const spyName = spy.getMockName();
|
|
11534
11624
|
const nthCall = spy.mock.calls[times - 1];
|
|
11625
|
+
const callCount = spy.mock.calls.length;
|
|
11626
|
+
const isCalled = times <= callCount;
|
|
11535
11627
|
this.assert(
|
|
11536
11628
|
equals(nthCall, args, [...customTesters, iterableEquality]),
|
|
11537
|
-
`expected ${ordinalOf(times)} "${spyName}" call to have been called with #{exp}`,
|
|
11629
|
+
`expected ${ordinalOf(times)} "${spyName}" call to have been called with #{exp}${isCalled ? `` : `, but called only ${callCount} times`}`,
|
|
11538
11630
|
`expected ${ordinalOf(times)} "${spyName}" call to not have been called with #{exp}`,
|
|
11539
11631
|
args,
|
|
11540
|
-
nthCall
|
|
11632
|
+
nthCall,
|
|
11633
|
+
isCalled
|
|
11541
11634
|
);
|
|
11542
11635
|
});
|
|
11543
11636
|
def(["toHaveBeenLastCalledWith", "lastCalledWith"], function(...args) {
|
|
@@ -12159,9 +12252,9 @@ ${snapshots.join("\n\n")}
|
|
|
12159
12252
|
}
|
|
12160
12253
|
function prepareExpected(expected) {
|
|
12161
12254
|
function findStartIndent() {
|
|
12162
|
-
var
|
|
12255
|
+
var _a, _b;
|
|
12163
12256
|
const matchObject = /^( +)}\s+$/m.exec(expected || "");
|
|
12164
|
-
const objectIndent = (
|
|
12257
|
+
const objectIndent = (_a = matchObject == null ? void 0 : matchObject[1]) == null ? void 0 : _a.length;
|
|
12165
12258
|
if (objectIndent)
|
|
12166
12259
|
return objectIndent;
|
|
12167
12260
|
const matchText = /^\n( +)"/.exec(expected || "");
|
|
@@ -12728,8 +12821,8 @@ function parseStacktrace(stack, options = {}) {
|
|
|
12728
12821
|
if (ignoreStackEntries.length)
|
|
12729
12822
|
stacks = stacks.filter((stack2) => !ignoreStackEntries.some((p) => stack2.file.match(p)));
|
|
12730
12823
|
return stacks.map((stack2) => {
|
|
12731
|
-
var
|
|
12732
|
-
const map2 = (
|
|
12824
|
+
var _a;
|
|
12825
|
+
const map2 = (_a = options.getSourceMap) == null ? void 0 : _a.call(options, stack2.file);
|
|
12733
12826
|
if (!map2 || typeof map2 !== "object" || !map2.version)
|
|
12734
12827
|
return stack2;
|
|
12735
12828
|
const traceMap = new TraceMap(map2);
|
|
@@ -13141,10 +13234,10 @@ var SnapshotClient = class {
|
|
|
13141
13234
|
snapshotState;
|
|
13142
13235
|
snapshotStateMap = /* @__PURE__ */ new Map();
|
|
13143
13236
|
async startCurrentRun(filepath, name, options) {
|
|
13144
|
-
var
|
|
13237
|
+
var _a;
|
|
13145
13238
|
this.filepath = filepath;
|
|
13146
13239
|
this.name = name;
|
|
13147
|
-
if (((
|
|
13240
|
+
if (((_a = this.snapshotState) == null ? void 0 : _a.testFilePath) !== filepath) {
|
|
13148
13241
|
await this.finishCurrentRun();
|
|
13149
13242
|
if (!this.getSnapshotState(filepath)) {
|
|
13150
13243
|
this.snapshotStateMap.set(
|
|
@@ -13166,11 +13259,11 @@ var SnapshotClient = class {
|
|
|
13166
13259
|
this.name = void 0;
|
|
13167
13260
|
}
|
|
13168
13261
|
skipTestSnapshots(name) {
|
|
13169
|
-
var
|
|
13170
|
-
(
|
|
13262
|
+
var _a;
|
|
13263
|
+
(_a = this.snapshotState) == null ? void 0 : _a.markSnapshotsAsCheckedForTest(name);
|
|
13171
13264
|
}
|
|
13172
13265
|
assert(options) {
|
|
13173
|
-
var
|
|
13266
|
+
var _a, _b, _c, _d;
|
|
13174
13267
|
const {
|
|
13175
13268
|
filepath = this.filepath,
|
|
13176
13269
|
name = this.name,
|
|
@@ -13189,7 +13282,7 @@ var SnapshotClient = class {
|
|
|
13189
13282
|
if (typeof received !== "object" || !received)
|
|
13190
13283
|
throw new Error("Received value must be an object when the matcher has properties");
|
|
13191
13284
|
try {
|
|
13192
|
-
const pass2 = ((_b = (
|
|
13285
|
+
const pass2 = ((_b = (_a = this.options).isEqual) == null ? void 0 : _b.call(_a, received, properties)) ?? false;
|
|
13193
13286
|
if (!pass2)
|
|
13194
13287
|
throw createMismatchError("Snapshot properties mismatched", (_c = this.snapshotState) == null ? void 0 : _c.expand, received, properties);
|
|
13195
13288
|
else
|
|
@@ -13250,7 +13343,7 @@ function getFullName(task, separator = " > ") {
|
|
|
13250
13343
|
return getNames(task).join(separator);
|
|
13251
13344
|
}
|
|
13252
13345
|
|
|
13253
|
-
// ../../node_modules/vitest/dist/vendor/base.
|
|
13346
|
+
// ../../node_modules/vitest/dist/vendor/base.5NT-gWu5.js
|
|
13254
13347
|
init_cjs_shims();
|
|
13255
13348
|
function isChildProcess() {
|
|
13256
13349
|
return typeof process !== "undefined" && !!process.send;
|
|
@@ -13308,7 +13401,7 @@ function resetDate() {
|
|
|
13308
13401
|
globalThis.Date = RealDate;
|
|
13309
13402
|
}
|
|
13310
13403
|
|
|
13311
|
-
// ../../node_modules/vitest/dist/vendor/vi.
|
|
13404
|
+
// ../../node_modules/vitest/dist/vendor/vi.YFlodzP_.js
|
|
13312
13405
|
function resetModules(modules, resetMocks = false) {
|
|
13313
13406
|
const skipPaths = [
|
|
13314
13407
|
// Vitest
|
|
@@ -13489,11 +13582,11 @@ function getError(expected, promise) {
|
|
|
13489
13582
|
}
|
|
13490
13583
|
var SnapshotPlugin = (chai3, utils) => {
|
|
13491
13584
|
const getTestNames = (test3) => {
|
|
13492
|
-
var
|
|
13585
|
+
var _a;
|
|
13493
13586
|
if (!test3)
|
|
13494
13587
|
return {};
|
|
13495
13588
|
return {
|
|
13496
|
-
filepath: (
|
|
13589
|
+
filepath: (_a = test3.file) == null ? void 0 : _a.filepath,
|
|
13497
13590
|
name: getNames(test3).slice(1).join(" > ")
|
|
13498
13591
|
};
|
|
13499
13592
|
};
|
|
@@ -13550,12 +13643,12 @@ var SnapshotPlugin = (chai3, utils) => {
|
|
|
13550
13643
|
chai3.Assertion.prototype,
|
|
13551
13644
|
"toMatchInlineSnapshot",
|
|
13552
13645
|
function __INLINE_SNAPSHOT__(properties, inlineSnapshot, message) {
|
|
13553
|
-
var
|
|
13646
|
+
var _a;
|
|
13554
13647
|
const isNot = utils.flag(this, "negate");
|
|
13555
13648
|
if (isNot)
|
|
13556
13649
|
throw new Error('toMatchInlineSnapshot cannot be used with "not"');
|
|
13557
13650
|
const test3 = utils.flag(this, "vitest-test");
|
|
13558
|
-
const isInsideEach = test3 && (test3.each || ((
|
|
13651
|
+
const isInsideEach = test3 && (test3.each || ((_a = test3.suite) == null ? void 0 : _a.each));
|
|
13559
13652
|
if (isInsideEach)
|
|
13560
13653
|
throw new Error("InlineSnapshot cannot be used inside of test.each or describe.each");
|
|
13561
13654
|
const expected = utils.flag(this, "object");
|
|
@@ -13603,12 +13696,12 @@ var SnapshotPlugin = (chai3, utils) => {
|
|
|
13603
13696
|
chai3.Assertion.prototype,
|
|
13604
13697
|
"toThrowErrorMatchingInlineSnapshot",
|
|
13605
13698
|
function __INLINE_SNAPSHOT__(inlineSnapshot, message) {
|
|
13606
|
-
var
|
|
13699
|
+
var _a;
|
|
13607
13700
|
const isNot = utils.flag(this, "negate");
|
|
13608
13701
|
if (isNot)
|
|
13609
13702
|
throw new Error('toThrowErrorMatchingInlineSnapshot cannot be used with "not"');
|
|
13610
13703
|
const test3 = utils.flag(this, "vitest-test");
|
|
13611
|
-
const isInsideEach = test3 && (test3.each || ((
|
|
13704
|
+
const isInsideEach = test3 && (test3.each || ((_a = test3.suite) == null ? void 0 : _a.each));
|
|
13612
13705
|
if (isInsideEach)
|
|
13613
13706
|
throw new Error("InlineSnapshot cannot be used inside of test.each or describe.each");
|
|
13614
13707
|
const expected = utils.flag(this, "object");
|
|
@@ -13640,7 +13733,7 @@ use(Subset);
|
|
|
13640
13733
|
use(SnapshotPlugin);
|
|
13641
13734
|
use(JestAsymmetricMatchers);
|
|
13642
13735
|
function createExpect(test3) {
|
|
13643
|
-
var
|
|
13736
|
+
var _a;
|
|
13644
13737
|
const expect2 = (value, message) => {
|
|
13645
13738
|
const { assertionCalls } = getState(expect2);
|
|
13646
13739
|
setState({ assertionCalls: assertionCalls + 1, soft: false }, expect2);
|
|
@@ -13665,7 +13758,7 @@ function createExpect(test3) {
|
|
|
13665
13758
|
expectedAssertionsNumber: null,
|
|
13666
13759
|
expectedAssertionsNumberErrorGen: null,
|
|
13667
13760
|
environment: getCurrentEnvironment(),
|
|
13668
|
-
testPath: test3 ? (
|
|
13761
|
+
testPath: test3 ? (_a = test3.suite.file) == null ? void 0 : _a.filepath : globalState.testPath,
|
|
13669
13762
|
currentTestName: test3 ? getFullName(test3) : globalState.currentTestName
|
|
13670
13763
|
}, expect2);
|
|
13671
13764
|
expect2.extend = (matchers) => expect.extend(expect2, matchers);
|
|
@@ -15240,7 +15333,7 @@ var FakeTimers = class {
|
|
|
15240
15333
|
}
|
|
15241
15334
|
}
|
|
15242
15335
|
useFakeTimers() {
|
|
15243
|
-
var
|
|
15336
|
+
var _a, _b, _c;
|
|
15244
15337
|
if (this._fakingDate) {
|
|
15245
15338
|
throw new Error(
|
|
15246
15339
|
'"setSystemTime" was called already and date was mocked. Reset timers using `vi.useRealTimers()` if you want to use fake timers again.'
|
|
@@ -15248,7 +15341,7 @@ var FakeTimers = class {
|
|
|
15248
15341
|
}
|
|
15249
15342
|
if (!this._fakingTime) {
|
|
15250
15343
|
const toFake = Object.keys(this._fakeTimers.timers).filter((timer) => timer !== "nextTick");
|
|
15251
|
-
if (((_b = (
|
|
15344
|
+
if (((_b = (_a = this._userConfig) == null ? void 0 : _a.toFake) == null ? void 0 : _b.includes("nextTick")) && isChildProcess())
|
|
15252
15345
|
throw new Error("process.nextTick cannot be mocked inside child_process");
|
|
15253
15346
|
const existingFakedMethods = (((_c = this._userConfig) == null ? void 0 : _c.toFake) || toFake).filter((method) => {
|
|
15254
15347
|
switch (method) {
|
|
@@ -15433,12 +15526,14 @@ function createVitest() {
|
|
|
15433
15526
|
let _mockedDate = null;
|
|
15434
15527
|
let _config = null;
|
|
15435
15528
|
const workerState = getWorkerState();
|
|
15436
|
-
|
|
15529
|
+
let _timers;
|
|
15530
|
+
const timers = () => _timers || (_timers = new FakeTimers({
|
|
15437
15531
|
global: globalThis,
|
|
15438
15532
|
config: workerState.config.fakeTimers
|
|
15439
|
-
});
|
|
15533
|
+
}));
|
|
15440
15534
|
const _stubsGlobal = /* @__PURE__ */ new Map();
|
|
15441
15535
|
const _stubsEnv = /* @__PURE__ */ new Map();
|
|
15536
|
+
const _envBooleans = ["PROD", "DEV", "SSR"];
|
|
15442
15537
|
const getImporter = () => {
|
|
15443
15538
|
const stackTrace = createSimpleStackTrace({ stackTraceLimit: 4 });
|
|
15444
15539
|
const importerStack = stackTrace.split("\n")[4];
|
|
@@ -15447,82 +15542,82 @@ function createVitest() {
|
|
|
15447
15542
|
};
|
|
15448
15543
|
const utils = {
|
|
15449
15544
|
useFakeTimers(config2) {
|
|
15450
|
-
var
|
|
15545
|
+
var _a, _b, _c, _d;
|
|
15451
15546
|
if (isChildProcess()) {
|
|
15452
|
-
if (((
|
|
15547
|
+
if (((_a = config2 == null ? void 0 : config2.toFake) == null ? void 0 : _a.includes("nextTick")) || ((_d = (_c = (_b = workerState.config) == null ? void 0 : _b.fakeTimers) == null ? void 0 : _c.toFake) == null ? void 0 : _d.includes("nextTick"))) {
|
|
15453
15548
|
throw new Error(
|
|
15454
15549
|
'vi.useFakeTimers({ toFake: ["nextTick"] }) is not supported in node:child_process. Use --pool=threads if mocking nextTick is required.'
|
|
15455
15550
|
);
|
|
15456
15551
|
}
|
|
15457
15552
|
}
|
|
15458
15553
|
if (config2)
|
|
15459
|
-
|
|
15554
|
+
timers().configure({ ...workerState.config.fakeTimers, ...config2 });
|
|
15460
15555
|
else
|
|
15461
|
-
|
|
15462
|
-
|
|
15556
|
+
timers().configure(workerState.config.fakeTimers);
|
|
15557
|
+
timers().useFakeTimers();
|
|
15463
15558
|
return utils;
|
|
15464
15559
|
},
|
|
15465
15560
|
isFakeTimers() {
|
|
15466
|
-
return
|
|
15561
|
+
return timers().isFakeTimers();
|
|
15467
15562
|
},
|
|
15468
15563
|
useRealTimers() {
|
|
15469
|
-
|
|
15564
|
+
timers().useRealTimers();
|
|
15470
15565
|
_mockedDate = null;
|
|
15471
15566
|
return utils;
|
|
15472
15567
|
},
|
|
15473
15568
|
runOnlyPendingTimers() {
|
|
15474
|
-
|
|
15569
|
+
timers().runOnlyPendingTimers();
|
|
15475
15570
|
return utils;
|
|
15476
15571
|
},
|
|
15477
15572
|
async runOnlyPendingTimersAsync() {
|
|
15478
|
-
await
|
|
15573
|
+
await timers().runOnlyPendingTimersAsync();
|
|
15479
15574
|
return utils;
|
|
15480
15575
|
},
|
|
15481
15576
|
runAllTimers() {
|
|
15482
|
-
|
|
15577
|
+
timers().runAllTimers();
|
|
15483
15578
|
return utils;
|
|
15484
15579
|
},
|
|
15485
15580
|
async runAllTimersAsync() {
|
|
15486
|
-
await
|
|
15581
|
+
await timers().runAllTimersAsync();
|
|
15487
15582
|
return utils;
|
|
15488
15583
|
},
|
|
15489
15584
|
runAllTicks() {
|
|
15490
|
-
|
|
15585
|
+
timers().runAllTicks();
|
|
15491
15586
|
return utils;
|
|
15492
15587
|
},
|
|
15493
15588
|
advanceTimersByTime(ms) {
|
|
15494
|
-
|
|
15589
|
+
timers().advanceTimersByTime(ms);
|
|
15495
15590
|
return utils;
|
|
15496
15591
|
},
|
|
15497
15592
|
async advanceTimersByTimeAsync(ms) {
|
|
15498
|
-
await
|
|
15593
|
+
await timers().advanceTimersByTimeAsync(ms);
|
|
15499
15594
|
return utils;
|
|
15500
15595
|
},
|
|
15501
15596
|
advanceTimersToNextTimer() {
|
|
15502
|
-
|
|
15597
|
+
timers().advanceTimersToNextTimer();
|
|
15503
15598
|
return utils;
|
|
15504
15599
|
},
|
|
15505
15600
|
async advanceTimersToNextTimerAsync() {
|
|
15506
|
-
await
|
|
15601
|
+
await timers().advanceTimersToNextTimerAsync();
|
|
15507
15602
|
return utils;
|
|
15508
15603
|
},
|
|
15509
15604
|
getTimerCount() {
|
|
15510
|
-
return
|
|
15605
|
+
return timers().getTimerCount();
|
|
15511
15606
|
},
|
|
15512
15607
|
setSystemTime(time) {
|
|
15513
15608
|
const date = time instanceof Date ? time : new Date(time);
|
|
15514
15609
|
_mockedDate = date;
|
|
15515
|
-
|
|
15610
|
+
timers().setSystemTime(date);
|
|
15516
15611
|
return utils;
|
|
15517
15612
|
},
|
|
15518
15613
|
getMockedSystemTime() {
|
|
15519
15614
|
return _mockedDate;
|
|
15520
15615
|
},
|
|
15521
15616
|
getRealSystemTime() {
|
|
15522
|
-
return
|
|
15617
|
+
return timers().getRealSystemTime();
|
|
15523
15618
|
},
|
|
15524
15619
|
clearAllTimers() {
|
|
15525
|
-
|
|
15620
|
+
timers().clearAllTimers();
|
|
15526
15621
|
return utils;
|
|
15527
15622
|
},
|
|
15528
15623
|
// mocks
|
|
@@ -15601,7 +15696,10 @@ function createVitest() {
|
|
|
15601
15696
|
stubEnv(name, value) {
|
|
15602
15697
|
if (!_stubsEnv.has(name))
|
|
15603
15698
|
_stubsEnv.set(name, process.env[name]);
|
|
15604
|
-
|
|
15699
|
+
if (_envBooleans.includes(name))
|
|
15700
|
+
process.env[name] = value ? "1" : "";
|
|
15701
|
+
else
|
|
15702
|
+
process.env[name] = String(value);
|
|
15605
15703
|
return utils;
|
|
15606
15704
|
},
|
|
15607
15705
|
unstubAllGlobals() {
|
|
@@ -15646,7 +15744,7 @@ function createVitest() {
|
|
|
15646
15744
|
var vitest = createVitest();
|
|
15647
15745
|
var vi = vitest;
|
|
15648
15746
|
|
|
15649
|
-
// ../../node_modules/vitest/dist/vendor/index.
|
|
15747
|
+
// ../../node_modules/vitest/dist/vendor/index.dI9lHwVn.js
|
|
15650
15748
|
init_cjs_shims();
|
|
15651
15749
|
function getRunningMode() {
|
|
15652
15750
|
return process.env.VITEST_MODE === "WATCH" ? "watch" : "run";
|