vitest 4.0.0-beta.8 → 4.0.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 +86 -102
- package/browser/context.d.ts +7 -0
- package/browser/context.js +20 -0
- package/dist/browser.d.ts +26 -9
- package/dist/browser.js +17 -7
- package/dist/chunks/base.CtHM3ryk.js +128 -0
- package/dist/chunks/{benchmark.UW6Ezvxy.js → benchmark.DHKMYAts.js} +2 -2
- package/dist/chunks/{browser.d.DOMmqJQx.d.ts → browser.d.B9iJzZyn.d.ts} +3 -3
- package/dist/chunks/{cac.By1HvRIk.js → cac.B99MQg-w.js} +47 -91
- package/dist/chunks/{cli-api.C-JHgQgp.js → cli-api.PwHwIMss.js} +1544 -310
- package/dist/chunks/{config.d._GBBbReY.d.ts → config.d.u2CUDWwS.d.ts} +6 -19
- package/dist/chunks/{console.B0quX7yH.js → console.CTJL2nuH.js} +4 -6
- package/dist/chunks/{coverage.DarITf6U.js → coverage.FU3w4IrQ.js} +128 -1142
- package/dist/chunks/{creator.KEg6n5IC.js → creator.DucAaYBz.js} +10 -37
- package/dist/chunks/{defaults.CXFFjsi8.js → defaults.BOqNVLsY.js} +0 -1
- package/dist/chunks/environment.d.CrsxCzP1.d.ts +29 -0
- package/dist/chunks/evaluatedModules.Dg1zASAC.js +17 -0
- package/dist/chunks/{global.d.K6uBQHzY.d.ts → global.d.BgJSTpgQ.d.ts} +2 -17
- package/dist/chunks/{globals.lgsmH00r.js → globals.BGT_RUsD.js} +12 -9
- package/dist/chunks/{index.BuwjkI-q.js → index.BdSLhLDZ.js} +3 -3
- package/dist/chunks/{index.DfviD7lX.js → index.CbWINfS7.js} +49 -21
- package/dist/chunks/{index.AzwzFtyi.js → index.CcRZ6fUh.js} +1493 -114
- package/dist/chunks/{index.X0nbfr6-.js → index.Dc3xnDvT.js} +48 -289
- package/dist/chunks/{index.AR8aAkCC.js → index.RwjEGCQ0.js} +7 -8
- package/dist/chunks/init-forks.DSafeltJ.js +54 -0
- package/dist/chunks/init-threads.SUtZ-067.js +17 -0
- package/dist/chunks/init.B2EESLQM.js +213 -0
- package/dist/chunks/{inspector.CvQD-Nie.js → inspector.DLZxSeU3.js} +2 -6
- package/dist/chunks/{moduleRunner.d.CX4DuqOx.d.ts → moduleRunner.d.YtNsMIoJ.d.ts} +12 -14
- package/dist/chunks/{node.BOqcT2jW.js → node.BwAWWjHZ.js} +3 -4
- package/dist/chunks/{plugin.d.CHe6slQs.d.ts → plugin.d.DQU1R5px.d.ts} +1 -1
- package/dist/chunks/{reporters.d.37tJQ2uV.d.ts → reporters.d.BMKt7f6I.d.ts} +1066 -1030
- package/dist/chunks/{index.CsFXYRkW.js → resolveSnapshotEnvironment.DJJKMKxb.js} +18 -24
- package/dist/chunks/{rpc.RpPylpp0.js → rpc.cD77ENhU.js} +13 -14
- package/dist/chunks/{setup-common.hLGRxhC8.js → setup-common.DR1sucx6.js} +8 -8
- package/dist/chunks/{startModuleRunner.C8TW8zTN.js → startModuleRunner.C2tTvmF9.js} +131 -110
- package/dist/chunks/test.C3RPt8JR.js +214 -0
- package/dist/chunks/{utils.C7__0Iv5.js → utils.CG9h5ccR.js} +3 -15
- package/dist/chunks/{vi.BfdOiD4j.js → vi.BZvkKVkM.js} +73 -176
- package/dist/chunks/{vm.BHBje7cC.js → vm.DBeOXrP9.js} +29 -33
- package/dist/chunks/{worker.d.DYlqbejz.d.ts → worker.d.BFk-vvBU.d.ts} +42 -6
- package/dist/cli.js +12 -11
- package/dist/config.cjs +0 -1
- package/dist/config.d.ts +12 -14
- package/dist/config.js +1 -1
- package/dist/coverage.d.ts +8 -7
- package/dist/coverage.js +3 -14
- package/dist/environments.d.ts +3 -6
- package/dist/environments.js +1 -1
- package/dist/index.d.ts +24 -30
- package/dist/index.js +12 -11
- package/dist/module-evaluator.d.ts +6 -4
- package/dist/module-evaluator.js +14 -16
- package/dist/module-runner.js +5 -5
- package/dist/node.d.ts +83 -27
- package/dist/node.js +23 -20
- package/dist/reporters.d.ts +11 -10
- package/dist/reporters.js +12 -11
- package/dist/runners.d.ts +1 -1
- package/dist/runners.js +14 -216
- package/dist/snapshot.js +3 -3
- package/dist/suite.js +4 -3
- package/dist/worker.d.ts +26 -0
- package/dist/worker.js +45 -166
- package/dist/workers/forks.js +41 -35
- package/dist/workers/runVmTests.js +25 -22
- package/dist/workers/threads.js +41 -23
- package/dist/workers/vmForks.js +26 -39
- package/dist/workers/vmThreads.js +26 -29
- package/package.json +48 -35
- package/worker.d.ts +1 -0
- package/browser.d.ts +0 -1
- package/dist/chunks/base.BXI97p6t.js +0 -39
- package/dist/chunks/environment.d.2fYMoz3o.d.ts +0 -66
- package/dist/chunks/moduleTransport.I-bgQy0S.js +0 -19
- package/dist/chunks/resolver.Bx6lE0iq.js +0 -119
- package/dist/chunks/runBaseTests.D6sfuWBM.js +0 -99
- package/dist/chunks/typechecker.DSo_maXz.js +0 -762
- package/dist/chunks/utils.C2YI6McM.js +0 -52
- package/dist/chunks/worker.d.BKu8cnnX.d.ts +0 -8
- package/dist/workers.d.ts +0 -38
- package/dist/workers.js +0 -31
- package/execute.d.ts +0 -1
- package/utils.d.ts +0 -1
- package/workers.d.ts +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { toArray } from '@vitest/utils';
|
|
1
|
+
import { toArray } from '@vitest/utils/helpers';
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
3
|
import { normalize } from 'pathe';
|
|
4
4
|
import c from 'tinyrainbow';
|
|
5
5
|
import { a as defaultPort, d as defaultBrowserPort } from './constants.D_Q9UYh-.js';
|
|
6
|
-
import { R as ReportersMap } from './index.
|
|
6
|
+
import { R as ReportersMap } from './index.CcRZ6fUh.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 = "4.0.0
|
|
622
|
+
var version = "4.0.0";
|
|
623
623
|
|
|
624
624
|
const apiConfig = (port) => ({
|
|
625
625
|
port: {
|
|
@@ -632,32 +632,7 @@ const apiConfig = (port) => ({
|
|
|
632
632
|
},
|
|
633
633
|
strictPort: { description: "Set to true to exit if port is already in use, instead of automatically trying the next available port" },
|
|
634
634
|
middlewareMode: null
|
|
635
|
-
})
|
|
636
|
-
isolate: { description: "Isolate tests in threads pool (default: `true`)" },
|
|
637
|
-
singleThread: { description: "Run tests inside a single thread (default: `false`)" },
|
|
638
|
-
maxThreads: {
|
|
639
|
-
description: "Maximum number or percentage of threads to run tests in",
|
|
640
|
-
argument: "<workers>"
|
|
641
|
-
},
|
|
642
|
-
minThreads: {
|
|
643
|
-
description: "Minimum number or percentage of threads to run tests in",
|
|
644
|
-
argument: "<workers>"
|
|
645
|
-
},
|
|
646
|
-
useAtomics: { description: "Use Atomics to synchronize threads. This can improve performance in some cases, but might cause segfault in older Node versions (default: `false`)" },
|
|
647
|
-
execArgv: null
|
|
648
|
-
}, poolForksCommands = {
|
|
649
|
-
isolate: { description: "Isolate tests in forks pool (default: `true`)" },
|
|
650
|
-
singleFork: { description: "Run tests inside a single child_process (default: `false`)" },
|
|
651
|
-
maxForks: {
|
|
652
|
-
description: "Maximum number or percentage of processes to run tests in",
|
|
653
|
-
argument: "<workers>"
|
|
654
|
-
},
|
|
655
|
-
minForks: {
|
|
656
|
-
description: "Minimum number or percentage of processes to run tests in",
|
|
657
|
-
argument: "<workers>"
|
|
658
|
-
},
|
|
659
|
-
execArgv: null
|
|
660
|
-
};
|
|
635
|
+
});
|
|
661
636
|
function watermarkTransform(value) {
|
|
662
637
|
return typeof value === "string" ? value.split(",").map(Number) : value;
|
|
663
638
|
}
|
|
@@ -766,7 +741,14 @@ const cliOptionsConfig = {
|
|
|
766
741
|
argument: "",
|
|
767
742
|
subcommands: {
|
|
768
743
|
perFile: { description: "Check thresholds per file. See `--coverage.thresholds.lines`, `--coverage.thresholds.functions`, `--coverage.thresholds.branches` and `--coverage.thresholds.statements` for the actual thresholds (default: `false`)" },
|
|
769
|
-
autoUpdate: {
|
|
744
|
+
autoUpdate: {
|
|
745
|
+
description: "Update threshold values: \"lines\", \"functions\", \"branches\" and \"statements\" to configuration file when current coverage is above the configured thresholds (default: `false`)",
|
|
746
|
+
argument: "<boolean|function>",
|
|
747
|
+
subcommands: null,
|
|
748
|
+
transform(value) {
|
|
749
|
+
return value === "true" || value === "yes" || value === true ? true : value === "false" || value === "no" || value === false ? false : value;
|
|
750
|
+
}
|
|
751
|
+
},
|
|
770
752
|
lines: {
|
|
771
753
|
description: "Threshold for lines. Visit [istanbuljs](https://github.com/istanbuljs/nyc#coverage-thresholds) for more information. This option is not available for custom providers",
|
|
772
754
|
argument: "<number>"
|
|
@@ -856,12 +838,19 @@ const cliOptionsConfig = {
|
|
|
856
838
|
provider: {
|
|
857
839
|
description: "Provider used to run browser tests. Some browsers are only available for specific providers. Can be \"webdriverio\", \"playwright\", \"preview\", or the path to a custom provider. Visit [`browser.provider`](https://vitest.dev/guide/browser/config.html#browser-provider) for more information (default: `\"preview\"`)",
|
|
858
840
|
argument: "<name>",
|
|
859
|
-
subcommands: null
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
841
|
+
subcommands: null,
|
|
842
|
+
transform(value) {
|
|
843
|
+
const supported = [
|
|
844
|
+
"playwright",
|
|
845
|
+
"webdriverio",
|
|
846
|
+
"preview"
|
|
847
|
+
];
|
|
848
|
+
if (typeof value !== "string" || !supported.includes(value)) throw new Error(`Unsupported browser provider: ${value}. Supported providers are: ${supported.join(", ")}`);
|
|
849
|
+
return {
|
|
850
|
+
name: value,
|
|
851
|
+
_cli: true
|
|
852
|
+
};
|
|
853
|
+
}
|
|
865
854
|
},
|
|
866
855
|
isolate: { description: "Run every browser test file in isolation. To disable isolation, use `--browser.isolate=false` (default: `true`)" },
|
|
867
856
|
ui: { description: "Show Vitest UI when running tests (default: `!process.env.CI`)" },
|
|
@@ -871,6 +860,14 @@ const cliOptionsConfig = {
|
|
|
871
860
|
argument: "<timeout>"
|
|
872
861
|
},
|
|
873
862
|
trackUnhandledErrors: { description: "Control if Vitest catches uncaught exceptions so they can be reported (default: `true`)" },
|
|
863
|
+
trace: {
|
|
864
|
+
description: "Enable trace view mode. Supported: \"on\", \"off\", \"on-first-retry\", \"on-all-retries\", \"retain-on-failure\".",
|
|
865
|
+
argument: "<mode>",
|
|
866
|
+
subcommands: null,
|
|
867
|
+
transform(value) {
|
|
868
|
+
return { mode: value };
|
|
869
|
+
}
|
|
870
|
+
},
|
|
874
871
|
orchestratorScripts: null,
|
|
875
872
|
commands: null,
|
|
876
873
|
viewport: null,
|
|
@@ -887,53 +884,19 @@ const cliOptionsConfig = {
|
|
|
887
884
|
argument: "<pool>",
|
|
888
885
|
subcommands: null
|
|
889
886
|
},
|
|
890
|
-
|
|
891
|
-
description: "
|
|
892
|
-
argument: "<
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
subcommands: poolThreadsCommands
|
|
898
|
-
},
|
|
899
|
-
vmThreads: {
|
|
900
|
-
description: "Specify VM threads pool options",
|
|
901
|
-
argument: "<options>",
|
|
902
|
-
subcommands: {
|
|
903
|
-
...poolThreadsCommands,
|
|
904
|
-
memoryLimit: {
|
|
905
|
-
description: "Memory limit for VM threads pool. If you see memory leaks, try to tinker this value.",
|
|
906
|
-
argument: "<limit>"
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
},
|
|
910
|
-
forks: {
|
|
911
|
-
description: "Specify forks pool options",
|
|
912
|
-
argument: "<options>",
|
|
913
|
-
subcommands: poolForksCommands
|
|
914
|
-
},
|
|
915
|
-
vmForks: {
|
|
916
|
-
description: "Specify VM forks pool options",
|
|
917
|
-
argument: "<options>",
|
|
918
|
-
subcommands: {
|
|
919
|
-
...poolForksCommands,
|
|
920
|
-
memoryLimit: {
|
|
921
|
-
description: "Memory limit for VM forks pool. If you see memory leaks, try to tinker this value.",
|
|
922
|
-
argument: "<limit>"
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
|
-
}
|
|
926
|
-
}
|
|
887
|
+
execArgv: {
|
|
888
|
+
description: "Pass additional arguments to `node` process when spawning `worker_threads` or `child_process`.",
|
|
889
|
+
argument: "<option>"
|
|
890
|
+
},
|
|
891
|
+
vmMemoryLimit: {
|
|
892
|
+
description: "Memory limit for VM pools. If you see memory leaks, try to tinker this value.",
|
|
893
|
+
argument: "<limit>"
|
|
927
894
|
},
|
|
928
895
|
fileParallelism: { description: "Should all test files run in parallel. Use `--no-file-parallelism` to disable (default: `true`)" },
|
|
929
896
|
maxWorkers: {
|
|
930
897
|
description: "Maximum number or percentage of workers to run tests in",
|
|
931
898
|
argument: "<workers>"
|
|
932
899
|
},
|
|
933
|
-
minWorkers: {
|
|
934
|
-
description: "Minimum number or percentage of workers to run tests in",
|
|
935
|
-
argument: "<workers>"
|
|
936
|
-
},
|
|
937
900
|
environment: {
|
|
938
901
|
description: "Specify runner environment, if not running in the browser (default: `node`)",
|
|
939
902
|
argument: "<name>",
|
|
@@ -1291,11 +1254,10 @@ function createCLI(options = {}) {
|
|
|
1291
1254
|
}), cli.command("run [...filters]", void 0, options).action(run), cli.command("related [...filters]", void 0, options).action(runRelated), cli.command("watch [...filters]", void 0, options).action(watch), cli.command("dev [...filters]", void 0, options).action(watch), addCliOptions(cli.command("bench [...filters]", void 0, options).action(benchmark), benchCliOptionsConfig), cli.command("init <project>", void 0, options).action(init), addCliOptions(cli.command("list [...filters]", void 0, options).action((filters, options) => collect("test", filters, options)), collectCliOptionsConfig), cli.command("[...filters]", void 0, options).action((filters, options) => start("test", filters, options)), cli;
|
|
1292
1255
|
}
|
|
1293
1256
|
function removeQuotes(str) {
|
|
1294
|
-
return typeof str === "string" ? str
|
|
1257
|
+
return typeof str === "string" ? str[0] === "\"" && str.endsWith("\"") || str.startsWith(`'`) && str.endsWith(`'`) ? str.slice(1, -1) : str : Array.isArray(str) ? str.map(removeQuotes) : str;
|
|
1295
1258
|
}
|
|
1296
1259
|
function splitArgv(argv) {
|
|
1297
|
-
|
|
1298
|
-
return argv = argv.replace(reg, (match) => match.replace(/\s/g, "\0")), argv.split(" ").map((arg) => {
|
|
1260
|
+
return argv = argv.replace(/(['"])(?:(?!\1).)+\1/g, (match) => match.replace(/\s/g, "\0")), argv.split(" ").map((arg) => {
|
|
1299
1261
|
return arg = arg.replace(/\0/g, " "), removeQuotes(arg);
|
|
1300
1262
|
});
|
|
1301
1263
|
}
|
|
@@ -1332,28 +1294,22 @@ function normalizeCliOptions(cliFilters, argv) {
|
|
|
1332
1294
|
}
|
|
1333
1295
|
async function start(mode, cliFilters, options) {
|
|
1334
1296
|
try {
|
|
1335
|
-
|
|
1336
|
-
} catch {}
|
|
1337
|
-
try {
|
|
1338
|
-
const { startVitest } = await import('./cli-api.C-JHgQgp.js').then(function (n) { return n.j; }), ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
|
|
1297
|
+
const { startVitest } = await import('./cli-api.PwHwIMss.js').then(function (n) { return n.p; }), ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
|
|
1339
1298
|
if (!ctx.shouldKeepServer()) await ctx.exit();
|
|
1340
1299
|
} catch (e) {
|
|
1341
|
-
const { errorBanner } = await import('./index.
|
|
1300
|
+
const { errorBanner } = await import('./index.CcRZ6fUh.js').then(function (n) { return n.u; });
|
|
1342
1301
|
if (console.error(`\n${errorBanner("Startup Error")}`), console.error(e), console.error("\n\n"), process.exitCode == null) process.exitCode = 1;
|
|
1343
1302
|
process.exit();
|
|
1344
1303
|
}
|
|
1345
1304
|
}
|
|
1346
1305
|
async function init(project) {
|
|
1347
1306
|
if (project !== "browser") console.error(/* @__PURE__ */ new Error("Only the \"browser\" project is supported. Use \"vitest init browser\" to create a new project.")), process.exit(1);
|
|
1348
|
-
const { create } = await import('./creator.
|
|
1307
|
+
const { create } = await import('./creator.DucAaYBz.js');
|
|
1349
1308
|
await create();
|
|
1350
1309
|
}
|
|
1351
1310
|
async function collect(mode, cliFilters, options) {
|
|
1352
1311
|
try {
|
|
1353
|
-
|
|
1354
|
-
} catch {}
|
|
1355
|
-
try {
|
|
1356
|
-
const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.C-JHgQgp.js').then(function (n) { return n.j; }), ctx = await prepareVitest(mode, {
|
|
1312
|
+
const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.PwHwIMss.js').then(function (n) { return n.p; }), ctx = await prepareVitest(mode, {
|
|
1357
1313
|
...normalizeCliOptions(cliFilters, options),
|
|
1358
1314
|
watch: false,
|
|
1359
1315
|
run: true
|
|
@@ -1371,7 +1327,7 @@ async function collect(mode, cliFilters, options) {
|
|
|
1371
1327
|
}
|
|
1372
1328
|
await ctx.close();
|
|
1373
1329
|
} catch (e) {
|
|
1374
|
-
const { errorBanner } = await import('./index.
|
|
1330
|
+
const { errorBanner } = await import('./index.CcRZ6fUh.js').then(function (n) { return n.u; });
|
|
1375
1331
|
if (console.error(`\n${errorBanner("Collect Error")}`), console.error(e), console.error("\n\n"), process.exitCode == null) process.exitCode = 1;
|
|
1376
1332
|
process.exit();
|
|
1377
1333
|
}
|