vitest 3.2.0-beta.2 → 3.2.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/LICENSE.md +29 -0
- package/dist/browser.d.ts +3 -3
- package/dist/browser.js +2 -2
- package/dist/chunks/{base.DwtwORaC.js → base.Cg0miDlQ.js} +11 -14
- package/dist/chunks/{benchmark.BoF7jW0Q.js → benchmark.CYdenmiT.js} +4 -6
- package/dist/chunks/{cac.I9MLYfT-.js → cac.6rXCxFY1.js} +76 -143
- package/dist/chunks/{cli-api.d6IK1pnk.js → cli-api.Cej3MBjA.js} +1460 -1344
- package/dist/chunks/{config.d.UqE-KR0o.d.ts → config.d.D2ROskhv.d.ts} +2 -0
- package/dist/chunks/{console.K1NMVOSc.js → console.CtFJOzRO.js} +25 -45
- package/dist/chunks/{constants.BZZyIeIE.js → constants.DnKduX2e.js} +1 -0
- package/dist/chunks/{coverage.0iPg4Wrz.js → coverage.DVF1vEu8.js} +4 -12
- package/dist/chunks/{coverage.OGU09Jbh.js → coverage.EIiagJJP.js} +578 -993
- package/dist/chunks/{creator.DGAdZ4Hj.js → creator.GK6I-cL4.js} +39 -83
- package/dist/chunks/date.Bq6ZW5rf.js +73 -0
- package/dist/chunks/{defaults.DSxsTG0h.js → defaults.B7q_naMc.js} +2 -1
- package/dist/chunks/{env.Dq0hM4Xv.js → env.D4Lgay0q.js} +1 -1
- package/dist/chunks/{environment.d.D8YDy2v5.d.ts → environment.d.cL3nLXbE.d.ts} +1 -0
- package/dist/chunks/{execute.JlGHLJZT.js → execute.B7h3T_Hc.js} +126 -217
- package/dist/chunks/{git.DXfdBEfR.js → git.BVQ8w_Sw.js} +1 -3
- package/dist/chunks/{global.d.BPa1eL3O.d.ts → global.d.MAmajcmJ.d.ts} +5 -1
- package/dist/chunks/{globals.CpxW8ccg.js → globals.DEHgCU4V.js} +7 -6
- package/dist/chunks/{index.CV36oG_L.js → index.BZ0g1JD2.js} +430 -625
- package/dist/chunks/{index.DswW_LEs.js → index.BbB8_kAK.js} +25 -24
- package/dist/chunks/{index.CmC5OK9L.js → index.CIyJn3t1.js} +38 -82
- package/dist/chunks/{index.CfXMNXHg.js → index.CdQS2e2Q.js} +4 -2
- package/dist/chunks/{index.DFXFpH3w.js → index.CmSc2RE5.js} +85 -105
- package/dist/chunks/index.D3XRDfWc.js +213 -0
- package/dist/chunks/{inspector.DbDkSkFn.js → inspector.C914Efll.js} +4 -1
- package/dist/chunks/{node.3xsWotC9.js → node.fjCdwEIl.js} +1 -1
- package/dist/chunks/{reporters.d.CLC9rhKy.d.ts → reporters.d.C1ogPriE.d.ts} +47 -9
- package/dist/chunks/{rpc.D9_013TY.js → rpc.Iovn4oWe.js} +10 -19
- package/dist/chunks/{runBaseTests.Dn2vyej_.js → runBaseTests.Dd85QTll.js} +27 -31
- package/dist/chunks/{setup-common.CYo3Y0dD.js → setup-common.Dd054P77.js} +16 -42
- package/dist/chunks/{typechecker.DnTrplSJ.js → typechecker.DRKU1-1g.js} +163 -186
- package/dist/chunks/{utils.BfxieIyZ.js → utils.CAioKnHs.js} +9 -14
- package/dist/chunks/{utils.CgTj3MsC.js → utils.XdZDrNZV.js} +6 -13
- package/dist/chunks/{vi.BFR5YIgu.js → vi.bdSIJ99Y.js} +137 -263
- package/dist/chunks/{vite.d.CBZ3M_ru.d.ts → vite.d.DqE4-hhK.d.ts} +3 -1
- package/dist/chunks/{vm.C1HHjtNS.js → vm.BThCzidc.js} +164 -212
- package/dist/chunks/{worker.d.D5Xdi-Zr.d.ts → worker.d.DvqK5Vmu.d.ts} +1 -1
- package/dist/chunks/{worker.d.CoCI7hzP.d.ts → worker.d.tQu2eJQy.d.ts} +5 -3
- package/dist/cli.js +5 -5
- package/dist/config.cjs +3 -1
- package/dist/config.d.ts +7 -6
- package/dist/config.js +3 -3
- package/dist/coverage.d.ts +4 -4
- package/dist/coverage.js +7 -7
- package/dist/environments.d.ts +6 -2
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +9 -3
- package/dist/execute.js +1 -1
- package/dist/index.d.ts +28 -15
- package/dist/index.js +5 -5
- package/dist/node.d.ts +18 -10
- package/dist/node.js +17 -17
- package/dist/reporters.d.ts +4 -4
- package/dist/reporters.js +4 -4
- package/dist/runners.d.ts +6 -3
- package/dist/runners.js +59 -80
- package/dist/snapshot.js +2 -2
- package/dist/suite.js +2 -2
- package/dist/worker.js +39 -41
- package/dist/workers/forks.js +6 -4
- package/dist/workers/runVmTests.js +20 -21
- package/dist/workers/threads.js +4 -4
- package/dist/workers/vmForks.js +6 -6
- package/dist/workers/vmThreads.js +6 -6
- package/dist/workers.d.ts +4 -4
- package/dist/workers.js +10 -10
- package/package.json +21 -19
- package/dist/chunks/date.CDOsz-HY.js +0 -53
- package/dist/chunks/index.CK1YOQaa.js +0 -143
package/LICENSE.md
CHANGED
|
@@ -372,6 +372,35 @@ Repository: sindresorhus/locate-path
|
|
|
372
372
|
|
|
373
373
|
---------------------------------------
|
|
374
374
|
|
|
375
|
+
## mime
|
|
376
|
+
License: MIT
|
|
377
|
+
By: Robert Kieffer
|
|
378
|
+
Repository: https://github.com/broofa/mime
|
|
379
|
+
|
|
380
|
+
> MIT License
|
|
381
|
+
>
|
|
382
|
+
> Copyright (c) 2023 Robert Kieffer
|
|
383
|
+
>
|
|
384
|
+
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
385
|
+
> of this software and associated documentation files (the "Software"), to deal
|
|
386
|
+
> in the Software without restriction, including without limitation the rights
|
|
387
|
+
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
388
|
+
> copies of the Software, and to permit persons to whom the Software is
|
|
389
|
+
> furnished to do so, subject to the following conditions:
|
|
390
|
+
>
|
|
391
|
+
> The above copyright notice and this permission notice shall be included in all
|
|
392
|
+
> copies or substantial portions of the Software.
|
|
393
|
+
>
|
|
394
|
+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
395
|
+
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
396
|
+
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
397
|
+
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
398
|
+
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
399
|
+
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
400
|
+
> SOFTWARE.
|
|
401
|
+
|
|
402
|
+
---------------------------------------
|
|
403
|
+
|
|
375
404
|
## mlly
|
|
376
405
|
License: MIT
|
|
377
406
|
Repository: unjs/mlly
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SerializedCoverageConfig, a as SerializedConfig } from './chunks/config.d.
|
|
1
|
+
import { S as SerializedCoverageConfig, a as SerializedConfig } from './chunks/config.d.D2ROskhv.js';
|
|
2
2
|
import { R as RuntimeCoverageModuleLoader } from './chunks/coverage.d.S9RMNXIe.js';
|
|
3
3
|
import { SerializedDiffOptions } from '@vitest/utils/diff';
|
|
4
4
|
import { VitestExecutor } from './execute.js';
|
|
@@ -12,8 +12,8 @@ import '@vitest/snapshot';
|
|
|
12
12
|
import '@vitest/snapshot/environment';
|
|
13
13
|
import 'vite-node/client';
|
|
14
14
|
import 'vite-node';
|
|
15
|
-
import './chunks/worker.d.
|
|
16
|
-
import './chunks/environment.d.
|
|
15
|
+
import './chunks/worker.d.tQu2eJQy.js';
|
|
16
|
+
import './chunks/environment.d.cL3nLXbE.js';
|
|
17
17
|
import 'vitest/optional-types.js';
|
|
18
18
|
import 'node:vm';
|
|
19
19
|
import '@vitest/mocker';
|
package/dist/browser.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { l as loadDiffConfig, b as loadSnapshotSerializers, c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/setup-common.
|
|
1
|
+
export { l as loadDiffConfig, b as loadSnapshotSerializers, c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/setup-common.Dd054P77.js';
|
|
2
2
|
export { collectTests, processError, startTests } from '@vitest/runner';
|
|
3
3
|
import * as spy from '@vitest/spy';
|
|
4
4
|
export { spy as SpyModule };
|
|
5
5
|
export { format, getSafeTimers, inspect, stringify } from '@vitest/utils';
|
|
6
6
|
export { TraceMap, originalPositionFor } from '@vitest/utils/source-map';
|
|
7
|
-
import './chunks/coverage.
|
|
7
|
+
import './chunks/coverage.DVF1vEu8.js';
|
|
8
8
|
import '@vitest/snapshot';
|
|
@@ -1,36 +1,33 @@
|
|
|
1
1
|
import { ModuleCacheMap } from 'vite-node/client';
|
|
2
|
-
import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.
|
|
3
|
-
import { p as provideWorkerState } from './utils.
|
|
2
|
+
import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.B7h3T_Hc.js';
|
|
3
|
+
import { p as provideWorkerState } from './utils.XdZDrNZV.js';
|
|
4
4
|
|
|
5
5
|
let _viteNode;
|
|
6
6
|
const moduleCache = new ModuleCacheMap();
|
|
7
|
-
const moduleExecutionInfo = new Map();
|
|
7
|
+
const moduleExecutionInfo = /* @__PURE__ */ new Map();
|
|
8
8
|
async function startViteNode(options) {
|
|
9
|
-
if (_viteNode)
|
|
10
|
-
return _viteNode;
|
|
11
|
-
}
|
|
9
|
+
if (_viteNode) return _viteNode;
|
|
12
10
|
_viteNode = await startVitestExecutor(options);
|
|
13
11
|
return _viteNode;
|
|
14
12
|
}
|
|
15
13
|
async function runBaseTests(method, state) {
|
|
16
14
|
const { ctx } = state;
|
|
15
|
+
// state has new context, but we want to reuse existing ones
|
|
17
16
|
state.moduleCache = moduleCache;
|
|
18
17
|
state.moduleExecutionInfo = moduleExecutionInfo;
|
|
19
18
|
provideWorkerState(globalThis, state);
|
|
20
|
-
if (ctx.invalidates) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
});
|
|
25
|
-
}
|
|
19
|
+
if (ctx.invalidates) ctx.invalidates.forEach((fsPath) => {
|
|
20
|
+
moduleCache.delete(fsPath);
|
|
21
|
+
moduleCache.delete(`mock:${fsPath}`);
|
|
22
|
+
});
|
|
26
23
|
ctx.files.forEach((i) => state.moduleCache.delete(typeof i === "string" ? i : i.filepath));
|
|
27
24
|
const [executor, { run }] = await Promise.all([startViteNode({
|
|
28
25
|
state,
|
|
29
26
|
requestStubs: getDefaultRequestStubs()
|
|
30
|
-
}), import('./runBaseTests.
|
|
27
|
+
}), import('./runBaseTests.Dd85QTll.js')]);
|
|
31
28
|
const fileSpecs = ctx.files.map((f) => typeof f === "string" ? {
|
|
32
29
|
filepath: f,
|
|
33
|
-
testLocations:
|
|
30
|
+
testLocations: void 0
|
|
34
31
|
} : f);
|
|
35
32
|
await run(method, fileSpecs, ctx.config, {
|
|
36
33
|
environment: state.environment,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { getCurrentSuite } from '@vitest/runner';
|
|
2
2
|
import { createChainable } from '@vitest/runner/utils';
|
|
3
3
|
import { noop } from '@vitest/utils';
|
|
4
|
-
import { g as getWorkerState } from './utils.
|
|
4
|
+
import { g as getWorkerState } from './utils.XdZDrNZV.js';
|
|
5
5
|
|
|
6
|
-
const benchFns = new WeakMap();
|
|
7
|
-
const benchOptsMap = new WeakMap();
|
|
6
|
+
const benchFns = /* @__PURE__ */ new WeakMap();
|
|
7
|
+
const benchOptsMap = /* @__PURE__ */ new WeakMap();
|
|
8
8
|
function getBenchOptions(key) {
|
|
9
9
|
return benchOptsMap.get(key);
|
|
10
10
|
}
|
|
@@ -12,9 +12,7 @@ function getBenchFn(key) {
|
|
|
12
12
|
return benchFns.get(key);
|
|
13
13
|
}
|
|
14
14
|
const bench = createBenchmark(function(name, fn = noop, options = {}) {
|
|
15
|
-
if (getWorkerState().config.mode !== "benchmark")
|
|
16
|
-
throw new Error("`bench()` is only available in benchmark mode.");
|
|
17
|
-
}
|
|
15
|
+
if (getWorkerState().config.mode !== "benchmark") throw new Error("`bench()` is only available in benchmark mode.");
|
|
18
16
|
const task = getCurrentSuite().task(formatName(name), {
|
|
19
17
|
...this,
|
|
20
18
|
meta: { benchmark: true }
|
|
@@ -2,8 +2,8 @@ import { toArray } from '@vitest/utils';
|
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
3
|
import { normalize } from 'pathe';
|
|
4
4
|
import c from 'tinyrainbow';
|
|
5
|
-
import { a as defaultPort, d as defaultBrowserPort } from './constants.
|
|
6
|
-
import { R as ReportersMap } from './index.
|
|
5
|
+
import { a as defaultPort, d as defaultBrowserPort } from './constants.DnKduX2e.js';
|
|
6
|
+
import { R as ReportersMap } from './index.BZ0g1JD2.js';
|
|
7
7
|
|
|
8
8
|
function toArr(any) {
|
|
9
9
|
return any == null ? [] : Array.isArray(any) ? any : [any];
|
|
@@ -619,7 +619,7 @@ class CAC extends EventEmitter {
|
|
|
619
619
|
|
|
620
620
|
const cac = (name = "") => new CAC(name);
|
|
621
621
|
|
|
622
|
-
var version = "3.2.0
|
|
622
|
+
var version = "3.2.0";
|
|
623
623
|
|
|
624
624
|
const apiConfig = (port) => ({
|
|
625
625
|
port: {
|
|
@@ -661,15 +661,11 @@ const poolForksCommands = {
|
|
|
661
661
|
execArgv: null
|
|
662
662
|
};
|
|
663
663
|
function watermarkTransform(value) {
|
|
664
|
-
if (typeof value === "string")
|
|
665
|
-
return value.split(",").map(Number);
|
|
666
|
-
}
|
|
664
|
+
if (typeof value === "string") return value.split(",").map(Number);
|
|
667
665
|
return value;
|
|
668
666
|
}
|
|
669
667
|
function transformNestedBoolean(value) {
|
|
670
|
-
if (typeof value === "boolean") {
|
|
671
|
-
return { enabled: value };
|
|
672
|
-
}
|
|
668
|
+
if (typeof value === "boolean") return { enabled: value };
|
|
673
669
|
return value;
|
|
674
670
|
}
|
|
675
671
|
const cliOptionsConfig = {
|
|
@@ -712,7 +708,13 @@ const cliOptionsConfig = {
|
|
|
712
708
|
},
|
|
713
709
|
silent: {
|
|
714
710
|
description: "Silent console output from tests. Use `'passed-only'` to see logs from failing tests only.",
|
|
715
|
-
argument: "[value]"
|
|
711
|
+
argument: "[value]",
|
|
712
|
+
transform(value) {
|
|
713
|
+
if (value === "true" || value === "yes" || value === true) return true;
|
|
714
|
+
if (value === "false" || value === "no" || value === false) return false;
|
|
715
|
+
if (value === "passed-only") return value;
|
|
716
|
+
throw new TypeError(`Unexpected value "--silent=${value}". Use "--silent=true ${value}" instead.`);
|
|
717
|
+
}
|
|
716
718
|
},
|
|
717
719
|
hideSkippedTests: { description: "Hide logs for skipped tests" },
|
|
718
720
|
reporters: {
|
|
@@ -855,21 +857,10 @@ const cliOptionsConfig = {
|
|
|
855
857
|
description: "Run tests in the browser. Equivalent to `--browser.enabled` (default: `false`)",
|
|
856
858
|
argument: "<name>",
|
|
857
859
|
transform(browser) {
|
|
858
|
-
if (typeof browser === "boolean") {
|
|
859
|
-
|
|
860
|
-
}
|
|
861
|
-
if (browser === "
|
|
862
|
-
return { enabled: browser === "true" };
|
|
863
|
-
}
|
|
864
|
-
if (browser === "yes" || browser === "no") {
|
|
865
|
-
return { enabled: browser === "yes" };
|
|
866
|
-
}
|
|
867
|
-
if (typeof browser === "string") {
|
|
868
|
-
return {
|
|
869
|
-
enabled: true,
|
|
870
|
-
name: browser
|
|
871
|
-
};
|
|
872
|
-
}
|
|
860
|
+
if (typeof browser === "boolean") return { enabled: browser };
|
|
861
|
+
if (browser === "true" || browser === "false") return { enabled: browser === "true" };
|
|
862
|
+
if (browser === "yes" || browser === "no") return { enabled: browser === "yes" };
|
|
863
|
+
if (typeof browser === "string") return { name: browser };
|
|
873
864
|
return browser;
|
|
874
865
|
},
|
|
875
866
|
subcommands: {
|
|
@@ -1013,12 +1004,8 @@ const cliOptionsConfig = {
|
|
|
1013
1004
|
description: "Enable Node.js inspector (default: `127.0.0.1:9229`)",
|
|
1014
1005
|
argument: "[[host:]port]",
|
|
1015
1006
|
transform(portOrEnabled) {
|
|
1016
|
-
if (portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes")
|
|
1017
|
-
|
|
1018
|
-
}
|
|
1019
|
-
if (portOrEnabled === "false" || portOrEnabled === "no") {
|
|
1020
|
-
return false;
|
|
1021
|
-
}
|
|
1007
|
+
if (portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes") return true;
|
|
1008
|
+
if (portOrEnabled === "false" || portOrEnabled === "no") return false;
|
|
1022
1009
|
return portOrEnabled;
|
|
1023
1010
|
}
|
|
1024
1011
|
},
|
|
@@ -1026,12 +1013,8 @@ const cliOptionsConfig = {
|
|
|
1026
1013
|
description: "Enable Node.js inspector and break before the test starts",
|
|
1027
1014
|
argument: "[[host:]port]",
|
|
1028
1015
|
transform(portOrEnabled) {
|
|
1029
|
-
if (portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes")
|
|
1030
|
-
|
|
1031
|
-
}
|
|
1032
|
-
if (portOrEnabled === "false" || portOrEnabled === "no") {
|
|
1033
|
-
return false;
|
|
1034
|
-
}
|
|
1016
|
+
if (portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes") return true;
|
|
1017
|
+
if (portOrEnabled === "false" || portOrEnabled === "no") return false;
|
|
1035
1018
|
return portOrEnabled;
|
|
1036
1019
|
}
|
|
1037
1020
|
},
|
|
@@ -1128,6 +1111,10 @@ const cliOptionsConfig = {
|
|
|
1128
1111
|
argument: "<path>",
|
|
1129
1112
|
normalize: true
|
|
1130
1113
|
},
|
|
1114
|
+
spawnTimeout: {
|
|
1115
|
+
description: "Minimum time in milliseconds it takes to spawn the typechecker",
|
|
1116
|
+
argument: "<time>"
|
|
1117
|
+
},
|
|
1131
1118
|
include: null,
|
|
1132
1119
|
exclude: null
|
|
1133
1120
|
}
|
|
@@ -1151,12 +1138,8 @@ const cliOptionsConfig = {
|
|
|
1151
1138
|
subcommands: { dir: null },
|
|
1152
1139
|
default: true,
|
|
1153
1140
|
transform(cache) {
|
|
1154
|
-
if (typeof cache !== "boolean" && cache)
|
|
1155
|
-
|
|
1156
|
-
}
|
|
1157
|
-
if (cache) {
|
|
1158
|
-
return {};
|
|
1159
|
-
}
|
|
1141
|
+
if (typeof cache !== "boolean" && cache) throw new Error("--cache.dir is deprecated");
|
|
1142
|
+
if (cache) return {};
|
|
1160
1143
|
return cache;
|
|
1161
1144
|
}
|
|
1162
1145
|
},
|
|
@@ -1183,22 +1166,22 @@ const cliOptionsConfig = {
|
|
|
1183
1166
|
}
|
|
1184
1167
|
},
|
|
1185
1168
|
transform(value) {
|
|
1186
|
-
if (typeof value !== "object") {
|
|
1187
|
-
throw new TypeError(`Unexpected value for --expect.poll: ${value}. If you need to configure timeout, use --expect.poll.timeout=<timeout>`);
|
|
1188
|
-
}
|
|
1169
|
+
if (typeof value !== "object") throw new TypeError(`Unexpected value for --expect.poll: ${value}. If you need to configure timeout, use --expect.poll.timeout=<timeout>`);
|
|
1189
1170
|
return value;
|
|
1190
1171
|
}
|
|
1191
1172
|
}
|
|
1192
1173
|
},
|
|
1193
1174
|
transform(value) {
|
|
1194
|
-
if (typeof value !== "object") {
|
|
1195
|
-
throw new TypeError(`Unexpected value for --expect: ${value}. If you need to configure expect options, use --expect.{name}=<value> syntax`);
|
|
1196
|
-
}
|
|
1175
|
+
if (typeof value !== "object") throw new TypeError(`Unexpected value for --expect: ${value}. If you need to configure expect options, use --expect.{name}=<value> syntax`);
|
|
1197
1176
|
return value;
|
|
1198
1177
|
}
|
|
1199
1178
|
},
|
|
1200
1179
|
printConsoleTrace: { description: "Always print console stack traces" },
|
|
1201
1180
|
includeTaskLocation: { description: "Collect test and suite locations in the `location` property" },
|
|
1181
|
+
attachmentsDir: {
|
|
1182
|
+
description: "The directory where attachments from `context.annotate` are stored in (default: `.vitest-attachments`)",
|
|
1183
|
+
argument: "<dir>"
|
|
1184
|
+
},
|
|
1202
1185
|
run: { description: "Disable watch mode" },
|
|
1203
1186
|
color: {
|
|
1204
1187
|
description: "Removes colors from the console output",
|
|
@@ -1214,9 +1197,7 @@ const cliOptionsConfig = {
|
|
|
1214
1197
|
description: "Path to a blob reports directory. If this options is used, Vitest won't run any tests, it will only report previously recorded tests",
|
|
1215
1198
|
argument: "[path]",
|
|
1216
1199
|
transform(value) {
|
|
1217
|
-
if (!value || typeof value === "boolean")
|
|
1218
|
-
return ".vitest-reports";
|
|
1219
|
-
}
|
|
1200
|
+
if (!value || typeof value === "boolean") return ".vitest-reports";
|
|
1220
1201
|
return value;
|
|
1221
1202
|
}
|
|
1222
1203
|
},
|
|
@@ -1279,49 +1260,31 @@ const collectCliOptionsConfig = {
|
|
|
1279
1260
|
function addCommand(cli, name, option) {
|
|
1280
1261
|
const commandName = option.alias || name;
|
|
1281
1262
|
let command = option.shorthand ? `-${option.shorthand}, --${commandName}` : `--${commandName}`;
|
|
1282
|
-
if ("argument" in option) {
|
|
1283
|
-
command += ` ${option.argument}`;
|
|
1284
|
-
}
|
|
1263
|
+
if ("argument" in option) command += ` ${option.argument}`;
|
|
1285
1264
|
function transform(value) {
|
|
1286
1265
|
if (!option.array && Array.isArray(value)) {
|
|
1287
1266
|
const received = value.map((s) => typeof s === "string" ? `"${s}"` : s).join(", ");
|
|
1288
1267
|
throw new Error(`Expected a single value for option "${command}", received [${received}]`);
|
|
1289
1268
|
}
|
|
1290
1269
|
value = removeQuotes(value);
|
|
1291
|
-
if (option.transform)
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
if (option.array) {
|
|
1295
|
-
return toArray(value);
|
|
1296
|
-
}
|
|
1297
|
-
if (option.normalize) {
|
|
1298
|
-
return normalize(String(value));
|
|
1299
|
-
}
|
|
1270
|
+
if (option.transform) return option.transform(value);
|
|
1271
|
+
if (option.array) return toArray(value);
|
|
1272
|
+
if (option.normalize) return normalize(String(value));
|
|
1300
1273
|
return value;
|
|
1301
1274
|
}
|
|
1302
1275
|
const hasSubcommands = "subcommands" in option && option.subcommands;
|
|
1303
1276
|
if (option.description) {
|
|
1304
1277
|
let description = option.description.replace(/\[.*\]\((.*)\)/, "$1").replace(/`/g, "");
|
|
1305
|
-
if (hasSubcommands) {
|
|
1306
|
-
description += `. Use '--help --${commandName}' for more info.`;
|
|
1307
|
-
}
|
|
1278
|
+
if (hasSubcommands) description += `. Use '--help --${commandName}' for more info.`;
|
|
1308
1279
|
cli.option(command, description, { type: transform });
|
|
1309
1280
|
}
|
|
1310
|
-
if (hasSubcommands) {
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
if (subcommand) {
|
|
1314
|
-
addCommand(cli, `${name}.${commandName}`, subcommand);
|
|
1315
|
-
}
|
|
1316
|
-
}
|
|
1281
|
+
if (hasSubcommands) for (const commandName in option.subcommands) {
|
|
1282
|
+
const subcommand = option.subcommands[commandName];
|
|
1283
|
+
if (subcommand) addCommand(cli, `${name}.${commandName}`, subcommand);
|
|
1317
1284
|
}
|
|
1318
1285
|
}
|
|
1319
1286
|
function addCliOptions(cli, options) {
|
|
1320
|
-
for (const [optionName, option] of Object.entries(options))
|
|
1321
|
-
if (option) {
|
|
1322
|
-
addCommand(cli, optionName, option);
|
|
1323
|
-
}
|
|
1324
|
-
}
|
|
1287
|
+
for (const [optionName, option] of Object.entries(options)) if (option) addCommand(cli, optionName, option);
|
|
1325
1288
|
}
|
|
1326
1289
|
function createCLI(options = {}) {
|
|
1327
1290
|
const cli = cac("vitest");
|
|
@@ -1329,43 +1292,38 @@ function createCLI(options = {}) {
|
|
|
1329
1292
|
addCliOptions(cli, cliOptionsConfig);
|
|
1330
1293
|
cli.help((info) => {
|
|
1331
1294
|
const helpSection = info.find((current) => current.title?.startsWith("For more info, run any command"));
|
|
1332
|
-
if (helpSection)
|
|
1333
|
-
helpSection.body += "\n $ vitest --help --expand-help";
|
|
1334
|
-
}
|
|
1295
|
+
if (helpSection) helpSection.body += "\n $ vitest --help --expand-help";
|
|
1335
1296
|
const options = info.find((current) => current.title === "Options");
|
|
1336
|
-
if (typeof options !== "object")
|
|
1337
|
-
return info;
|
|
1338
|
-
}
|
|
1297
|
+
if (typeof options !== "object") return info;
|
|
1339
1298
|
const helpIndex = process.argv.findIndex((arg) => arg === "--help");
|
|
1340
1299
|
const subcommands = process.argv.slice(helpIndex + 1);
|
|
1341
1300
|
const defaultOutput = options.body.split("\n").filter((line) => /^\s+--\S+\./.test(line) === false).join("\n");
|
|
1301
|
+
// Filter out options with dot-notation if --help is not called with a subcommand (default behavior)
|
|
1342
1302
|
if (subcommands.length === 0) {
|
|
1343
1303
|
options.body = defaultOutput;
|
|
1344
1304
|
return info;
|
|
1345
1305
|
}
|
|
1346
|
-
if (subcommands.length === 1 && (subcommands[0] === "--expand-help" || subcommands[0] === "--expandHelp"))
|
|
1347
|
-
return info;
|
|
1348
|
-
}
|
|
1306
|
+
if (subcommands.length === 1 && (subcommands[0] === "--expand-help" || subcommands[0] === "--expandHelp")) return info;
|
|
1349
1307
|
const subcommandMarker = "$SUB_COMMAND_MARKER$";
|
|
1350
1308
|
const banner = info.find((current) => /^vitest\/\d+\.\d+\.\d+$/.test(current.body));
|
|
1351
1309
|
function addBannerWarning(warning) {
|
|
1352
1310
|
if (typeof banner?.body === "string") {
|
|
1353
|
-
if (banner?.body.includes(warning))
|
|
1354
|
-
return;
|
|
1355
|
-
}
|
|
1311
|
+
if (banner?.body.includes(warning)) return;
|
|
1356
1312
|
banner.body = `${banner.body}\n WARN: ${warning}`;
|
|
1357
1313
|
}
|
|
1358
1314
|
}
|
|
1315
|
+
// If other subcommand combinations are used, only show options for the subcommand
|
|
1359
1316
|
for (let i = 0; i < subcommands.length; i++) {
|
|
1360
1317
|
const subcommand = subcommands[i];
|
|
1318
|
+
// --help --expand-help can't be called with multiple subcommands and is handled above
|
|
1361
1319
|
if (subcommand === "--expand-help" || subcommand === "--expandHelp") {
|
|
1362
1320
|
addBannerWarning("--expand-help subcommand ignored because, when used with --help, it must be the only subcommand");
|
|
1363
1321
|
continue;
|
|
1364
1322
|
}
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
}
|
|
1323
|
+
// Mark the help section for the subcommands
|
|
1324
|
+
if (subcommand.startsWith("--")) options.body = options.body.split("\n").map((line) => line.trim().startsWith(subcommand) ? `${subcommandMarker}${line}` : line).join("\n");
|
|
1368
1325
|
}
|
|
1326
|
+
// Filter based on the marked options to preserve the original sort order
|
|
1369
1327
|
options.body = options.body.split("\n").map((line) => line.startsWith(subcommandMarker) ? line.split(subcommandMarker)[1] : "").filter((line) => line.length !== 0).join("\n");
|
|
1370
1328
|
if (!options.body) {
|
|
1371
1329
|
addBannerWarning("no options were found for your subcommands so we printed the whole output");
|
|
@@ -1373,29 +1331,23 @@ function createCLI(options = {}) {
|
|
|
1373
1331
|
}
|
|
1374
1332
|
return info;
|
|
1375
1333
|
});
|
|
1376
|
-
cli.command("run [...filters]",
|
|
1377
|
-
cli.command("related [...filters]",
|
|
1378
|
-
cli.command("watch [...filters]",
|
|
1379
|
-
cli.command("dev [...filters]",
|
|
1380
|
-
addCliOptions(cli.command("bench [...filters]",
|
|
1381
|
-
cli.command("init <project>",
|
|
1382
|
-
addCliOptions(cli.command("list [...filters]",
|
|
1383
|
-
cli.command("[...filters]",
|
|
1334
|
+
cli.command("run [...filters]", void 0, options).action(run);
|
|
1335
|
+
cli.command("related [...filters]", void 0, options).action(runRelated);
|
|
1336
|
+
cli.command("watch [...filters]", void 0, options).action(watch);
|
|
1337
|
+
cli.command("dev [...filters]", void 0, options).action(watch);
|
|
1338
|
+
addCliOptions(cli.command("bench [...filters]", void 0, options).action(benchmark), benchCliOptionsConfig);
|
|
1339
|
+
cli.command("init <project>", void 0, options).action(init);
|
|
1340
|
+
addCliOptions(cli.command("list [...filters]", void 0, options).action((filters, options) => collect("test", filters, options)), collectCliOptionsConfig);
|
|
1341
|
+
cli.command("[...filters]", void 0, options).action((filters, options) => start("test", filters, options));
|
|
1384
1342
|
return cli;
|
|
1385
1343
|
}
|
|
1386
1344
|
function removeQuotes(str) {
|
|
1387
1345
|
if (typeof str !== "string") {
|
|
1388
|
-
if (Array.isArray(str))
|
|
1389
|
-
return str.map(removeQuotes);
|
|
1390
|
-
}
|
|
1346
|
+
if (Array.isArray(str)) return str.map(removeQuotes);
|
|
1391
1347
|
return str;
|
|
1392
1348
|
}
|
|
1393
|
-
if (str.startsWith("\"") && str.endsWith("\""))
|
|
1394
|
-
|
|
1395
|
-
}
|
|
1396
|
-
if (str.startsWith(`'`) && str.endsWith(`'`)) {
|
|
1397
|
-
return str.slice(1, -1);
|
|
1398
|
-
}
|
|
1349
|
+
if (str.startsWith("\"") && str.endsWith("\"")) return str.slice(1, -1);
|
|
1350
|
+
if (str.startsWith(`'`) && str.endsWith(`'`)) return str.slice(1, -1);
|
|
1399
1351
|
return str;
|
|
1400
1352
|
}
|
|
1401
1353
|
function splitArgv(argv) {
|
|
@@ -1408,18 +1360,12 @@ function splitArgv(argv) {
|
|
|
1408
1360
|
}
|
|
1409
1361
|
function parseCLI(argv, config = {}) {
|
|
1410
1362
|
const arrayArgs = typeof argv === "string" ? splitArgv(argv) : argv;
|
|
1411
|
-
if (arrayArgs[0] !== "vitest") {
|
|
1412
|
-
throw new Error(`Expected "vitest" as the first argument, received "${arrayArgs[0]}"`);
|
|
1413
|
-
}
|
|
1363
|
+
if (arrayArgs[0] !== "vitest") throw new Error(`Expected "vitest" as the first argument, received "${arrayArgs[0]}"`);
|
|
1414
1364
|
arrayArgs[0] = "/index.js";
|
|
1415
1365
|
arrayArgs.unshift("node");
|
|
1416
1366
|
let { args, options } = createCLI(config).parse(arrayArgs, { run: false });
|
|
1417
|
-
if (arrayArgs[2] === "watch" || arrayArgs[2] === "dev")
|
|
1418
|
-
|
|
1419
|
-
}
|
|
1420
|
-
if (arrayArgs[2] === "run") {
|
|
1421
|
-
options.run = true;
|
|
1422
|
-
}
|
|
1367
|
+
if (arrayArgs[2] === "watch" || arrayArgs[2] === "dev") options.watch = true;
|
|
1368
|
+
if (arrayArgs[2] === "run") options.run = true;
|
|
1423
1369
|
if (arrayArgs[2] === "related") {
|
|
1424
1370
|
options.related = args;
|
|
1425
1371
|
options.passWithNoTests ??= true;
|
|
@@ -1452,15 +1398,8 @@ function normalizeCliOptions(cliFilters, argv) {
|
|
|
1452
1398
|
argv.cliExclude = toArray(argv.exclude);
|
|
1453
1399
|
delete argv.exclude;
|
|
1454
1400
|
}
|
|
1455
|
-
if (cliFilters.some((filter) => filter.includes(":")))
|
|
1456
|
-
|
|
1457
|
-
}
|
|
1458
|
-
if (typeof argv.browser === "object" && !("enabled" in argv.browser)) {
|
|
1459
|
-
argv.browser.enabled = true;
|
|
1460
|
-
}
|
|
1461
|
-
if (typeof argv.typecheck?.only === "boolean") {
|
|
1462
|
-
argv.typecheck.enabled ??= true;
|
|
1463
|
-
}
|
|
1401
|
+
if (cliFilters.some((filter) => filter.includes(":"))) argv.includeTaskLocation ??= true;
|
|
1402
|
+
if (typeof argv.typecheck?.only === "boolean") argv.typecheck.enabled ??= true;
|
|
1464
1403
|
return argv;
|
|
1465
1404
|
}
|
|
1466
1405
|
async function start(mode, cliFilters, options) {
|
|
@@ -1468,19 +1407,15 @@ async function start(mode, cliFilters, options) {
|
|
|
1468
1407
|
process.title = "node (vitest)";
|
|
1469
1408
|
} catch {}
|
|
1470
1409
|
try {
|
|
1471
|
-
const { startVitest } = await import('./cli-api.
|
|
1410
|
+
const { startVitest } = await import('./cli-api.Cej3MBjA.js').then(function (n) { return n.f; });
|
|
1472
1411
|
const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
|
|
1473
|
-
if (!ctx.shouldKeepServer())
|
|
1474
|
-
await ctx.exit();
|
|
1475
|
-
}
|
|
1412
|
+
if (!ctx.shouldKeepServer()) await ctx.exit();
|
|
1476
1413
|
} catch (e) {
|
|
1477
|
-
const { errorBanner } = await import('./index.
|
|
1414
|
+
const { errorBanner } = await import('./index.BZ0g1JD2.js').then(function (n) { return n.u; });
|
|
1478
1415
|
console.error(`\n${errorBanner("Startup Error")}`);
|
|
1479
1416
|
console.error(e);
|
|
1480
1417
|
console.error("\n\n");
|
|
1481
|
-
if (process.exitCode == null)
|
|
1482
|
-
process.exitCode = 1;
|
|
1483
|
-
}
|
|
1418
|
+
if (process.exitCode == null) process.exitCode = 1;
|
|
1484
1419
|
process.exit();
|
|
1485
1420
|
}
|
|
1486
1421
|
}
|
|
@@ -1489,7 +1424,7 @@ async function init(project) {
|
|
|
1489
1424
|
console.error(new Error("Only the \"browser\" project is supported. Use \"vitest init browser\" to create a new project."));
|
|
1490
1425
|
process.exit(1);
|
|
1491
1426
|
}
|
|
1492
|
-
const { create } = await import('./creator.
|
|
1427
|
+
const { create } = await import('./creator.GK6I-cL4.js');
|
|
1493
1428
|
await create();
|
|
1494
1429
|
}
|
|
1495
1430
|
async function collect(mode, cliFilters, options) {
|
|
@@ -1497,7 +1432,7 @@ async function collect(mode, cliFilters, options) {
|
|
|
1497
1432
|
process.title = "node (vitest)";
|
|
1498
1433
|
} catch {}
|
|
1499
1434
|
try {
|
|
1500
|
-
const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.
|
|
1435
|
+
const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.Cej3MBjA.js').then(function (n) { return n.f; });
|
|
1501
1436
|
const ctx = await prepareVitest(mode, {
|
|
1502
1437
|
...normalizeCliOptions(cliFilters, options),
|
|
1503
1438
|
watch: false,
|
|
@@ -1519,13 +1454,11 @@ async function collect(mode, cliFilters, options) {
|
|
|
1519
1454
|
}
|
|
1520
1455
|
await ctx.close();
|
|
1521
1456
|
} catch (e) {
|
|
1522
|
-
const { errorBanner } = await import('./index.
|
|
1457
|
+
const { errorBanner } = await import('./index.BZ0g1JD2.js').then(function (n) { return n.u; });
|
|
1523
1458
|
console.error(`\n${errorBanner("Collect Error")}`);
|
|
1524
1459
|
console.error(e);
|
|
1525
1460
|
console.error("\n\n");
|
|
1526
|
-
if (process.exitCode == null)
|
|
1527
|
-
process.exitCode = 1;
|
|
1528
|
-
}
|
|
1461
|
+
if (process.exitCode == null) process.exitCode = 1;
|
|
1529
1462
|
process.exit();
|
|
1530
1463
|
}
|
|
1531
1464
|
}
|