vitest 5.0.3 → 5.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/dist/browser.d.ts +4 -4
- package/dist/browser.js +11 -11
- package/dist/chunks/{base.DhkQeZwd.js → base.CYbb9pQW.js} +39 -15
- package/dist/chunks/{browser.d.3cffPS1V.d.ts → browser.d.FGQ9_rK6.d.ts} +3 -3
- package/dist/chunks/{cac.DfDGTQ9W.js → cac.DTXWs6Ni.js} +21 -23
- package/dist/chunks/cli-api.Bx28WXzL.js +13879 -0
- package/dist/chunks/{config.d.BxjInJat.d.ts → config.d.QBNYCgFU.d.ts} +20 -9
- package/dist/chunks/{console.RBA5x-0t.js → console.DtI4yxfN.js} +5 -5
- package/dist/chunks/{coverage.S6Dao4g-.js → coverage.-bm5IxnW.js} +1 -1
- package/dist/chunks/{coverage._yXj5zeb.js → coverage.cTDc4uSS.js} +1 -1
- package/dist/chunks/{creator.203NYCo3.js → creator.CLL8QFMS.js} +43 -53
- package/dist/chunks/{defaults.D2ip7f-X.js → defaults.B1FCaFfh.js} +2 -2
- package/dist/chunks/{display.CXBnkt9a.js → display.BlTmubjj.js} +1 -1
- package/dist/chunks/{doctor.CpHPRoza.js → doctor.Bqc8NDDb.js} +40 -41
- package/dist/chunks/{env.DzFJjrmK.js → env.BKKtU2WC.js} +1 -1
- package/dist/chunks/{environment.d.DAj1Vt__.d.ts → environment.d.BY56MoGs.d.ts} +1 -1
- package/dist/chunks/{globals.9QtHn8Sr.js → globals.CTWMSIPL.js} +10 -10
- package/dist/chunks/{index.DpLw24bj.js → index.B8VfM7Mf.js} +6233 -18539
- package/dist/chunks/{index.DXQx-kDM.js → index.BoyTG_B7.js} +9 -4
- package/dist/chunks/{index.k8L_ZRzq.js → index.CPNMO3h-.js} +54 -46
- package/dist/chunks/{index.cx-_w29y.js → index.D0heQG4v.js} +5 -3
- package/dist/chunks/{index.ggMXe2IF.js → index.GYMZ12wH.js} +5 -5
- package/dist/chunks/{index.C4tKZ0yW.js → index.uwTEEBsB.js} +88 -68
- package/dist/chunks/{init-forks.hzLs7kMZ.js → init-forks.CbYYa5xq.js} +1 -1
- package/dist/chunks/{init-threads.COb0VD5D.js → init-threads.DtjdvxPl.js} +1 -1
- package/dist/chunks/{init.D0qF-GGk.js → init.DrHtV5zd.js} +7 -6
- package/dist/chunks/module-dependencies.CwNPkcV4.js +71 -0
- package/dist/chunks/{native.CBlba4VV.js → native.cdzHIdmv.js} +47 -33
- package/dist/chunks/{nativeModuleMocker.CXSh3m91.js → nativeModuleMocker.D8f4cW4A.js} +2 -2
- package/dist/chunks/{nativeModuleRunner.jwZPY3dg.js → nativeModuleRunner.xi64Afb2.js} +1 -1
- package/dist/chunks/{node.BzimPqT5.js → node.uQulW0ei.js} +1 -1
- package/dist/chunks/{pathe.M-eThtNZ.CknpM8Or.js → pathe.M-eThtNZ.Ba-7h1rE.js} +8 -6
- package/dist/chunks/{plugin.d.BsjqSb4-.d.ts → plugin.d.C8mmycim.d.ts} +88 -53
- package/dist/chunks/{plugins.D2ut1V9b.js → plugins.DPQHVT0p.js} +1 -1
- package/dist/chunks/{resolver.fbW9AUvG.js → resolver.CtCcxIy1.js} +1 -1
- package/dist/chunks/{rpc.BTmCtPly.js → rpc.DpkUyY1N.js} +2 -2
- package/dist/chunks/{rpc.d.BPFHl-HE.d.ts → rpc.d.Cft1biqy.d.ts} +2 -1
- package/dist/chunks/{run.BTlFXlnv.js → run.Cm2sd7-x.js} +97 -82
- package/dist/chunks/{setup-common.BglbuAHD.js → setup-common.BABL3z3m.js} +3 -3
- package/dist/chunks/{source-map.DUxvo12T.js → source-map.DdKI5IHB.js} +13 -4
- package/dist/chunks/{source-map.d.BLHtC2OB.d.ts → source-map.d.kzFtk_dj.d.ts} +1 -1
- package/dist/chunks/{spy.DgMTfhrK.js → spy.DDMXghXv.js} +45 -16
- package/dist/chunks/{task-utils.d.C-IeGxLU.d.ts → task-utils.d.PFh2BV6Q.d.ts} +1 -1
- package/dist/chunks/tinyrainbow.Do8I1XRG.js +88 -0
- package/dist/chunks/{utils.RcGwuOc_.js → utils.DSfl_w8V.js} +44 -42
- package/dist/chunks/{vm.vTyZj_02.js → vm.Uo_C9Uld.js} +14 -11
- package/dist/chunks/{worker.d.Bt2A2mmi.d.ts → worker.d.BH-r1bPu.d.ts} +8 -3
- package/dist/cli.js +4 -4
- package/dist/config.cjs +1 -1
- package/dist/config.d.ts +9 -10
- package/dist/config.js +2 -2
- package/dist/index.d.ts +10 -10
- package/dist/index.js +10 -10
- package/dist/module-evaluator.d.ts +2 -2
- package/dist/node.d.ts +9 -10
- package/dist/node.js +26 -25
- package/dist/runtime.d.ts +4 -4
- package/dist/runtime.js +4 -4
- package/dist/spy.js +1 -1
- package/dist/task-utils.js +6 -4
- package/dist/worker.d.ts +4 -4
- package/dist/worker.js +21 -20
- package/dist/workers/forks.js +19 -18
- package/dist/workers/runVmTests.js +23 -14
- package/dist/workers/threads.js +19 -18
- package/dist/workers/vmForks.js +13 -13
- package/dist/workers/vmThreads.js +13 -13
- package/package.json +28 -27
- package/dist/chunks/cli-api.C4x4GGip.js +0 -528
- package/dist/chunks/tinyrainbow.Ht9iggcq.js +0 -95
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { f as format, p as plugins } from './index.
|
|
2
|
-
import {
|
|
3
|
-
import { s as stringify, f as format$1, a as formatRegExp, t as truncateString, i as inspect } from './display.
|
|
4
|
-
import { p as deepClone, q as getOwnProperties, g as getType$1, u as isObject, v as filterOutComments, w as ordinal, e as createDefer, x as assertTypes, t as toArray, y as isNegativeNaN, z as unique, A as objectAttr } from './pathe.M-eThtNZ.
|
|
5
|
-
import { d as diffSequences, b as serializeValue, p as parseStacktrace, a as getSafeTimers } from './source-map.
|
|
1
|
+
import { f as format, p as plugins } from './index.D0heQG4v.js';
|
|
2
|
+
import { $ } from './tinyrainbow.Do8I1XRG.js';
|
|
3
|
+
import { s as stringify, f as format$1, a as formatRegExp, t as truncateString, i as inspect } from './display.BlTmubjj.js';
|
|
4
|
+
import { p as deepClone, q as getOwnProperties, g as getType$1, u as isObject, v as filterOutComments, w as ordinal, e as createDefer, x as assertTypes, t as toArray, y as isNegativeNaN, z as unique, A as objectAttr } from './pathe.M-eThtNZ.Ba-7h1rE.js';
|
|
5
|
+
import { d as diffSequences, b as serializeValue, p as parseStacktrace, a as getSafeTimers } from './source-map.DdKI5IHB.js';
|
|
6
6
|
import { createTaskName, createFileTask, calculateSuiteHash, interpretTaskModes, hasFailed } from '../task-utils.js';
|
|
7
7
|
|
|
8
8
|
const RealDate = Date;
|
|
@@ -508,25 +508,27 @@ function joinAlignedDiffsNoExpand(diffs, options) {
|
|
|
508
508
|
while (i !== iLength) {
|
|
509
509
|
const iStart = i;
|
|
510
510
|
while (i !== iLength && diffs[i][0] === DIFF_EQUAL) i += 1;
|
|
511
|
-
if (iStart !== i)
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
511
|
+
if (iStart !== i) {
|
|
512
|
+
if (iStart === 0) {
|
|
513
|
+
// at start
|
|
514
|
+
if (i > nContextLines) {
|
|
515
|
+
jLength -= i - nContextLines;
|
|
516
|
+
hasExcessAtStartOrEnd = true;
|
|
517
|
+
}
|
|
518
|
+
} else if (i === iLength) {
|
|
519
|
+
// at end
|
|
520
|
+
const n = i - iStart;
|
|
521
|
+
if (n > nContextLines) {
|
|
522
|
+
jLength -= n - nContextLines;
|
|
523
|
+
hasExcessAtStartOrEnd = true;
|
|
524
|
+
}
|
|
525
|
+
} else {
|
|
526
|
+
// between changes
|
|
527
|
+
const n = i - iStart;
|
|
528
|
+
if (n > nContextLines2) {
|
|
529
|
+
jLength -= n - nContextLines2;
|
|
530
|
+
nExcessesBetweenChanges += 1;
|
|
531
|
+
}
|
|
530
532
|
}
|
|
531
533
|
}
|
|
532
534
|
while (i !== iLength && diffs[i][0] !== DIFF_EQUAL) i += 1;
|
|
@@ -564,36 +566,38 @@ function joinAlignedDiffsNoExpand(diffs, options) {
|
|
|
564
566
|
while (i !== iLength) {
|
|
565
567
|
let iStart = i;
|
|
566
568
|
while (i !== iLength && diffs[i][0] === DIFF_EQUAL) i += 1;
|
|
567
|
-
if (iStart !== i)
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
} else {
|
|
582
|
-
// between changes
|
|
583
|
-
const nCommon = i - iStart;
|
|
584
|
-
if (nCommon > nContextLines2) {
|
|
585
|
-
const iEnd = iStart + nContextLines;
|
|
569
|
+
if (iStart !== i) {
|
|
570
|
+
if (iStart === 0) {
|
|
571
|
+
// at beginning
|
|
572
|
+
if (i > nContextLines) {
|
|
573
|
+
iStart = i - nContextLines;
|
|
574
|
+
aStart = iStart;
|
|
575
|
+
bStart = iStart;
|
|
576
|
+
aEnd = aStart;
|
|
577
|
+
bEnd = bStart;
|
|
578
|
+
}
|
|
579
|
+
for (let iCommon = iStart; iCommon !== i; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
|
|
580
|
+
} else if (i === iLength) {
|
|
581
|
+
// at end
|
|
582
|
+
const iEnd = i - iStart > nContextLines ? iStart + nContextLines : i;
|
|
586
583
|
for (let iCommon = iStart; iCommon !== iEnd; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
584
|
+
} else {
|
|
585
|
+
// between changes
|
|
586
|
+
const nCommon = i - iStart;
|
|
587
|
+
if (nCommon > nContextLines2) {
|
|
588
|
+
const iEnd = iStart + nContextLines;
|
|
589
|
+
for (let iCommon = iStart; iCommon !== iEnd; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
|
|
590
|
+
lines[jPatchMark] = createPatchMark(aStart, aEnd, bStart, bEnd, options);
|
|
591
|
+
jPatchMark = lines.length;
|
|
592
|
+
lines.push("");
|
|
593
|
+
const nOmit = nCommon - nContextLines2;
|
|
594
|
+
aStart = aEnd + nOmit;
|
|
595
|
+
bStart = bEnd + nOmit;
|
|
596
|
+
aEnd = aStart;
|
|
597
|
+
bEnd = bStart;
|
|
598
|
+
for (let iCommon = i - nContextLines; iCommon !== i; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
|
|
599
|
+
} else for (let iCommon = iStart; iCommon !== i; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
|
|
600
|
+
}
|
|
597
601
|
}
|
|
598
602
|
while (i !== iLength && diffs[i][0] === DIFF_DELETE) {
|
|
599
603
|
pushDeleteLine(diffs[i][1]);
|
|
@@ -629,14 +633,14 @@ const DIFF_TRUNCATE_THRESHOLD_DEFAULT = 0;
|
|
|
629
633
|
function getDefaultOptions() {
|
|
630
634
|
return {
|
|
631
635
|
aAnnotation: "Expected",
|
|
632
|
-
aColor:
|
|
636
|
+
aColor: $.green,
|
|
633
637
|
aIndicator: "-",
|
|
634
638
|
bAnnotation: "Received",
|
|
635
|
-
bColor:
|
|
639
|
+
bColor: $.red,
|
|
636
640
|
bIndicator: "+",
|
|
637
|
-
changeColor:
|
|
641
|
+
changeColor: $.inverse,
|
|
638
642
|
changeLineTrailingSpaceColor: noColor,
|
|
639
|
-
commonColor:
|
|
643
|
+
commonColor: $.dim,
|
|
640
644
|
commonIndicator: " ",
|
|
641
645
|
commonLineTrailingSpaceColor: noColor,
|
|
642
646
|
compareKeys: void 0,
|
|
@@ -645,7 +649,7 @@ function getDefaultOptions() {
|
|
|
645
649
|
expand: false,
|
|
646
650
|
includeChangeCounts: false,
|
|
647
651
|
omitAnnotationLines: false,
|
|
648
|
-
patchColor:
|
|
652
|
+
patchColor: $.yellow,
|
|
649
653
|
printBasicPrototype: false,
|
|
650
654
|
truncateThreshold: DIFF_TRUNCATE_THRESHOLD_DEFAULT,
|
|
651
655
|
truncateAnnotation: "... Diff result is truncated",
|
|
@@ -1260,13 +1264,13 @@ function replaceTrailingSpaces(text) {
|
|
|
1260
1264
|
return text.replace(/\s+$/gm, (spaces) => SPACE_SYMBOL.repeat(spaces.length));
|
|
1261
1265
|
}
|
|
1262
1266
|
function printReceived(object) {
|
|
1263
|
-
return
|
|
1267
|
+
return $.red(replaceTrailingSpaces(stringify(object)));
|
|
1264
1268
|
}
|
|
1265
1269
|
function printExpected(value) {
|
|
1266
|
-
return
|
|
1270
|
+
return $.green(replaceTrailingSpaces(stringify(value)));
|
|
1267
1271
|
}
|
|
1268
1272
|
function getCommonAndChangedSubstrings(diffs, op, hasCommonDiff) {
|
|
1269
|
-
return diffs.reduce((reduced, diff) => reduced + (diff[0] === DIFF_EQUAL ? diff[1] : diff[0] === op ? hasCommonDiff ?
|
|
1273
|
+
return diffs.reduce((reduced, diff) => reduced + (diff[0] === DIFF_EQUAL ? diff[1] : diff[0] === op ? hasCommonDiff ? $.inverse(diff[1]) : diff[1] : ""), "");
|
|
1270
1274
|
}
|
|
1271
1275
|
|
|
1272
1276
|
function processError(_err, diffOptions, seen = /* @__PURE__ */ new WeakSet()) {
|
|
@@ -1658,8 +1662,12 @@ function withFixtures(fn, options) {
|
|
|
1658
1662
|
// access the parent fixture ({ a: ({ a }) => {} })
|
|
1659
1663
|
if (cachedFixtures.has(fixture)) continue;
|
|
1660
1664
|
cachedFixtures.add(fixture);
|
|
1661
|
-
|
|
1662
|
-
|
|
1665
|
+
try {
|
|
1666
|
+
context[fixture.name] = await resolveTestFixtureValue(fixture, context, cleanupFnArray);
|
|
1667
|
+
} catch (error) {
|
|
1668
|
+
cachedFixtures.delete(fixture);
|
|
1669
|
+
throw error;
|
|
1670
|
+
}
|
|
1663
1671
|
cleanupFnArray.push(() => {
|
|
1664
1672
|
cachedFixtures.delete(fixture);
|
|
1665
1673
|
});
|
|
@@ -1701,8 +1709,9 @@ async function resolveScopeFixtureValue(fixtures, suite, fixture) {
|
|
|
1701
1709
|
...fileContext
|
|
1702
1710
|
} : fixtureContext, cleanupFnFileArray).then((value) => {
|
|
1703
1711
|
fixtureContext[fixture.name] = value;
|
|
1704
|
-
scopedFixturePromiseCache.delete(fixture);
|
|
1705
1712
|
return value;
|
|
1713
|
+
}).finally(() => {
|
|
1714
|
+
scopedFixturePromiseCache.delete(fixture);
|
|
1706
1715
|
});
|
|
1707
1716
|
scopedFixturePromiseCache.set(fixture, promise);
|
|
1708
1717
|
return promise;
|
|
@@ -1750,8 +1759,10 @@ function resolveDeps(usedFixtures, registrations, depSet = /* @__PURE__ */ new S
|
|
|
1750
1759
|
pendingFixtures.push(fixture);
|
|
1751
1760
|
return;
|
|
1752
1761
|
}
|
|
1753
|
-
if (depSet.has(fixture))
|
|
1754
|
-
|
|
1762
|
+
if (depSet.has(fixture)) {
|
|
1763
|
+
if (fixture.parent) fixture = fixture.parent;
|
|
1764
|
+
else throw new Error(`Circular fixture dependency detected: ${fixture.name} <- ${[...depSet].reverse().map((d) => d.name).join(" <- ")}`);
|
|
1765
|
+
}
|
|
1755
1766
|
depSet.add(fixture);
|
|
1756
1767
|
resolveDeps(Array.from(fixture.deps, (n) => n === fixture.name ? fixture.parent : registrations.get(n)).filter((n) => !!n), registrations, depSet, pendingFixtures);
|
|
1757
1768
|
pendingFixtures.push(fixture);
|
|
@@ -2822,9 +2833,10 @@ function createSuite() {
|
|
|
2822
2833
|
const fnFirst = typeof optionsOrFn === "function";
|
|
2823
2834
|
cases.forEach((i, idx) => {
|
|
2824
2835
|
const items = Array.isArray(i) ? i : [i];
|
|
2825
|
-
if (fnFirst)
|
|
2826
|
-
|
|
2827
|
-
|
|
2836
|
+
if (fnFirst) {
|
|
2837
|
+
if (arrayOnlyCases) suite(formatTitle(_name, items, idx), handler ? () => handler(...items) : void 0, options.timeout);
|
|
2838
|
+
else suite(formatTitle(_name, items, idx), handler ? () => handler(i) : void 0, options.timeout);
|
|
2839
|
+
} else if (arrayOnlyCases) suite(formatTitle(_name, items, idx), options, handler ? () => handler(...items) : void 0);
|
|
2828
2840
|
else suite(formatTitle(_name, items, idx), options, handler ? () => handler(i) : void 0);
|
|
2829
2841
|
});
|
|
2830
2842
|
context.setContext("each", void 0);
|
|
@@ -2865,9 +2877,10 @@ function createTaskCollector(fn) {
|
|
|
2865
2877
|
const fnFirst = typeof optionsOrFn === "function";
|
|
2866
2878
|
cases.forEach((i, idx) => {
|
|
2867
2879
|
const items = Array.isArray(i) ? i : [i];
|
|
2868
|
-
if (fnFirst)
|
|
2869
|
-
|
|
2870
|
-
|
|
2880
|
+
if (fnFirst) {
|
|
2881
|
+
if (arrayOnlyCases) test(formatTitle(_name, items, idx), handler ? () => handler(...items) : void 0, options.timeout);
|
|
2882
|
+
else test(formatTitle(_name, items, idx), handler ? () => handler(i) : void 0, options.timeout);
|
|
2883
|
+
} else if (arrayOnlyCases) test(formatTitle(_name, items, idx), options, handler ? () => handler(...items) : void 0);
|
|
2871
2884
|
else test(formatTitle(_name, items, idx), options, handler ? () => handler(i) : void 0);
|
|
2872
2885
|
});
|
|
2873
2886
|
context.setContext("each", void 0);
|
|
@@ -3004,7 +3017,7 @@ function formatTitle(template, items, idx) {
|
|
|
3004
3017
|
const arrayElement = isArrayKey ? objectAttr(items, key) : void 0;
|
|
3005
3018
|
const value = isObjectItem ? objectAttr(items[0], key, arrayElement) : arrayElement;
|
|
3006
3019
|
// print string without quotes
|
|
3007
|
-
if (typeof value === "string") return truncateString(value, inspectOptions.truncate);
|
|
3020
|
+
if (typeof value === "string") return inspectOptions.truncate ? truncateString(value, inspectOptions.truncate) : value;
|
|
3008
3021
|
return inspect(value, inspectOptions);
|
|
3009
3022
|
});
|
|
3010
3023
|
}
|
|
@@ -4084,14 +4097,16 @@ async function runSuite(suite, runner) {
|
|
|
4084
4097
|
if (!suiteRan) markTasksAsSkipped(suite, runner);
|
|
4085
4098
|
failTask(suite.result, e, runner.config._diffOptions);
|
|
4086
4099
|
}
|
|
4087
|
-
if (suite.mode === "run" || suite.mode === "queued")
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4100
|
+
if (suite.mode === "run" || suite.mode === "queued") {
|
|
4101
|
+
if (!runner.config.passWithNoTests && !suite.containsTest) {
|
|
4102
|
+
suite.result.state = "fail";
|
|
4103
|
+
if (!suite.result.errors?.length) {
|
|
4104
|
+
const error = processError(/* @__PURE__ */ new Error(`No test found in suite ${suite.name}`));
|
|
4105
|
+
suite.result.errors = [error];
|
|
4106
|
+
}
|
|
4107
|
+
} else if (hasFailed(suite)) suite.result.state = "fail";
|
|
4108
|
+
else suite.result.state = "pass";
|
|
4109
|
+
}
|
|
4095
4110
|
suite.result.duration = now() - start;
|
|
4096
4111
|
await runner.onAfterRunSuite?.(suite);
|
|
4097
4112
|
updateTask("suite-finished", suite, runner);
|
|
@@ -4183,4 +4198,4 @@ async function publicCollect(specs, runner) {
|
|
|
4183
4198
|
return files;
|
|
4184
4199
|
}
|
|
4185
4200
|
|
|
4186
|
-
export {
|
|
4201
|
+
export { createTagsFilter as A, validateTags as B, shuffle as C, TestSyntaxError as T, processError as a, printDiffOrStringify as b, createTaskCollector as c, diff as d, getCurrentSuite as e, createChainable as f, getCurrentTest as g, getHooks as h, getFn as i, afterAll as j, afterEach as k, aroundAll as l, matchesTags as m, aroundEach as n, beforeAll as o, publicCollect as p, beforeEach as q, describe as r, startTests as s, it as t, onTestFailed as u, onTestFinished as v, recordArtifact as w, suite as x, test as y, limitConcurrency as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { s as setSafeTimers } from './source-map.
|
|
2
|
-
import { a as addSerializer } from './plugins.
|
|
1
|
+
import { s as setSafeTimers } from './source-map.DdKI5IHB.js';
|
|
2
|
+
import { a as addSerializer } from './plugins.DPQHVT0p.js';
|
|
3
3
|
|
|
4
4
|
let globalSetup = false;
|
|
5
5
|
async function setupCommonEnv(config) {
|
|
@@ -7,7 +7,7 @@ async function setupCommonEnv(config) {
|
|
|
7
7
|
if (globalSetup) return;
|
|
8
8
|
globalSetup = true;
|
|
9
9
|
setSafeTimers();
|
|
10
|
-
if (config.globals) (await import('./globals.
|
|
10
|
+
if (config.globals) (await import('./globals.CTWMSIPL.js')).registerApiGlobally();
|
|
11
11
|
}
|
|
12
12
|
function setupDefines(config) {
|
|
13
13
|
for (const key in config.defines) globalThis[key] = config.defines[key];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as getDefaultExportFromCjs } from './index.
|
|
2
|
-
import { m as isPrimitive, o as notNullish, r as resolve$1 } from './pathe.M-eThtNZ.
|
|
1
|
+
import { g as getDefaultExportFromCjs } from './index.D0heQG4v.js';
|
|
2
|
+
import { m as isPrimitive, o as notNullish, r as resolve$1 } from './pathe.M-eThtNZ.Ba-7h1rE.js';
|
|
3
3
|
|
|
4
4
|
var build = {};
|
|
5
5
|
|
|
@@ -1591,7 +1591,7 @@ function extractLocation(urlLike) {
|
|
|
1591
1591
|
const urlObj = new URL(url);
|
|
1592
1592
|
urlObj.searchParams.delete("import");
|
|
1593
1593
|
urlObj.searchParams.delete("browserv");
|
|
1594
|
-
url = urlObj.pathname + urlObj.hash + urlObj.search;
|
|
1594
|
+
url = tryDecode(urlObj.pathname, decodeURI) + urlObj.hash + urlObj.search;
|
|
1595
1595
|
}
|
|
1596
1596
|
if (url.startsWith("/@fs/")) {
|
|
1597
1597
|
const isWindows = /^\/@fs\/[a-zA-Z]:\//.test(url);
|
|
@@ -1604,6 +1604,13 @@ function extractLocation(urlLike) {
|
|
|
1604
1604
|
parts[3] || void 0
|
|
1605
1605
|
];
|
|
1606
1606
|
}
|
|
1607
|
+
function tryDecode(value, decode) {
|
|
1608
|
+
try {
|
|
1609
|
+
return decode(value);
|
|
1610
|
+
} catch {
|
|
1611
|
+
return value;
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1607
1614
|
function parseSingleFFOrSafariStack(raw) {
|
|
1608
1615
|
let line = raw.trim();
|
|
1609
1616
|
if (SAFARI_NATIVE_CODE_REGEXP.test(line)) return null;
|
|
@@ -1663,7 +1670,9 @@ function parseSingleV8Stack(raw) {
|
|
|
1663
1670
|
let file = url && ["eval", "<anonymous>"].includes(url) ? void 0 : url;
|
|
1664
1671
|
if (!file || !lineNumber || !columnNumber) return null;
|
|
1665
1672
|
if (method.startsWith("async ")) method = method.slice(6);
|
|
1666
|
-
if (file.startsWith("file://"))
|
|
1673
|
+
if (file.startsWith("file://"))
|
|
1674
|
+
// pathToFileURL also encodes "#" and "?", which decodeURI keeps
|
|
1675
|
+
file = tryDecode(file.slice(7), decodeURIComponent);
|
|
1667
1676
|
// normalize Windows path (\ -> /)
|
|
1668
1677
|
file = file.startsWith("node:") || file.startsWith("internal:") ? file : resolve$1(file);
|
|
1669
1678
|
if (method) 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, "");
|
|
@@ -6,13 +6,38 @@ const MOCK_RESTORE = /* @__PURE__ */ new Set();
|
|
|
6
6
|
// but it makes the state slower to access and return different values
|
|
7
7
|
// if you stored it before calling `mockClear` where it will be recreated
|
|
8
8
|
const DIRTY_MOCK_STATES = /* @__PURE__ */ new Set();
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
// Mocks whose implementation, once-queue or name changed since their last
|
|
10
|
+
// `mockReset()`, so `resetAllMocks()` only visits mocks that are not already reset
|
|
11
|
+
const DIRTY_MOCK_CONFIGS = /* @__PURE__ */ new Set();
|
|
12
|
+
// a test may spy on `Set.prototype.add`, and the spy itself marks mocks dirty
|
|
13
|
+
const addToSet = Set.prototype.add;
|
|
14
|
+
const MOCK_REFS = /* @__PURE__ */ new WeakMap();
|
|
11
15
|
const MOCK_FINALIZER = new FinalizationRegistry((ref) => {
|
|
12
|
-
|
|
16
|
+
DIRTY_MOCK_STATES.delete(ref);
|
|
17
|
+
DIRTY_MOCK_CONFIGS.delete(ref);
|
|
13
18
|
});
|
|
14
19
|
const MOCK_CONFIGS = /* @__PURE__ */ new WeakMap();
|
|
15
20
|
const MOCKS_BY_STATE = /* @__PURE__ */ new WeakMap();
|
|
21
|
+
function markDirty(set, mock) {
|
|
22
|
+
let ref = MOCK_REFS.get(mock);
|
|
23
|
+
if (!ref) {
|
|
24
|
+
ref = new WeakRef(mock);
|
|
25
|
+
MOCK_REFS.set(mock, ref);
|
|
26
|
+
MOCK_FINALIZER.register(mock, ref);
|
|
27
|
+
}
|
|
28
|
+
addToSet.call(set, ref);
|
|
29
|
+
}
|
|
30
|
+
function unmarkDirty(set, mock) {
|
|
31
|
+
const ref = MOCK_REFS.get(mock);
|
|
32
|
+
if (ref) set.delete(ref);
|
|
33
|
+
}
|
|
34
|
+
function forEachDirty(set, fn) {
|
|
35
|
+
for (const ref of set) {
|
|
36
|
+
const mock = ref.deref();
|
|
37
|
+
if (mock) fn(mock);
|
|
38
|
+
else set.delete(ref);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
16
41
|
function createMockInstance(options = {}) {
|
|
17
42
|
const { originalImplementation, restore, mockImplementation, resetToMockImplementation, resetToMockName } = options;
|
|
18
43
|
if (restore) MOCK_RESTORE.add(restore);
|
|
@@ -36,9 +61,6 @@ function createMockInstance(options = {}) {
|
|
|
36
61
|
if (resetToMockName) config.mockName = mock.name || "vi.fn()";
|
|
37
62
|
MOCK_CONFIGS.set(mock, config);
|
|
38
63
|
MOCKS_BY_STATE.set(state, mock);
|
|
39
|
-
const ref = new WeakRef(mock);
|
|
40
|
-
REGISTERED_MOCKS.add(ref);
|
|
41
|
-
MOCK_FINALIZER.register(mock, ref);
|
|
42
64
|
mock._isMockFunction = true;
|
|
43
65
|
mock.getMockImplementation = () => {
|
|
44
66
|
// Jest only returns `config.mockImplementation` here,
|
|
@@ -59,21 +81,25 @@ function createMockInstance(options = {}) {
|
|
|
59
81
|
value: state
|
|
60
82
|
});
|
|
61
83
|
mock.mockImplementation = function mockImplementation(implementation) {
|
|
84
|
+
markDirty(DIRTY_MOCK_CONFIGS, mock);
|
|
62
85
|
config.mockImplementation = implementation;
|
|
63
86
|
updateMockPrototype();
|
|
64
87
|
return mock;
|
|
65
88
|
};
|
|
66
89
|
mock.mockImplementationOnce = function mockImplementationOnce(implementation) {
|
|
90
|
+
markDirty(DIRTY_MOCK_CONFIGS, mock);
|
|
67
91
|
config.onceMockImplementations.push(implementation);
|
|
68
92
|
updateMockPrototype();
|
|
69
93
|
return mock;
|
|
70
94
|
};
|
|
71
95
|
mock.withImplementation = function withImplementation(implementation, callback) {
|
|
96
|
+
markDirty(DIRTY_MOCK_CONFIGS, mock);
|
|
72
97
|
const previousImplementation = config.mockImplementation;
|
|
73
98
|
const previousOnceImplementations = config.onceMockImplementations;
|
|
74
99
|
const reset = () => {
|
|
75
100
|
config.mockImplementation = previousImplementation;
|
|
76
101
|
config.onceMockImplementations = previousOnceImplementations;
|
|
102
|
+
markDirty(DIRTY_MOCK_CONFIGS, mock);
|
|
77
103
|
updateMockPrototype();
|
|
78
104
|
};
|
|
79
105
|
config.mockImplementation = implementation;
|
|
@@ -147,7 +173,7 @@ function createMockInstance(options = {}) {
|
|
|
147
173
|
state.invocationCallOrder = [];
|
|
148
174
|
state.results = [];
|
|
149
175
|
state.settledResults = [];
|
|
150
|
-
DIRTY_MOCK_STATES
|
|
176
|
+
unmarkDirty(DIRTY_MOCK_STATES, mock);
|
|
151
177
|
return mock;
|
|
152
178
|
};
|
|
153
179
|
mock.mockReset = function mockReset() {
|
|
@@ -155,6 +181,7 @@ function createMockInstance(options = {}) {
|
|
|
155
181
|
config.mockImplementation = resetToMockImplementation ? mockImplementation : void 0;
|
|
156
182
|
config.mockName = resetToMockName ? mock.name || "vi.fn()" : "vi.fn()";
|
|
157
183
|
config.onceMockImplementations = [];
|
|
184
|
+
unmarkDirty(DIRTY_MOCK_CONFIGS, mock);
|
|
158
185
|
updateMockPrototype();
|
|
159
186
|
return mock;
|
|
160
187
|
};
|
|
@@ -163,7 +190,10 @@ function createMockInstance(options = {}) {
|
|
|
163
190
|
return restore?.();
|
|
164
191
|
};
|
|
165
192
|
mock.mockName = function mockName(name) {
|
|
166
|
-
if (typeof name === "string")
|
|
193
|
+
if (typeof name === "string") {
|
|
194
|
+
markDirty(DIRTY_MOCK_CONFIGS, mock);
|
|
195
|
+
config.mockName = name;
|
|
196
|
+
}
|
|
167
197
|
return mock;
|
|
168
198
|
};
|
|
169
199
|
mock.getMockName = function getMockName() {
|
|
@@ -269,8 +299,8 @@ function createMock({ state, config, name: mockName, prototypeState, prototypeCo
|
|
|
269
299
|
const namedObject = {
|
|
270
300
|
// to keep the name of the function intact
|
|
271
301
|
[name]: function(...args) {
|
|
272
|
-
|
|
273
|
-
if (prototypeMock)
|
|
302
|
+
markDirty(DIRTY_MOCK_STATES, namedObject[name]);
|
|
303
|
+
if (prototypeMock) markDirty(DIRTY_MOCK_STATES, prototypeMock);
|
|
274
304
|
registerCalls(args, state, prototypeState);
|
|
275
305
|
registerInvocationOrder(invocationCallCounter++, state, prototypeState);
|
|
276
306
|
const result = {
|
|
@@ -453,14 +483,13 @@ function restoreAllMocks() {
|
|
|
453
483
|
MOCK_RESTORE.clear();
|
|
454
484
|
}
|
|
455
485
|
function clearAllMocks() {
|
|
456
|
-
|
|
486
|
+
forEachDirty(DIRTY_MOCK_STATES, (mock) => mock.mockClear());
|
|
457
487
|
}
|
|
458
488
|
function resetAllMocks() {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
}
|
|
489
|
+
// `mockReset()` removes the mock from both sets, so a mock present in both
|
|
490
|
+
// is visited once.
|
|
491
|
+
forEachDirty(DIRTY_MOCK_STATES, (mock) => mock.mockReset());
|
|
492
|
+
forEachDirty(DIRTY_MOCK_CONFIGS, (mock) => mock.mockReset());
|
|
464
493
|
}
|
|
465
494
|
function throwConstructorError(shorthand) {
|
|
466
495
|
throw new TypeError(`Cannot use \`${shorthand}\` when called with \`new\`. Use \`mockImplementation\` with a \`class\` keyword instead. See https://vitest.dev/api/mock#class-support for more information.`);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { bn as SnapshotState, m as Test, bo as PromisifyAssertion, bp as Tester, bq as Plugin, ad as BenchResult, a as File } from './config.d.
|
|
1
|
+
import { bn as SnapshotState, m as Test, bo as PromisifyAssertion, bp as Tester, bq as Plugin, ad as BenchResult, a as File } from './config.d.QBNYCgFU.js';
|
|
2
2
|
|
|
3
3
|
interface SnapshotMatcher<
|
|
4
4
|
R extends void | Promise<void>,
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
var d = (e) => String(e);
|
|
3
|
+
d.open = d.close = "";
|
|
4
|
+
var i = () => d, t = "\x1B[39m", o = "\x1B[49m", F = (e, r, a, n, l) => {
|
|
5
|
+
let m = "", g = 0;
|
|
6
|
+
do
|
|
7
|
+
m += e.substring(g, n) + a, g = n + l, n = e.indexOf(r, g);
|
|
8
|
+
while (~n);
|
|
9
|
+
return m + e.substring(g);
|
|
10
|
+
}, u = (e, r, a = e, n = e.length) => {
|
|
11
|
+
let l = r.length, m = (g) => {
|
|
12
|
+
let s = g + "", x = s.indexOf(r, n);
|
|
13
|
+
return ~x ? e + F(s, r, a, x, l) + r : e + s + r;
|
|
14
|
+
};
|
|
15
|
+
return m.open = e, m.close = r, m;
|
|
16
|
+
}, B = (e, r) => u(e, r, e, 5), c = (e) => {
|
|
17
|
+
let r = e.charCodeAt(0) === 35 ? e.slice(1) : e, a = parseInt(r, 16) || 0;
|
|
18
|
+
return r.length < 6 ? `${(a >> 8 & 15) * 17};${(a >> 4 & 15) * 17};${(a & 15) * 17}` : `${a >> 16 & 255};${a >> 8 & 255};${a & 255}`;
|
|
19
|
+
};
|
|
20
|
+
function y(e) {
|
|
21
|
+
let r = e ? u : i;
|
|
22
|
+
return {
|
|
23
|
+
isColorSupported: e,
|
|
24
|
+
reset: r("\x1B[0m", "\x1B[0m"),
|
|
25
|
+
bold: r("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
26
|
+
dim: r("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
27
|
+
italic: r("\x1B[3m", "\x1B[23m"),
|
|
28
|
+
underline: r("\x1B[4m", "\x1B[24m"),
|
|
29
|
+
inverse: r("\x1B[7m", "\x1B[27m"),
|
|
30
|
+
hidden: r("\x1B[8m", "\x1B[28m"),
|
|
31
|
+
strikethrough: r("\x1B[9m", "\x1B[29m"),
|
|
32
|
+
black: r("\x1B[30m", t),
|
|
33
|
+
red: r("\x1B[31m", t),
|
|
34
|
+
green: r("\x1B[32m", t),
|
|
35
|
+
yellow: r("\x1B[33m", t),
|
|
36
|
+
blue: r("\x1B[34m", t),
|
|
37
|
+
magenta: r("\x1B[35m", t),
|
|
38
|
+
cyan: r("\x1B[36m", t),
|
|
39
|
+
white: r("\x1B[37m", t),
|
|
40
|
+
gray: r("\x1B[90m", t),
|
|
41
|
+
bgBlack: r("\x1B[40m", o),
|
|
42
|
+
bgRed: r("\x1B[41m", o),
|
|
43
|
+
bgGreen: r("\x1B[42m", o),
|
|
44
|
+
bgYellow: r("\x1B[43m", o),
|
|
45
|
+
bgBlue: r("\x1B[44m", o),
|
|
46
|
+
bgMagenta: r("\x1B[45m", o),
|
|
47
|
+
bgCyan: r("\x1B[46m", o),
|
|
48
|
+
bgWhite: r("\x1B[47m", o),
|
|
49
|
+
blackBright: r("\x1B[90m", t),
|
|
50
|
+
redBright: r("\x1B[91m", t),
|
|
51
|
+
greenBright: r("\x1B[92m", t),
|
|
52
|
+
yellowBright: r("\x1B[93m", t),
|
|
53
|
+
blueBright: r("\x1B[94m", t),
|
|
54
|
+
magentaBright: r("\x1B[95m", t),
|
|
55
|
+
cyanBright: r("\x1B[96m", t),
|
|
56
|
+
whiteBright: r("\x1B[97m", t),
|
|
57
|
+
bgBlackBright: r("\x1B[100m", o),
|
|
58
|
+
bgRedBright: r("\x1B[101m", o),
|
|
59
|
+
bgGreenBright: r("\x1B[102m", o),
|
|
60
|
+
bgYellowBright: r("\x1B[103m", o),
|
|
61
|
+
bgBlueBright: r("\x1B[104m", o),
|
|
62
|
+
bgMagentaBright: r("\x1B[105m", o),
|
|
63
|
+
bgCyanBright: r("\x1B[106m", o),
|
|
64
|
+
bgWhiteBright: r("\x1B[107m", o),
|
|
65
|
+
rgb: e ? (n, l, m) => B(`\x1B[38;2;${n};${l};${m}m`, t) : i,
|
|
66
|
+
bgRgb: e ? (n, l, m) => B(`\x1B[48;2;${n};${l};${m}m`, o) : i,
|
|
67
|
+
hex: e ? (n) => B(`\x1B[38;2;${c(n)}m`, t) : i,
|
|
68
|
+
bgHex: e ? (n) => B(`\x1B[48;2;${c(n)}m`, o) : i
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function f() {
|
|
72
|
+
return y(false);
|
|
73
|
+
}
|
|
74
|
+
function C() {
|
|
75
|
+
let e = typeof process != "undefined" ? process : void 0, r = (e == null ? void 0 : e.env) || {}, a = r.FORCE_TTY !== "false", n = (e == null ? void 0 : e.argv) || [];
|
|
76
|
+
return !("NO_COLOR" in r || n.includes("--no-color")) && ("FORCE_COLOR" in r || n.includes("--color") || (e == null ? void 0 : e.platform) === "win32" || a && r.TERM !== "dumb" || "CI" in r) || typeof window != "undefined" && !!window.chrome;
|
|
77
|
+
}
|
|
78
|
+
function h({ force: e } = {}) {
|
|
79
|
+
let r = e || C();
|
|
80
|
+
return y(r);
|
|
81
|
+
}
|
|
82
|
+
var b = h();
|
|
83
|
+
function w() {
|
|
84
|
+
Object.assign(b, f());
|
|
85
|
+
}
|
|
86
|
+
var $ = b;
|
|
87
|
+
|
|
88
|
+
export { $, w };
|