vitest 5.0.3 → 5.0.5
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.CzXt2BO_.js} +40 -15
- package/dist/chunks/{browser.d.3cffPS1V.d.ts → browser.d.FGQ9_rK6.d.ts} +3 -3
- package/dist/chunks/{cac.DfDGTQ9W.js → cac.CLrZKo1g.js} +21 -23
- package/dist/chunks/cli-api.De07GUeT.js +13894 -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.C5g4egeG.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.BK86Cncq.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.CXEE6_2C.js} +10 -10
- package/dist/chunks/{index.DpLw24bj.js → index.1TqnEahn.js} +7209 -19488
- package/dist/chunks/{index.DXQx-kDM.js → index.BoyTG_B7.js} +9 -4
- package/dist/chunks/{index.k8L_ZRzq.js → index.CK-t0WMg.js} +60 -53
- package/dist/chunks/{index.ggMXe2IF.js → index.CoUIxZd4.js} +7 -5
- package/dist/chunks/{index.cx-_w29y.js → index.D0heQG4v.js} +5 -3
- package/dist/chunks/{index.C4tKZ0yW.js → index.aTZaPVhf.js} +88 -68
- package/dist/chunks/{init-forks.hzLs7kMZ.js → init-forks.CRxIPOJR.js} +1 -1
- package/dist/chunks/{init-threads.COb0VD5D.js → init-threads.Dv3kwST_.js} +1 -1
- package/dist/chunks/{init.D0qF-GGk.js → init.PvxYpuCm.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.BxrHJNAF.js} +26 -5
- 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.BPv-BBRv.js} +134 -110
- package/dist/chunks/{setup-common.BglbuAHD.js → setup-common.HGAqWOnX.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.FGl2rw_t.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/module-evaluator.js +16 -12
- 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 +24 -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
|
@@ -185,15 +185,20 @@ async function installPackage(names, options = {}) {
|
|
|
185
185
|
const [agent] = detectedAgent.split("@");
|
|
186
186
|
if (!Array.isArray(names)) names = [names];
|
|
187
187
|
const args = (typeof options.additionalArgs === "function" ? options.additionalArgs(agent, detectedAgent) : options.additionalArgs) || [];
|
|
188
|
-
if (options.preferOffline)
|
|
189
|
-
|
|
188
|
+
if (options.preferOffline) {
|
|
189
|
+
if (detectedAgent === "yarn@berry") args.unshift("--cached");
|
|
190
|
+
else args.unshift("--prefer-offline");
|
|
191
|
+
}
|
|
190
192
|
if (agent === "pnpm") {
|
|
191
193
|
args.unshift(
|
|
192
194
|
/**
|
|
193
|
-
* Prevent pnpm from removing installed devDeps while `NODE_ENV` is `production
|
|
195
|
+
* Prevent pnpm from removing installed devDeps while `NODE_ENV` is `production`.
|
|
196
|
+
* Uses the `--config.` escape hatch instead of `--prod=false` because pnpm >=12.4.1
|
|
197
|
+
* routes `install <pkg>` through its `add`-compatible parser, which rejects `--prod`.
|
|
194
198
|
* @see https://pnpm.io/cli/install#--prod--p
|
|
199
|
+
* @see https://github.com/pnpm/pnpm/issues/14868
|
|
195
200
|
*/
|
|
196
|
-
"--prod=false"
|
|
201
|
+
"--config.prod=false"
|
|
197
202
|
);
|
|
198
203
|
if (existsSync(resolve(options.cwd ?? process.cwd(), "pnpm-workspace.yaml"))) args.unshift("-w");
|
|
199
204
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fs__default from 'node:fs';
|
|
2
|
-
import { n as normalize, k as splitFileAndPostfix$1, j as join, l as isBareImport } from './pathe.M-eThtNZ.
|
|
2
|
+
import { n as normalize, k as splitFileAndPostfix$1, j as join, l as isBareImport } from './pathe.M-eThtNZ.Ba-7h1rE.js';
|
|
3
3
|
import { i as isBuiltin, a as isBrowserExternal, t as toBuiltin } from './modules.BJuCwlRJ.js';
|
|
4
4
|
import { E as EnvironmentTeardownError, a as getSafeWorkerState } from './utils.DYj33du9.js';
|
|
5
5
|
import { pathToFileURL, URL as URL$1 } from 'node:url';
|
|
@@ -48,7 +48,9 @@ class BareModuleMocker {
|
|
|
48
48
|
return this.registries.get(suite);
|
|
49
49
|
}
|
|
50
50
|
reset() {
|
|
51
|
+
for (const registry of this.registries.values()) for (const url of registry.keys()) this.invalidateModuleById(registry.get(url).id);
|
|
51
52
|
this.registries.clear();
|
|
53
|
+
BareModuleMocker.pendingIds = [];
|
|
52
54
|
}
|
|
53
55
|
invalidateModuleById(_id) {
|
|
54
56
|
// implemented by mockers that control the module runner
|
|
@@ -304,9 +306,6 @@ class VitestMocker extends BareModuleMocker {
|
|
|
304
306
|
if (this.spyModule) return;
|
|
305
307
|
this.spyModule = await this.moduleRunner.import(spyModulePath);
|
|
306
308
|
}
|
|
307
|
-
reset() {
|
|
308
|
-
this.registries.clear();
|
|
309
|
-
}
|
|
310
309
|
invalidateModuleById(id) {
|
|
311
310
|
const mockId = this.getMockPath(id);
|
|
312
311
|
const node = this.evaluatedModules.getModuleById(mockId);
|
|
@@ -373,7 +372,7 @@ If you need to partially mock a module, you can use "importOriginal" helper insi
|
|
|
373
372
|
const Object = this.primitives.Object;
|
|
374
373
|
return this.mockObject(mod, Object.create(Object.prototype), mock.type);
|
|
375
374
|
}
|
|
376
|
-
if (mock.type === "manual") return this.callFunctionMock(id, url, mock);
|
|
375
|
+
if (mock.type === "manual") return this.callFunctionMock(this.getMockPath(id), this.getMockPath(url), mock);
|
|
377
376
|
const node = await this.moduleRunner.fetchModule(mock.redirect);
|
|
378
377
|
return this.moduleRunner.cachedRequest(mock.redirect, node, [importer], void 0, true);
|
|
379
378
|
}
|
|
@@ -565,6 +564,7 @@ class VitestModuleRunner extends viteModuleRunner.ModuleRunner {
|
|
|
565
564
|
return await this.cachedModule(url, importer);
|
|
566
565
|
}
|
|
567
566
|
_cachedRequest(url, module, callstack = [], metadata) {
|
|
567
|
+
this.vitestOptions.getWorkerState().dependencies?.add(module.id);
|
|
568
568
|
// @ts-expect-error "cachedRequest" is private
|
|
569
569
|
return super.cachedRequest(url, module, callstack, metadata);
|
|
570
570
|
}
|
|
@@ -577,7 +577,6 @@ class VitestModuleRunner extends viteModuleRunner.ModuleRunner {
|
|
|
577
577
|
if (ignoreMock) return this._cachedRequest(url, mod, callstack, metadata);
|
|
578
578
|
let mocked;
|
|
579
579
|
if (mod.meta && "mockedModule" in mod.meta) {
|
|
580
|
-
const mockedModule = mod.meta.mockedModule;
|
|
581
580
|
const mockId = this.mocker.getMockPath(mod.id);
|
|
582
581
|
const currentMock = this.mocker.getDependencyMock(mod.id);
|
|
583
582
|
// bypass mock and force "importActual" behavior when:
|
|
@@ -590,7 +589,7 @@ class VitestModuleRunner extends viteModuleRunner.ModuleRunner {
|
|
|
590
589
|
const node = await this.fetchModule(injectQuery(url, "_vitest_original"));
|
|
591
590
|
return this._cachedRequest(node.url, node, callstack, metadata);
|
|
592
591
|
}
|
|
593
|
-
if (
|
|
592
|
+
if (currentMock.type === "automock" || currentMock.type === "autospy") {
|
|
594
593
|
const freshNode = await this.fetchModule(injectQuery(url, "_vitest_original"));
|
|
595
594
|
mocked = await this.mocker.requestWithMockedModule(url, freshNode, callstack, currentMock);
|
|
596
595
|
} else mocked = await this.mocker.requestWithMockedModule(url, mod, callstack, currentMock);
|
|
@@ -639,7 +638,10 @@ function getCachedVitestImport(id, state) {
|
|
|
639
638
|
const relativeRoot = relativeIds[root] ?? (relativeIds[root] = getRelativeDistDir(root));
|
|
640
639
|
if (id.includes(distDir) || id.includes(normalizedDistDir)) {
|
|
641
640
|
const { file, postfix } = splitFileAndPostfix$1(id);
|
|
642
|
-
|
|
641
|
+
// Vite resolves the Windows drive letter in upper case, but Node.js caches
|
|
642
|
+
// modules by URL, so keep the drive letter Vitest itself was loaded with
|
|
643
|
+
const path = file.startsWith(normalizedDistDir) ? distDir + file.slice(normalizedDistDir.length) : file;
|
|
644
|
+
const externalize = id.startsWith("file://") ? id : `${pathToFileURL(path)}${postfix}`;
|
|
643
645
|
externalizeMap.set(id, externalize);
|
|
644
646
|
return {
|
|
645
647
|
externalize,
|
|
@@ -765,7 +767,8 @@ function startVitestModuleRunner(options) {
|
|
|
765
767
|
id: resolvedMock.id,
|
|
766
768
|
url: resolvedMock.url,
|
|
767
769
|
invalidate: false,
|
|
768
|
-
|
|
770
|
+
// the module node outlives the test file, so it must not keep the mock factory alive
|
|
771
|
+
mockedModule: true
|
|
769
772
|
};
|
|
770
773
|
}
|
|
771
774
|
if (isBuiltin(rawId)) return {
|
|
@@ -788,13 +791,15 @@ function startVitestModuleRunner(options) {
|
|
|
788
791
|
// the null prototype is not preserved by the IPC serialization, so
|
|
789
792
|
// ids like "constructor" must not fall through to Object.prototype
|
|
790
793
|
const warmResult = warm && (Object.hasOwn(warm, id) ? warm[id] : Object.hasOwn(warm, rawId) ? warm[rawId] : void 0);
|
|
791
|
-
if (warmResult)
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
794
|
+
if (warmResult) {
|
|
795
|
+
if ("tmp" in warmResult) try {
|
|
796
|
+
return {
|
|
797
|
+
code: readFileSync(warmResult.tmp, "utf-8"),
|
|
798
|
+
...warmResult
|
|
799
|
+
};
|
|
800
|
+
} catch {}
|
|
801
|
+
else return warmResult;
|
|
802
|
+
}
|
|
798
803
|
}
|
|
799
804
|
const otelCarrier = traces?.getContextCarrier();
|
|
800
805
|
const result = await trackFetchTime(rpc().fetch(id, importer, environment(), options, otelCarrier));
|
|
@@ -1526,43 +1531,45 @@ var node = {
|
|
|
1526
1531
|
let context = vm.createContext();
|
|
1527
1532
|
let global = vm.runInContext("this", context);
|
|
1528
1533
|
const contextGlobals = new Set(Object.getOwnPropertyNames(global));
|
|
1529
|
-
for (const [nodeGlobalsKey, descriptor] of nodeGlobals) if (!contextGlobals.has(nodeGlobalsKey))
|
|
1530
|
-
configurable
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1534
|
+
for (const [nodeGlobalsKey, descriptor] of nodeGlobals) if (!contextGlobals.has(nodeGlobalsKey)) {
|
|
1535
|
+
if (descriptor.configurable) Object.defineProperty(global, nodeGlobalsKey, {
|
|
1536
|
+
configurable: true,
|
|
1537
|
+
enumerable: descriptor.enumerable,
|
|
1538
|
+
get() {
|
|
1539
|
+
// @ts-expect-error: no index signature
|
|
1540
|
+
const val = globalThis[nodeGlobalsKey];
|
|
1541
|
+
// override lazy getter
|
|
1542
|
+
Object.defineProperty(global, nodeGlobalsKey, {
|
|
1543
|
+
configurable: true,
|
|
1544
|
+
enumerable: descriptor.enumerable,
|
|
1545
|
+
value: val,
|
|
1546
|
+
writable: descriptor.writable === true || nodeGlobalsKey === "performance"
|
|
1547
|
+
});
|
|
1548
|
+
return val;
|
|
1549
|
+
},
|
|
1550
|
+
set(val) {
|
|
1551
|
+
// override lazy getter
|
|
1552
|
+
Object.defineProperty(global, nodeGlobalsKey, {
|
|
1553
|
+
configurable: true,
|
|
1554
|
+
enumerable: descriptor.enumerable,
|
|
1555
|
+
value: val,
|
|
1556
|
+
writable: true
|
|
1557
|
+
});
|
|
1558
|
+
}
|
|
1559
|
+
});
|
|
1560
|
+
else if ("value" in descriptor) Object.defineProperty(global, nodeGlobalsKey, {
|
|
1561
|
+
configurable: false,
|
|
1562
|
+
enumerable: descriptor.enumerable,
|
|
1563
|
+
value: descriptor.value,
|
|
1564
|
+
writable: descriptor.writable
|
|
1565
|
+
});
|
|
1566
|
+
else Object.defineProperty(global, nodeGlobalsKey, {
|
|
1567
|
+
configurable: false,
|
|
1568
|
+
enumerable: descriptor.enumerable,
|
|
1569
|
+
get: descriptor.get,
|
|
1570
|
+
set: descriptor.set
|
|
1571
|
+
});
|
|
1572
|
+
}
|
|
1566
1573
|
global.global = global;
|
|
1567
1574
|
global.Buffer = Buffer;
|
|
1568
1575
|
global.ArrayBuffer = ArrayBuffer;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as chai from 'chai';
|
|
2
2
|
import { createHook } from 'node:async_hooks';
|
|
3
|
-
import { t as takeCoverageInsideWorker } from './coverage.
|
|
4
|
-
import { r as rpc } from './rpc.
|
|
5
|
-
import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.
|
|
3
|
+
import { t as takeCoverageInsideWorker } from './coverage.-bm5IxnW.js';
|
|
4
|
+
import { r as rpc } from './rpc.DpkUyY1N.js';
|
|
5
|
+
import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.HGAqWOnX.js';
|
|
6
6
|
import { g as getWorkerState } from './utils.DYj33du9.js';
|
|
7
|
-
import { T as TestRunner } from './index.
|
|
7
|
+
import { T as TestRunner } from './index.aTZaPVhf.js';
|
|
8
8
|
|
|
9
9
|
function setupChaiConfig(config) {
|
|
10
10
|
Object.assign(chai.config, config);
|
|
@@ -12,7 +12,7 @@ function setupChaiConfig(config) {
|
|
|
12
12
|
|
|
13
13
|
async function resolveSnapshotEnvironment(config, moduleRunner) {
|
|
14
14
|
if (!config.snapshotEnvironment) {
|
|
15
|
-
const { VitestNodeSnapshotEnvironment } = await import('./node.
|
|
15
|
+
const { VitestNodeSnapshotEnvironment } = await import('./node.uQulW0ei.js');
|
|
16
16
|
return new VitestNodeSnapshotEnvironment();
|
|
17
17
|
}
|
|
18
18
|
const mod = await moduleRunner.import(config.snapshotEnvironment);
|
|
@@ -50,6 +50,8 @@ function detectAsyncLeaks(testFile, projectName) {
|
|
|
50
50
|
} finally {
|
|
51
51
|
Error.stackTraceLimit = limit;
|
|
52
52
|
}
|
|
53
|
+
// a builtin loaded on first use can create pending promises at the module level
|
|
54
|
+
if (stack.includes("node:internal/bootstrap/realm")) return;
|
|
53
55
|
if (!stack.includes(testFile)) {
|
|
54
56
|
const trigger = resources.get(triggerAsyncId);
|
|
55
57
|
if (!trigger) return;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $ } from './tinyrainbow.Do8I1XRG.js';
|
|
2
2
|
|
|
3
3
|
function _mergeNamespaces(n, m) {
|
|
4
4
|
m.forEach(function (e) {
|
|
@@ -508,6 +508,7 @@ function requireReactIs_production () {
|
|
|
508
508
|
type === REACT_STRICT_MODE_TYPE ||
|
|
509
509
|
type === REACT_SUSPENSE_TYPE ||
|
|
510
510
|
type === REACT_SUSPENSE_LIST_TYPE ||
|
|
511
|
+
type === REACT_VIEW_TRANSITION_TYPE ||
|
|
511
512
|
("object" === typeof type &&
|
|
512
513
|
null !== type &&
|
|
513
514
|
(type.$$typeof === REACT_LAZY_TYPE ||
|
|
@@ -648,6 +649,7 @@ function requireReactIs_development$1 () {
|
|
|
648
649
|
type === REACT_STRICT_MODE_TYPE ||
|
|
649
650
|
type === REACT_SUSPENSE_TYPE ||
|
|
650
651
|
type === REACT_SUSPENSE_LIST_TYPE ||
|
|
652
|
+
type === REACT_VIEW_TRANSITION_TYPE ||
|
|
651
653
|
("object" === typeof type &&
|
|
652
654
|
null !== type &&
|
|
653
655
|
(type.$$typeof === REACT_LAZY_TYPE ||
|
|
@@ -1071,7 +1073,7 @@ function printFunction(val, printFunctionName) {
|
|
|
1071
1073
|
return `[Function ${val.name || "anonymous"}]`;
|
|
1072
1074
|
}
|
|
1073
1075
|
function printSymbol(val) {
|
|
1074
|
-
return
|
|
1076
|
+
return Symbol.prototype.toString.call(val).replace(SYMBOL_REGEXP, "Symbol($1)");
|
|
1075
1077
|
}
|
|
1076
1078
|
function printError(val) {
|
|
1077
1079
|
return `[${errorToString.call(val)}]`;
|
|
@@ -1239,7 +1241,7 @@ function validateOptions(options) {
|
|
|
1239
1241
|
function getColorsHighlight() {
|
|
1240
1242
|
return DEFAULT_THEME_KEYS.reduce((colors, key) => {
|
|
1241
1243
|
const value = DEFAULT_THEME[key];
|
|
1242
|
-
const color = value &&
|
|
1244
|
+
const color = value && $[value];
|
|
1243
1245
|
if (color && typeof color.close === "string" && typeof color.open === "string") colors[key] = color;
|
|
1244
1246
|
else throw new Error(`pretty-format: Option "theme" has a key "${key}" whose value "${value}" is undefined in ansi-styles.`);
|
|
1245
1247
|
return colors;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { b as printDiffOrStringify, d as diff, a as processError, T as TestSyntaxError, g as getCurrentTest, c as createTaskCollector, e as getCurrentSuite, f as createChainable, h as getHooks, i as getFn, m as matchesTags, j as afterAll, k as afterEach, l as aroundAll, n as aroundEach, o as beforeAll, q as beforeEach, r as describe, t as it, u as onTestFailed, v as onTestFinished, w as recordArtifact, x as suite, y as test } from './run.
|
|
1
|
+
import { b as printDiffOrStringify, d as diff, a as processError, T as TestSyntaxError, g as getCurrentTest, c as createTaskCollector, e as getCurrentSuite, f as createChainable, h as getHooks, i as getFn, m as matchesTags, j as afterAll, k as afterEach, l as aroundAll, n as aroundEach, o as beforeAll, q as beforeEach, r as describe, t as it, u as onTestFailed, v as onTestFinished, w as recordArtifact, x as suite, y as test } from './run.BPv-BBRv.js';
|
|
2
2
|
import { i as isChildProcess, r as resetModules, g as getWorkerState } from './utils.DYj33du9.js';
|
|
3
|
-
import { e as parseErrorStacktrace, a as getSafeTimers, f as parseSingleStack, h as delay } from './source-map.
|
|
4
|
-
import { i as isMockFunction, f as fn, a as spyOn, r as restoreAllMocks, b as resetAllMocks, c as clearAllMocks } from './spy.
|
|
5
|
-
import { u as isObject, B as getCallLastIndex, g as getType, D as noop, x as assertTypes, w as ordinal, E as createSimpleStackTrace, i as isAbsolute, a as relative, n as normalize } from './pathe.M-eThtNZ.
|
|
6
|
-
import { g as getDefaultExportFromCjs, f as format, a as commonjsGlobal } from './index.
|
|
7
|
-
import { s as stringify, i as inspect } from './display.
|
|
8
|
-
import {
|
|
3
|
+
import { e as parseErrorStacktrace, a as getSafeTimers, f as parseSingleStack, h as delay } from './source-map.DdKI5IHB.js';
|
|
4
|
+
import { i as isMockFunction, f as fn, a as spyOn, r as restoreAllMocks, b as resetAllMocks, c as clearAllMocks } from './spy.DDMXghXv.js';
|
|
5
|
+
import { u as isObject, B as getCallLastIndex, g as getType, D as noop, x as assertTypes, w as ordinal, E as createSimpleStackTrace, i as isAbsolute, a as relative, n as normalize } from './pathe.M-eThtNZ.Ba-7h1rE.js';
|
|
6
|
+
import { g as getDefaultExportFromCjs, f as format, a as commonjsGlobal } from './index.D0heQG4v.js';
|
|
7
|
+
import { s as stringify, i as inspect } from './display.BlTmubjj.js';
|
|
8
|
+
import { $ } from './tinyrainbow.Do8I1XRG.js';
|
|
9
9
|
import * as chai from 'chai';
|
|
10
10
|
import { use, util } from 'chai';
|
|
11
11
|
import { getNames, getTests, getTestName, createFileTask } from '../task-utils.js';
|
|
12
|
-
import { g as getSerializers, a as addSerializer } from './plugins.
|
|
12
|
+
import { g as getSerializers, a as addSerializer } from './plugins.DPQHVT0p.js';
|
|
13
13
|
import { p as positionToOffset, o as offsetToLineNumber, l as lineSplitRE } from './offset.Dy-5Fdfn.js';
|
|
14
|
-
import { r as rpc, V as VitestEvaluatedModules } from './rpc.
|
|
14
|
+
import { r as rpc, V as VitestEvaluatedModules } from './rpc.DpkUyY1N.js';
|
|
15
15
|
import { Bench } from 'tinybench';
|
|
16
16
|
import { expectTypeOf } from 'expect-type';
|
|
17
17
|
|
|
@@ -133,7 +133,8 @@ function serialize(val, indent = 2, formatOverrides = {}) {
|
|
|
133
133
|
}));
|
|
134
134
|
}
|
|
135
135
|
function escapeBacktickString(str) {
|
|
136
|
-
|
|
136
|
+
// a raw CR inside a template literal is read back as LF
|
|
137
|
+
return str.replace(/`|\\|\$\{/g, "\\$&").replace(/\r/g, "\\r");
|
|
137
138
|
}
|
|
138
139
|
function printBacktickString(str) {
|
|
139
140
|
return `\`${escapeBacktickString(str)}\``;
|
|
@@ -176,9 +177,10 @@ function deepMergeSnapshot(target, source) {
|
|
|
176
177
|
if (isObject(target) && isObject(source)) {
|
|
177
178
|
const mergedOutput = { ...target };
|
|
178
179
|
Object.keys(source).forEach((key) => {
|
|
179
|
-
if (isObject(source[key]) && !source[key].$$typeof)
|
|
180
|
-
|
|
181
|
-
|
|
180
|
+
if (isObject(source[key]) && !source[key].$$typeof) {
|
|
181
|
+
if (!(key in target)) Object.assign(mergedOutput, { [key]: source[key] });
|
|
182
|
+
else mergedOutput[key] = deepMergeSnapshot(target[key], source[key]);
|
|
183
|
+
} else if (Array.isArray(source[key])) mergedOutput[key] = deepMergeArray(target[key], source[key]);
|
|
182
184
|
else Object.assign(mergedOutput, { [key]: source[key] });
|
|
183
185
|
});
|
|
184
186
|
return mergedOutput;
|
|
@@ -378,6 +380,7 @@ class SnapshotState {
|
|
|
378
380
|
_inlineSnapshotStacks;
|
|
379
381
|
_testIdToKeys = new DefaultMap(() => []);
|
|
380
382
|
_rawSnapshots;
|
|
383
|
+
_rawSnapshotFiles = /* @__PURE__ */ new Set();
|
|
381
384
|
_uncheckedKeys;
|
|
382
385
|
_snapshotFormat;
|
|
383
386
|
_environment;
|
|
@@ -571,17 +574,18 @@ class SnapshotState {
|
|
|
571
574
|
// * The update flag is set to 'none'.
|
|
572
575
|
// * There's no snapshot file or a file without this snapshot on a CI environment.
|
|
573
576
|
if (opts.hasSnapshot && this._updateSnapshot === "all" || (!opts.hasSnapshot || !opts.snapshotIsPersisted) && (this._updateSnapshot === "new" || this._updateSnapshot === "all")) {
|
|
574
|
-
if (this._updateSnapshot === "all")
|
|
575
|
-
if (opts.
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
577
|
+
if (this._updateSnapshot === "all") {
|
|
578
|
+
if (!opts.pass) {
|
|
579
|
+
if (opts.hasSnapshot) this.updated.increment(opts.testId);
|
|
580
|
+
else this.added.increment(opts.testId);
|
|
581
|
+
this._addSnapshot(opts.key, opts.addValue, {
|
|
582
|
+
stack: opts.stack,
|
|
583
|
+
testId: opts.testId,
|
|
584
|
+
rawSnapshot: opts.rawSnapshot,
|
|
585
|
+
assertionName: opts.assertionName
|
|
586
|
+
});
|
|
587
|
+
} else this.matched.increment(opts.testId);
|
|
588
|
+
} else {
|
|
585
589
|
this._addSnapshot(opts.key, opts.addValue, {
|
|
586
590
|
stack: opts.stack,
|
|
587
591
|
testId: opts.testId,
|
|
@@ -681,6 +685,7 @@ class SnapshotState {
|
|
|
681
685
|
let receivedSerialized = rawSnapshot && typeof received === "string" ? received : serialize(received, void 0, this._snapshotFormat);
|
|
682
686
|
if (!rawSnapshot) receivedSerialized = addExtraLineBreaks(receivedSerialized);
|
|
683
687
|
if (rawSnapshot) {
|
|
688
|
+
this._rawSnapshotFiles.add(rawSnapshot.file);
|
|
684
689
|
// normalize EOL when snapshot contains CRLF but received is LF
|
|
685
690
|
if (rawSnapshot.content && /\r\n/.test(rawSnapshot.content) && !/\r\n/.test(receivedSerialized)) rawSnapshot.content = normalizeNewlines(rawSnapshot.content);
|
|
686
691
|
}
|
|
@@ -741,6 +746,14 @@ class SnapshotState {
|
|
|
741
746
|
assertionName
|
|
742
747
|
});
|
|
743
748
|
}
|
|
749
|
+
/**
|
|
750
|
+
* The snapshot file, if the test file stores snapshots in it, and every asserted file snapshot.
|
|
751
|
+
*/
|
|
752
|
+
getSnapshotFiles() {
|
|
753
|
+
const files = Array.from(this._rawSnapshotFiles);
|
|
754
|
+
if (this._fileExists || Object.keys(this._snapshotData).length) files.unshift(this.snapshotPath);
|
|
755
|
+
return files;
|
|
756
|
+
}
|
|
744
757
|
async pack() {
|
|
745
758
|
const snapshot = {
|
|
746
759
|
filepath: this.testFilePath,
|
|
@@ -1066,7 +1079,7 @@ const ChaiStyleAssertions = (chai, utils) => {
|
|
|
1066
1079
|
defMethod("calledOnceWith", "toHaveBeenCalledExactlyOnceWith");
|
|
1067
1080
|
defMethod("lastCalledWith", "toHaveBeenLastCalledWith");
|
|
1068
1081
|
defMethod("nthCalledWith", "toHaveBeenNthCalledWith");
|
|
1069
|
-
defMethod("returned", "
|
|
1082
|
+
defMethod("returned", "toHaveReturnedWith");
|
|
1070
1083
|
defMethod("returnedWith", "toHaveReturnedWith");
|
|
1071
1084
|
defMethod("returnedTimes", "toHaveReturnedTimes");
|
|
1072
1085
|
defMethod("lastReturnedWith", "toHaveLastReturnedWith");
|
|
@@ -1107,10 +1120,11 @@ ${printReceived(actual)}`
|
|
|
1107
1120
|
},
|
|
1108
1121
|
toBeOneOf(actual, expected) {
|
|
1109
1122
|
const { equals, customTesters } = this;
|
|
1110
|
-
const { printReceived, printExpected, matcherHint } = this.utils;
|
|
1123
|
+
const { printReceived, printExpected, matcherHint, iterableEquality } = this.utils;
|
|
1124
|
+
const testers = [...customTesters, iterableEquality];
|
|
1111
1125
|
let pass;
|
|
1112
|
-
if (Array.isArray(expected)) pass = expected.length === 0 || expected.some((item) => equals(item, actual,
|
|
1113
|
-
else if (expected instanceof Set) pass = expected.size === 0 || expected.has(actual) || [...expected].some((item) => equals(item, actual,
|
|
1126
|
+
if (Array.isArray(expected)) pass = expected.length === 0 || expected.some((item) => equals(item, actual, testers));
|
|
1127
|
+
else if (expected instanceof Set) pass = expected.size === 0 || expected.has(actual) || [...expected].some((item) => equals(item, actual, testers));
|
|
1114
1128
|
else throw new TypeError(`You must provide an array or set to ${matcherHint(".toBeOneOf")}, not '${typeof expected}'.`);
|
|
1115
1129
|
return {
|
|
1116
1130
|
pass,
|
|
@@ -1132,11 +1146,11 @@ ${printReceived(actual)}`
|
|
|
1132
1146
|
}
|
|
1133
1147
|
};
|
|
1134
1148
|
|
|
1135
|
-
const EXPECTED_COLOR =
|
|
1136
|
-
const RECEIVED_COLOR =
|
|
1137
|
-
const INVERTED_COLOR =
|
|
1138
|
-
const BOLD_WEIGHT =
|
|
1139
|
-
const DIM_COLOR =
|
|
1149
|
+
const EXPECTED_COLOR = $.green;
|
|
1150
|
+
const RECEIVED_COLOR = $.red;
|
|
1151
|
+
const INVERTED_COLOR = $.inverse;
|
|
1152
|
+
const BOLD_WEIGHT = $.bold;
|
|
1153
|
+
const DIM_COLOR = $.dim;
|
|
1140
1154
|
function matcherHint(matcherName, received = "received", expected = "expected", options = {}) {
|
|
1141
1155
|
const { comment = "", isDirectExpectCall = false, isNot = false, promise = "", secondArgument = "", expectedColor = EXPECTED_COLOR, receivedColor = RECEIVED_COLOR, secondArgumentColor = EXPECTED_COLOR } = options;
|
|
1142
1156
|
let hint = "";
|
|
@@ -1983,10 +1997,12 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
1983
1997
|
if (promise === "rejects") utils.flag(this, "object", () => {
|
|
1984
1998
|
throw object;
|
|
1985
1999
|
});
|
|
1986
|
-
else if (promise === "resolves" && typeof object !== "function")
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
2000
|
+
else if (promise === "resolves" && typeof object !== "function") {
|
|
2001
|
+
if (!isNot) {
|
|
2002
|
+
const message = utils.flag(this, "message") || "expected promise to throw an error, but it didn't";
|
|
2003
|
+
throw new AssertionError(message, { showDiff: false }, utils.flag(this, "ssfi"));
|
|
2004
|
+
} else return;
|
|
2005
|
+
}
|
|
1990
2006
|
_super.apply(this, args);
|
|
1991
2007
|
};
|
|
1992
2008
|
});
|
|
@@ -2079,7 +2095,7 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
2079
2095
|
def("toContainEqual", function(expected) {
|
|
2080
2096
|
const obj = utils.flag(this, "object");
|
|
2081
2097
|
const index = Array.from(obj).findIndex((item) => {
|
|
2082
|
-
return equals(item, expected, customTesters);
|
|
2098
|
+
return equals(item, expected, [...customTesters, iterableEquality]);
|
|
2083
2099
|
});
|
|
2084
2100
|
this.assert(index !== -1, "expected #{this} to deep equally contain #{exp}", "expected #{this} to not deep equally contain #{exp}", expected);
|
|
2085
2101
|
});
|
|
@@ -2160,7 +2176,7 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
2160
2176
|
return utils.getPathInfo(actual, propertyName);
|
|
2161
2177
|
};
|
|
2162
2178
|
const { value, exists } = getValue();
|
|
2163
|
-
const pass = exists && (args.length === 1 || equals(expected, value, customTesters));
|
|
2179
|
+
const pass = exists && (args.length === 1 || equals(expected, value, [...customTesters, iterableEquality]));
|
|
2164
2180
|
const valueString = args.length === 1 ? "" : ` with value ${inspect(expected, { truncate: 40 })}`;
|
|
2165
2181
|
return this.assert(pass, `expected #{this} to have property "${propertyName}"${valueString}`, `expected #{this} to not have property "${propertyName}"${valueString}`, expected, exists ? value : void 0);
|
|
2166
2182
|
});
|
|
@@ -2290,11 +2306,12 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
2290
2306
|
const isNot = utils.flag(this, "negate");
|
|
2291
2307
|
let thrown = null;
|
|
2292
2308
|
if (promise === "rejects") thrown = obj;
|
|
2293
|
-
else if (promise === "resolves" && typeof obj !== "function")
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2309
|
+
else if (promise === "resolves" && typeof obj !== "function") {
|
|
2310
|
+
if (!isNot) {
|
|
2311
|
+
const message = utils.flag(this, "message") || "expected promise to throw an error, but it didn't";
|
|
2312
|
+
throw new AssertionError(message, { showDiff: false }, utils.flag(this, "ssfi"));
|
|
2313
|
+
} else return;
|
|
2314
|
+
} else {
|
|
2298
2315
|
let isThrow = false;
|
|
2299
2316
|
try {
|
|
2300
2317
|
obj();
|
|
@@ -2317,7 +2334,7 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
2317
2334
|
}
|
|
2318
2335
|
if (typeof expected === "object" && "asymmetricMatch" in expected && typeof expected.asymmetricMatch === "function") {
|
|
2319
2336
|
const matcher = expected;
|
|
2320
|
-
return this.assert(thrown && matcher.asymmetricMatch(thrown), "expected error to match asymmetric matcher", "expected error not to match asymmetric matcher", matcher, thrown);
|
|
2337
|
+
return this.assert(thrown && matcher.asymmetricMatch(thrown, [...customTesters, iterableEquality]), "expected error to match asymmetric matcher", "expected error not to match asymmetric matcher", matcher, thrown);
|
|
2321
2338
|
}
|
|
2322
2339
|
const equal = equals(thrown, expected, [...customTesters, iterableEquality]);
|
|
2323
2340
|
return this.assert(equal, "expected a thrown value to equal #{exp}", "expected a thrown value not to equal #{exp}", expected, thrown);
|
|
@@ -2356,11 +2373,11 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
2356
2373
|
});
|
|
2357
2374
|
[{
|
|
2358
2375
|
name: "toHaveResolvedWith",
|
|
2359
|
-
condition: (spy, value) => spy.mock.settledResults.some(({ type, value: result }) => type === "fulfilled" && equals(value, result)),
|
|
2376
|
+
condition: (spy, value) => spy.mock.settledResults.some(({ type, value: result }) => type === "fulfilled" && equals(value, result, [...customTesters, iterableEquality])),
|
|
2360
2377
|
action: "resolve"
|
|
2361
2378
|
}, {
|
|
2362
2379
|
name: ["toHaveReturnedWith", "toReturnWith"],
|
|
2363
|
-
condition: (spy, value) => spy.mock.results.some(({ type, value: result }) => type === "return" && equals(value, result)),
|
|
2380
|
+
condition: (spy, value) => spy.mock.results.some(({ type, value: result }) => type === "return" && equals(value, result, [...customTesters, iterableEquality])),
|
|
2364
2381
|
action: "return"
|
|
2365
2382
|
}].forEach(({ name, condition, action }) => {
|
|
2366
2383
|
def(name, function(value) {
|
|
@@ -2384,14 +2401,14 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
2384
2401
|
name: "toHaveLastResolvedWith",
|
|
2385
2402
|
condition: (spy, value) => {
|
|
2386
2403
|
const result = spy.mock.settledResults.at(-1);
|
|
2387
|
-
return Boolean(result && result.type === "fulfilled" && equals(result.value, value));
|
|
2404
|
+
return Boolean(result && result.type === "fulfilled" && equals(result.value, value, [...customTesters, iterableEquality]));
|
|
2388
2405
|
},
|
|
2389
2406
|
action: "resolve"
|
|
2390
2407
|
}, {
|
|
2391
2408
|
name: "toHaveLastReturnedWith",
|
|
2392
2409
|
condition: (spy, value) => {
|
|
2393
2410
|
const result = spy.mock.results.at(-1);
|
|
2394
|
-
return Boolean(result && result.type === "return" && equals(result.value, value));
|
|
2411
|
+
return Boolean(result && result.type === "return" && equals(result.value, value, [...customTesters, iterableEquality]));
|
|
2395
2412
|
},
|
|
2396
2413
|
action: "return"
|
|
2397
2414
|
}].forEach(({ name, condition, action }) => {
|
|
@@ -2406,14 +2423,14 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
2406
2423
|
name: "toHaveNthResolvedWith",
|
|
2407
2424
|
condition: (spy, index, value) => {
|
|
2408
2425
|
const result = spy.mock.settledResults[index - 1];
|
|
2409
|
-
return result && result.type === "fulfilled" && equals(result.value, value);
|
|
2426
|
+
return result && result.type === "fulfilled" && equals(result.value, value, [...customTesters, iterableEquality]);
|
|
2410
2427
|
},
|
|
2411
2428
|
action: "resolve"
|
|
2412
2429
|
}, {
|
|
2413
2430
|
name: "toHaveNthReturnedWith",
|
|
2414
2431
|
condition: (spy, index, value) => {
|
|
2415
2432
|
const result = spy.mock.results[index - 1];
|
|
2416
|
-
return result && result.type === "return" && equals(result.value, value);
|
|
2433
|
+
return result && result.type === "return" && equals(result.value, value, [...customTesters, iterableEquality]);
|
|
2417
2434
|
},
|
|
2418
2435
|
action: "return"
|
|
2419
2436
|
}].forEach(({ name, condition, action }) => {
|
|
@@ -2493,25 +2510,25 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
2493
2510
|
});
|
|
2494
2511
|
};
|
|
2495
2512
|
function formatCalls(spy, msg, showActualCall) {
|
|
2496
|
-
if (spy.mock.calls.length) msg +=
|
|
2497
|
-
let methodCall =
|
|
2513
|
+
if (spy.mock.calls.length) msg += $.gray(`\n\nReceived:\n\n${spy.mock.calls.map((callArg, i) => {
|
|
2514
|
+
let methodCall = $.bold(` ${ordinal(i + 1)} ${spy.getMockName()} call:\n\n`);
|
|
2498
2515
|
if (showActualCall) methodCall += diff(showActualCall, callArg, { omitAnnotationLines: true });
|
|
2499
2516
|
else methodCall += stringify(callArg).split("\n").map((line) => ` ${line}`).join("\n");
|
|
2500
2517
|
methodCall += "\n";
|
|
2501
2518
|
return methodCall;
|
|
2502
2519
|
}).join("\n")}`);
|
|
2503
|
-
msg +=
|
|
2520
|
+
msg += $.gray(`\n\nNumber of calls: ${$.bold(spy.mock.calls.length)}\n`);
|
|
2504
2521
|
return msg;
|
|
2505
2522
|
}
|
|
2506
2523
|
function formatReturns(spy, results, msg, showActualReturn) {
|
|
2507
|
-
if (results.length) msg +=
|
|
2508
|
-
let methodCall =
|
|
2524
|
+
if (results.length) msg += $.gray(`\n\nReceived:\n\n${results.map((callReturn, i) => {
|
|
2525
|
+
let methodCall = $.bold(` ${ordinal(i + 1)} ${spy.getMockName()} call return:\n\n`);
|
|
2509
2526
|
if (showActualReturn) methodCall += diff(showActualReturn, callReturn.value, { omitAnnotationLines: true });
|
|
2510
2527
|
else methodCall += stringify(callReturn).split("\n").map((line) => ` ${line}`).join("\n");
|
|
2511
2528
|
methodCall += "\n";
|
|
2512
2529
|
return methodCall;
|
|
2513
2530
|
}).join("\n")}`);
|
|
2514
|
-
msg +=
|
|
2531
|
+
msg += $.gray(`\n\nNumber of calls: ${$.bold(spy.mock.calls.length)}\n`);
|
|
2515
2532
|
return msg;
|
|
2516
2533
|
}
|
|
2517
2534
|
|
|
@@ -6883,13 +6900,15 @@ class FakeTimers {
|
|
|
6883
6900
|
return 0;
|
|
6884
6901
|
}
|
|
6885
6902
|
setTimerTickMode(mode, interval) {
|
|
6886
|
-
if (this._checkFakeTimers())
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
mode
|
|
6890
|
-
|
|
6891
|
-
|
|
6892
|
-
|
|
6903
|
+
if (this._checkFakeTimers()) {
|
|
6904
|
+
if (mode === "manual") this._clock.setTickMode({ mode: "manual" });
|
|
6905
|
+
else if (mode === "nextTimerAsync") this._clock.setTickMode({ mode: "nextAsync" });
|
|
6906
|
+
else if (mode === "interval") this._clock.setTickMode({
|
|
6907
|
+
mode: "interval",
|
|
6908
|
+
delta: interval
|
|
6909
|
+
});
|
|
6910
|
+
else throw new Error(`Invalid tick mode: ${mode}`);
|
|
6911
|
+
}
|
|
6893
6912
|
}
|
|
6894
6913
|
configure(config) {
|
|
6895
6914
|
this._userConfig = config;
|
|
@@ -8243,8 +8262,8 @@ function createBench(test, config, moduleRunner) {
|
|
|
8243
8262
|
if (excessiveInvocations?.length) {
|
|
8244
8263
|
const entries = excessiveInvocations.map(({ moduleId, exportName }) => ` - ${formatModuleId(moduleId, workerState.config.root)} > ${exportName}`).join("\n");
|
|
8245
8264
|
console.warn([
|
|
8246
|
-
|
|
8247
|
-
`Benchmark ${
|
|
8265
|
+
$.yellow($.bold("Benchmark Warning")),
|
|
8266
|
+
`Benchmark ${$.bold(`"${groupName(options)}"`)} accessed module export getters too many times.`,
|
|
8248
8267
|
"",
|
|
8249
8268
|
"This can make results unreliable because export getters add overhead.",
|
|
8250
8269
|
"See https://vitest.dev/guide/benchmarking#module-runner-overhead",
|
|
@@ -8369,8 +8388,8 @@ function createBench(test, config, moduleRunner) {
|
|
|
8369
8388
|
const names = Array.from(pending, (reg) => `"${reg.name}"`).join(", ");
|
|
8370
8389
|
pending.clear();
|
|
8371
8390
|
console.warn([
|
|
8372
|
-
|
|
8373
|
-
`Test ${
|
|
8391
|
+
$.yellow($.bold("Benchmark Warning")),
|
|
8392
|
+
`Test ${$.bold(`"${test.fullTestName}"`)} registered benchmarks that never ran: ${names}.`,
|
|
8374
8393
|
"",
|
|
8375
8394
|
"Call `.run()` on the registration, or pass it to `bench.compare()`.",
|
|
8376
8395
|
"See https://vitest.dev/guide/benchmarking#defining-a-benchmark"
|
|
@@ -8463,6 +8482,7 @@ class TestRunner {
|
|
|
8463
8482
|
const name = getNames(test).slice(1).join(" > ");
|
|
8464
8483
|
this.snapshotClient.skipTest(suite.file.filepath, name);
|
|
8465
8484
|
}
|
|
8485
|
+
this.snapshotClient.getSnapshotState(suite.file.filepath).getSnapshotFiles().forEach((file) => this.workerState.dependencies?.add(file));
|
|
8466
8486
|
const result = await this.snapshotClient.finish(suite.file.filepath);
|
|
8467
8487
|
if (this.workerState.config.snapshotOptions.updateSnapshot === "none" && result.unchecked) {
|
|
8468
8488
|
let message = `Obsolete snapshots found when no snapshot update is expected.\n`;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isMainThread, parentPort } from 'node:worker_threads';
|
|
2
|
-
import { i as init } from './init.
|
|
2
|
+
import { i as init } from './init.PvxYpuCm.js';
|
|
3
3
|
|
|
4
4
|
if (isMainThread || !parentPort) throw new Error("Expected worker to be run in node:worker_threads");
|
|
5
5
|
function workerInit(options) {
|