vitest 2.0.0-beta.9 → 2.0.1
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 -22
- package/dist/browser.d.ts +24 -7
- package/dist/browser.js +5 -19
- package/dist/chunks/browser-creator.DSqYDthP.js +673 -0
- package/dist/chunks/{environments-node.39w4gmlF.js → environments-node.XE5FbRPQ.js} +1 -1
- package/dist/chunks/{integrations-globals.BK0Cn4q1.js → integrations-globals.CzYWb38r.js} +10 -9
- package/dist/chunks/{node-git.CCI8evVZ.js → node-git.ZtkbKc8u.js} +14 -15
- package/dist/chunks/{runtime-console.DiVMr5d4.js → runtime-console.O41g23Zj.js} +26 -11
- package/dist/chunks/{runtime-runBaseTests.C-Bkopka.js → runtime-runBaseTests.DX3h28Mp.js} +47 -34
- package/dist/cli.js +3 -3
- package/dist/config.cjs +48 -23
- package/dist/config.d.ts +2 -1
- package/dist/config.js +48 -24
- package/dist/coverage.d.ts +6 -4
- package/dist/coverage.js +102 -38
- package/dist/environments.d.ts +2 -1
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +4 -3
- package/dist/execute.js +2 -2
- package/dist/index.d.ts +1437 -7
- package/dist/index.js +10 -9
- package/dist/node.d.ts +34 -7
- package/dist/node.js +31 -20
- package/dist/path.js +4 -1
- package/dist/{reporters-DaDey3o0.d.ts → reporters-BU_vXAUX.d.ts} +216 -206
- package/dist/reporters.d.ts +2 -1
- package/dist/reporters.js +8 -8
- package/dist/runners.d.ts +3 -1
- package/dist/runners.js +100 -61
- package/dist/snapshot.js +2 -2
- package/dist/{suite-BHSUxUib.d.ts → suite-BRl_IYuM.d.ts} +1 -1
- package/dist/suite.d.ts +3 -2
- package/dist/suite.js +3 -3
- package/dist/utils.d.ts +1 -5
- package/dist/utils.js +1 -6
- package/dist/vendor/{base._gnK9Slw.js → base.CTYV4Gnz.js} +24 -17
- package/dist/vendor/{base.D4XK-wRp.js → base.CdA1i5tB.js} +6 -4
- package/dist/vendor/{benchmark.BNLebNi5.js → benchmark.B6pblCp2.js} +13 -14
- package/dist/vendor/{cac.DCg3FnEs.js → cac.BQc6bsef.js} +142 -47
- package/dist/vendor/{cli-api.LMvYagQ5.js → cli-api.BGRtK_Kj.js} +4189 -9537
- package/dist/vendor/{constants.TCjCaw2D.js → constants.CsnA4eRy.js} +5 -23
- package/dist/vendor/{coverage.ChSqD-qS.js → coverage.BhYSDdTT.js} +27 -11
- package/dist/vendor/{date.BKM1wewY.js → date.W2xKR2qe.js} +5 -3
- package/dist/vendor/env.2ltrQNq0.js +8 -0
- package/dist/vendor/{execute.BHj6OMh4.js → execute.Dx503nGn.js} +186 -64
- package/dist/vendor/{index.TBU3GqRP.js → index.3x3MdmUV.js} +1075 -526
- package/dist/vendor/{index._7XLd8Kd.js → index.BJmtb_7W.js} +3 -2
- package/dist/vendor/{index.DP-km6lF.js → index.BMmMjLIQ.js} +64 -51
- package/dist/vendor/{index.DHRpy7zp.js → index.CROIsoiT.js} +18 -10
- package/dist/vendor/{index.DeR1hhfY.js → index.D4nqnQWz.js} +71 -74
- package/dist/vendor/index.D6GZqexG.js +6575 -0
- package/dist/vendor/{index.DwR86H5i.js → index.Hqvcg1pf.js} +4 -27
- package/dist/vendor/{rpc.DRDE9Pu1.js → rpc.BGx7q_k2.js} +30 -19
- package/dist/vendor/run-once.Db8Hgq9X.js +28 -0
- package/dist/vendor/{setup-common.BhJvzjns.js → setup-common.yHaxjRhz.js} +30 -15
- package/dist/vendor/spy.Cf_4R5Oe.js +22 -0
- package/dist/vendor/{tasks.WC7M-K-v.js → tasks.DhVtQBtW.js} +3 -1
- package/dist/vendor/{utils.YuQ3LT2a.js → utils.BVMrsl6E.js} +55 -30
- package/dist/vendor/{utils.CUjzkRH7.js → utils.DkxLWvS1.js} +12 -5
- package/dist/vendor/{vi.C6AfDXK6.js → vi.DXACdGTu.js} +269 -136
- package/dist/vendor/{vm.Ow-X2mkS.js → vm.BrDS6p7h.js} +157 -90
- package/dist/worker.js +41 -18
- package/dist/workers/forks.js +12 -6
- package/dist/workers/runVmTests.js +22 -16
- package/dist/workers/threads.js +8 -5
- package/dist/workers/vmForks.js +15 -9
- package/dist/workers/vmThreads.js +11 -8
- package/dist/workers.d.ts +8 -5
- package/dist/workers.js +11 -11
- package/package.json +22 -21
- package/suppress-warnings.cjs +2 -4
- package/dist/index-B0dCycbN.d.ts +0 -1571
- package/dist/vendor/env.bmJgw1qP.js +0 -7
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { normalize } from 'pathe';
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
3
|
import c from 'picocolors';
|
|
4
|
-
import { t as toArray } from './base.
|
|
5
|
-
import { d as defaultPort, a as defaultBrowserPort } from './constants.
|
|
4
|
+
import { t as toArray } from './base.CTYV4Gnz.js';
|
|
5
|
+
import { d as defaultPort, a as defaultBrowserPort } from './constants.CsnA4eRy.js';
|
|
6
6
|
|
|
7
7
|
function toArr(any) {
|
|
8
8
|
return any == null ? [] : Array.isArray(any) ? any : [any];
|
|
@@ -618,7 +618,7 @@ class CAC extends EventEmitter {
|
|
|
618
618
|
|
|
619
619
|
const cac = (name = "") => new CAC(name);
|
|
620
620
|
|
|
621
|
-
var version = "2.0.
|
|
621
|
+
var version = "2.0.1";
|
|
622
622
|
|
|
623
623
|
const apiConfig = (port) => ({
|
|
624
624
|
port: {
|
|
@@ -642,11 +642,11 @@ const poolThreadsCommands = {
|
|
|
642
642
|
description: "Run tests inside a single thread (default: `false`)"
|
|
643
643
|
},
|
|
644
644
|
maxThreads: {
|
|
645
|
-
description: "Maximum number of threads to run tests in",
|
|
645
|
+
description: "Maximum number or percentage of threads to run tests in",
|
|
646
646
|
argument: "<workers>"
|
|
647
647
|
},
|
|
648
648
|
minThreads: {
|
|
649
|
-
description: "Minimum number of threads to run tests in",
|
|
649
|
+
description: "Minimum number or percentage of threads to run tests in",
|
|
650
650
|
argument: "<workers>"
|
|
651
651
|
},
|
|
652
652
|
useAtomics: {
|
|
@@ -662,23 +662,25 @@ const poolForksCommands = {
|
|
|
662
662
|
description: "Run tests inside a single child_process (default: `false`)"
|
|
663
663
|
},
|
|
664
664
|
maxForks: {
|
|
665
|
-
description: "Maximum number of processes to run tests in",
|
|
665
|
+
description: "Maximum number or percentage of processes to run tests in",
|
|
666
666
|
argument: "<workers>"
|
|
667
667
|
},
|
|
668
668
|
minForks: {
|
|
669
|
-
description: "Minimum number of processes to run tests in",
|
|
669
|
+
description: "Minimum number or percentage of processes to run tests in",
|
|
670
670
|
argument: "<workers>"
|
|
671
671
|
},
|
|
672
672
|
execArgv: null
|
|
673
673
|
};
|
|
674
674
|
function watermarkTransform(value) {
|
|
675
|
-
if (typeof value === "string")
|
|
675
|
+
if (typeof value === "string") {
|
|
676
676
|
return value.split(",").map(Number);
|
|
677
|
+
}
|
|
677
678
|
return value;
|
|
678
679
|
}
|
|
679
680
|
function transformNestedBoolean(value) {
|
|
680
|
-
if (typeof value === "boolean")
|
|
681
|
+
if (typeof value === "boolean") {
|
|
681
682
|
return { enabled: value };
|
|
683
|
+
}
|
|
682
684
|
return value;
|
|
683
685
|
}
|
|
684
686
|
const cliOptionsConfig = {
|
|
@@ -898,14 +900,18 @@ const cliOptionsConfig = {
|
|
|
898
900
|
description: "Run tests in the browser. Equivalent to `--browser.enabled` (default: `false`)",
|
|
899
901
|
argument: "<name>",
|
|
900
902
|
transform(browser) {
|
|
901
|
-
if (typeof browser === "boolean")
|
|
903
|
+
if (typeof browser === "boolean") {
|
|
902
904
|
return { enabled: browser };
|
|
903
|
-
|
|
905
|
+
}
|
|
906
|
+
if (browser === "true" || browser === "false") {
|
|
904
907
|
return { enabled: browser === "true" };
|
|
905
|
-
|
|
908
|
+
}
|
|
909
|
+
if (browser === "yes" || browser === "no") {
|
|
906
910
|
return { enabled: browser === "yes" };
|
|
907
|
-
|
|
911
|
+
}
|
|
912
|
+
if (typeof browser === "string") {
|
|
908
913
|
return { enabled: true, name: browser };
|
|
914
|
+
}
|
|
909
915
|
return browser;
|
|
910
916
|
},
|
|
911
917
|
subcommands: {
|
|
@@ -942,10 +948,15 @@ const cliOptionsConfig = {
|
|
|
942
948
|
ui: {
|
|
943
949
|
description: "Show Vitest UI when running tests (default: `!process.env.CI`)"
|
|
944
950
|
},
|
|
951
|
+
fileParallelism: {
|
|
952
|
+
description: "Should browser test files run in parallel. Use `--browser.fileParallelism=false` to disable (default: `true`)"
|
|
953
|
+
},
|
|
945
954
|
orchestratorScripts: null,
|
|
946
955
|
testerScripts: null,
|
|
947
956
|
commands: null,
|
|
948
|
-
viewport: null
|
|
957
|
+
viewport: null,
|
|
958
|
+
screenshotDirectory: null,
|
|
959
|
+
screenshotFailures: null
|
|
949
960
|
}
|
|
950
961
|
},
|
|
951
962
|
pool: {
|
|
@@ -1068,10 +1079,12 @@ const cliOptionsConfig = {
|
|
|
1068
1079
|
description: "Enable Node.js inspector (default: `127.0.0.1:9229`)",
|
|
1069
1080
|
argument: "[[host:]port]",
|
|
1070
1081
|
transform(portOrEnabled) {
|
|
1071
|
-
if (portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes")
|
|
1082
|
+
if (portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes") {
|
|
1072
1083
|
return true;
|
|
1073
|
-
|
|
1084
|
+
}
|
|
1085
|
+
if (portOrEnabled === "false" || portOrEnabled === "no") {
|
|
1074
1086
|
return false;
|
|
1087
|
+
}
|
|
1075
1088
|
return portOrEnabled;
|
|
1076
1089
|
}
|
|
1077
1090
|
},
|
|
@@ -1079,10 +1092,12 @@ const cliOptionsConfig = {
|
|
|
1079
1092
|
description: "Enable Node.js inspector and break before the test starts",
|
|
1080
1093
|
argument: "[[host:]port]",
|
|
1081
1094
|
transform(portOrEnabled) {
|
|
1082
|
-
if (portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes")
|
|
1095
|
+
if (portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes") {
|
|
1083
1096
|
return true;
|
|
1084
|
-
|
|
1097
|
+
}
|
|
1098
|
+
if (portOrEnabled === "false" || portOrEnabled === "no") {
|
|
1085
1099
|
return false;
|
|
1100
|
+
}
|
|
1086
1101
|
return portOrEnabled;
|
|
1087
1102
|
}
|
|
1088
1103
|
},
|
|
@@ -1174,10 +1189,12 @@ const cliOptionsConfig = {
|
|
|
1174
1189
|
default: true,
|
|
1175
1190
|
// cache can only be "false" or an object
|
|
1176
1191
|
transform(cache) {
|
|
1177
|
-
if (typeof cache !== "boolean" && cache)
|
|
1192
|
+
if (typeof cache !== "boolean" && cache) {
|
|
1178
1193
|
throw new Error("--cache.dir is deprecated");
|
|
1179
|
-
|
|
1194
|
+
}
|
|
1195
|
+
if (cache) {
|
|
1180
1196
|
return {};
|
|
1197
|
+
}
|
|
1181
1198
|
return cache;
|
|
1182
1199
|
}
|
|
1183
1200
|
},
|
|
@@ -1207,15 +1224,21 @@ const cliOptionsConfig = {
|
|
|
1207
1224
|
}
|
|
1208
1225
|
},
|
|
1209
1226
|
transform(value) {
|
|
1210
|
-
if (typeof value !== "object")
|
|
1211
|
-
throw new
|
|
1227
|
+
if (typeof value !== "object") {
|
|
1228
|
+
throw new TypeError(
|
|
1229
|
+
`Unexpected value for --expect.poll: ${value}. If you need to configure timeout, use --expect.poll.timeout=<timeout>`
|
|
1230
|
+
);
|
|
1231
|
+
}
|
|
1212
1232
|
return value;
|
|
1213
1233
|
}
|
|
1214
1234
|
}
|
|
1215
1235
|
},
|
|
1216
1236
|
transform(value) {
|
|
1217
|
-
if (typeof value !== "object")
|
|
1218
|
-
throw new
|
|
1237
|
+
if (typeof value !== "object") {
|
|
1238
|
+
throw new TypeError(
|
|
1239
|
+
`Unexpected value for --expect: ${value}. If you need to configure expect options, use --expect.{name}=<value> syntax`
|
|
1240
|
+
);
|
|
1241
|
+
}
|
|
1219
1242
|
return value;
|
|
1220
1243
|
}
|
|
1221
1244
|
},
|
|
@@ -1240,8 +1263,9 @@ const cliOptionsConfig = {
|
|
|
1240
1263
|
description: "Paths to blob reports directory. If this options is used, Vitest won't run any tests, it will only report previously recorded tests",
|
|
1241
1264
|
argument: "[path]",
|
|
1242
1265
|
transform(value) {
|
|
1243
|
-
if (!value || typeof value === "boolean")
|
|
1266
|
+
if (!value || typeof value === "boolean") {
|
|
1244
1267
|
return ".vitest-reports";
|
|
1268
|
+
}
|
|
1245
1269
|
return value;
|
|
1246
1270
|
}
|
|
1247
1271
|
},
|
|
@@ -1278,24 +1302,32 @@ const cliOptionsConfig = {
|
|
|
1278
1302
|
includeTaskLocation: null,
|
|
1279
1303
|
snapshotEnvironment: null,
|
|
1280
1304
|
compare: null,
|
|
1281
|
-
outputJson: null
|
|
1305
|
+
outputJson: null,
|
|
1306
|
+
json: null
|
|
1282
1307
|
};
|
|
1283
1308
|
const benchCliOptionsConfig = {
|
|
1284
1309
|
compare: {
|
|
1285
|
-
description: "
|
|
1310
|
+
description: "Benchmark output file to compare against",
|
|
1286
1311
|
argument: "<filename>"
|
|
1287
1312
|
},
|
|
1288
1313
|
outputJson: {
|
|
1289
|
-
description: "
|
|
1314
|
+
description: "Benchmark output file",
|
|
1290
1315
|
argument: "<filename>"
|
|
1291
1316
|
}
|
|
1292
1317
|
};
|
|
1318
|
+
const collectCliOptionsConfig = {
|
|
1319
|
+
json: {
|
|
1320
|
+
description: "Print collected tests as JSON or write to a file (Default: false)",
|
|
1321
|
+
argument: "[true/path]"
|
|
1322
|
+
}
|
|
1323
|
+
};
|
|
1293
1324
|
|
|
1294
1325
|
function addCommand(cli, name, option) {
|
|
1295
1326
|
const commandName = option.alias || name;
|
|
1296
1327
|
let command = option.shorthand ? `-${option.shorthand}, --${commandName}` : `--${commandName}`;
|
|
1297
|
-
if ("argument" in option)
|
|
1328
|
+
if ("argument" in option) {
|
|
1298
1329
|
command += ` ${option.argument}`;
|
|
1330
|
+
}
|
|
1299
1331
|
function transform(value) {
|
|
1300
1332
|
if (!option.array && Array.isArray(value)) {
|
|
1301
1333
|
const received = value.map((s) => typeof s === "string" ? `"${s}"` : s).join(", ");
|
|
@@ -1303,19 +1335,23 @@ function addCommand(cli, name, option) {
|
|
|
1303
1335
|
`Expected a single value for option "${command}", received [${received}]`
|
|
1304
1336
|
);
|
|
1305
1337
|
}
|
|
1306
|
-
if (option.transform)
|
|
1338
|
+
if (option.transform) {
|
|
1307
1339
|
return option.transform(value);
|
|
1308
|
-
|
|
1340
|
+
}
|
|
1341
|
+
if (option.array) {
|
|
1309
1342
|
return toArray(value);
|
|
1310
|
-
|
|
1343
|
+
}
|
|
1344
|
+
if (option.normalize) {
|
|
1311
1345
|
return normalize(String(value));
|
|
1346
|
+
}
|
|
1312
1347
|
return value;
|
|
1313
1348
|
}
|
|
1314
1349
|
const hasSubcommands = "subcommands" in option && option.subcommands;
|
|
1315
1350
|
if (option.description) {
|
|
1316
1351
|
let description = option.description.replace(/\[.*\]\((.*)\)/, "$1").replace(/`/g, "");
|
|
1317
|
-
if (hasSubcommands)
|
|
1352
|
+
if (hasSubcommands) {
|
|
1318
1353
|
description += `. Use '--help --${commandName}' for more info.`;
|
|
1354
|
+
}
|
|
1319
1355
|
cli.option(command, description, {
|
|
1320
1356
|
type: transform
|
|
1321
1357
|
});
|
|
@@ -1323,15 +1359,17 @@ function addCommand(cli, name, option) {
|
|
|
1323
1359
|
if (hasSubcommands) {
|
|
1324
1360
|
for (const commandName2 in option.subcommands) {
|
|
1325
1361
|
const subcommand = option.subcommands[commandName2];
|
|
1326
|
-
if (subcommand)
|
|
1362
|
+
if (subcommand) {
|
|
1327
1363
|
addCommand(cli, `${name}.${commandName2}`, subcommand);
|
|
1364
|
+
}
|
|
1328
1365
|
}
|
|
1329
1366
|
}
|
|
1330
1367
|
}
|
|
1331
1368
|
function addCliOptions(cli, options) {
|
|
1332
1369
|
for (const [optionName, option] of Object.entries(options)) {
|
|
1333
|
-
if (option)
|
|
1370
|
+
if (option) {
|
|
1334
1371
|
addCommand(cli, optionName, option);
|
|
1372
|
+
}
|
|
1335
1373
|
}
|
|
1336
1374
|
}
|
|
1337
1375
|
function createCLI(options = {}) {
|
|
@@ -1343,11 +1381,13 @@ function createCLI(options = {}) {
|
|
|
1343
1381
|
var _a;
|
|
1344
1382
|
return (_a = current.title) == null ? void 0 : _a.startsWith("For more info, run any command");
|
|
1345
1383
|
});
|
|
1346
|
-
if (helpSection)
|
|
1384
|
+
if (helpSection) {
|
|
1347
1385
|
helpSection.body += "\n $ vitest --help --expand-help";
|
|
1386
|
+
}
|
|
1348
1387
|
const options2 = info.find((current) => current.title === "Options");
|
|
1349
|
-
if (typeof options2 !== "object")
|
|
1388
|
+
if (typeof options2 !== "object") {
|
|
1350
1389
|
return info;
|
|
1390
|
+
}
|
|
1351
1391
|
const helpIndex = process.argv.findIndex((arg) => arg === "--help");
|
|
1352
1392
|
const subcommands = process.argv.slice(helpIndex + 1);
|
|
1353
1393
|
const defaultOutput = options2.body.split("\n").filter((line) => /^\s+--\S+\./.test(line) === false).join("\n");
|
|
@@ -1355,14 +1395,16 @@ function createCLI(options = {}) {
|
|
|
1355
1395
|
options2.body = defaultOutput;
|
|
1356
1396
|
return info;
|
|
1357
1397
|
}
|
|
1358
|
-
if (subcommands.length === 1 && (subcommands[0] === "--expand-help" || subcommands[0] === "--expandHelp"))
|
|
1398
|
+
if (subcommands.length === 1 && (subcommands[0] === "--expand-help" || subcommands[0] === "--expandHelp")) {
|
|
1359
1399
|
return info;
|
|
1400
|
+
}
|
|
1360
1401
|
const subcommandMarker = "$SUB_COMMAND_MARKER$";
|
|
1361
1402
|
const banner = info.find((current) => /^vitest\/\d+\.\d+\.\d+$/.test(current.body));
|
|
1362
1403
|
function addBannerWarning(warning) {
|
|
1363
1404
|
if (typeof (banner == null ? void 0 : banner.body) === "string") {
|
|
1364
|
-
if (banner == null ? void 0 : banner.body.includes(warning))
|
|
1405
|
+
if (banner == null ? void 0 : banner.body.includes(warning)) {
|
|
1365
1406
|
return;
|
|
1407
|
+
}
|
|
1366
1408
|
banner.body = `${banner.body}
|
|
1367
1409
|
WARN: ${warning}`;
|
|
1368
1410
|
}
|
|
@@ -1392,22 +1434,30 @@ function createCLI(options = {}) {
|
|
|
1392
1434
|
cli.command("bench [...filters]", void 0, options).action(benchmark),
|
|
1393
1435
|
benchCliOptionsConfig
|
|
1394
1436
|
);
|
|
1437
|
+
cli.command("init <project>", void 0, options).action(init);
|
|
1438
|
+
addCliOptions(
|
|
1439
|
+
cli.command("list [...filters]", void 0, options).action((filters, options2) => collect("test", filters, options2)),
|
|
1440
|
+
collectCliOptionsConfig
|
|
1441
|
+
);
|
|
1395
1442
|
cli.command("[...filters]", void 0, options).action((filters, options2) => start("test", filters, options2));
|
|
1396
1443
|
return cli;
|
|
1397
1444
|
}
|
|
1398
1445
|
function parseCLI(argv, config = {}) {
|
|
1399
1446
|
const arrayArgs = typeof argv === "string" ? argv.split(" ") : argv;
|
|
1400
|
-
if (arrayArgs[0] !== "vitest")
|
|
1447
|
+
if (arrayArgs[0] !== "vitest") {
|
|
1401
1448
|
throw new Error(`Expected "vitest" as the first argument, received "${arrayArgs[0]}"`);
|
|
1449
|
+
}
|
|
1402
1450
|
arrayArgs[0] = "/index.js";
|
|
1403
1451
|
arrayArgs.unshift("node");
|
|
1404
1452
|
let { args, options } = createCLI(config).parse(arrayArgs, {
|
|
1405
1453
|
run: false
|
|
1406
1454
|
});
|
|
1407
|
-
if (arrayArgs[2] === "watch" || arrayArgs[2] === "dev")
|
|
1455
|
+
if (arrayArgs[2] === "watch" || arrayArgs[2] === "dev") {
|
|
1408
1456
|
options.watch = true;
|
|
1409
|
-
|
|
1457
|
+
}
|
|
1458
|
+
if (arrayArgs[2] === "run") {
|
|
1410
1459
|
options.run = true;
|
|
1460
|
+
}
|
|
1411
1461
|
if (arrayArgs[2] === "related") {
|
|
1412
1462
|
options.related = args;
|
|
1413
1463
|
options.passWithNoTests ?? (options.passWithNoTests = true);
|
|
@@ -1448,19 +1498,64 @@ async function start(mode, cliFilters, options) {
|
|
|
1448
1498
|
} catch {
|
|
1449
1499
|
}
|
|
1450
1500
|
try {
|
|
1451
|
-
const { startVitest } = await import('./cli-api.
|
|
1501
|
+
const { startVitest } = await import('./cli-api.BGRtK_Kj.js').then(function (n) { return n.h; });
|
|
1452
1502
|
const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(options));
|
|
1453
|
-
if (!(ctx == null ? void 0 : ctx.shouldKeepServer()))
|
|
1503
|
+
if (!(ctx == null ? void 0 : ctx.shouldKeepServer())) {
|
|
1454
1504
|
await (ctx == null ? void 0 : ctx.exit());
|
|
1455
|
-
|
|
1505
|
+
}
|
|
1456
1506
|
} catch (e) {
|
|
1457
|
-
const { divider } = await import('./utils.
|
|
1507
|
+
const { divider } = await import('./utils.BVMrsl6E.js').then(function (n) { return n.u; });
|
|
1458
1508
|
console.error(`
|
|
1459
|
-
${c.red(divider(c.bold(c.inverse("
|
|
1509
|
+
${c.red(divider(c.bold(c.inverse(" Startup Error "))))}`);
|
|
1460
1510
|
console.error(e);
|
|
1461
1511
|
console.error("\n\n");
|
|
1512
|
+
if (process.exitCode == null) {
|
|
1513
|
+
process.exitCode = 1;
|
|
1514
|
+
}
|
|
1515
|
+
process.exit();
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
async function init(project) {
|
|
1519
|
+
if (project !== "browser") {
|
|
1520
|
+
console.error(new Error('Only the "browser" project is supported. Use "vitest init browser" to create a new project.'));
|
|
1462
1521
|
process.exit(1);
|
|
1463
1522
|
}
|
|
1523
|
+
const { create } = await import('../chunks/browser-creator.DSqYDthP.js');
|
|
1524
|
+
await create();
|
|
1525
|
+
}
|
|
1526
|
+
async function collect(mode, cliFilters, options) {
|
|
1527
|
+
try {
|
|
1528
|
+
process.title = "node (vitest)";
|
|
1529
|
+
} catch {
|
|
1530
|
+
}
|
|
1531
|
+
try {
|
|
1532
|
+
const { prepareVitest, processCollected } = await import('./cli-api.BGRtK_Kj.js').then(function (n) { return n.h; });
|
|
1533
|
+
const ctx = await prepareVitest(mode, {
|
|
1534
|
+
...normalizeCliOptions(options),
|
|
1535
|
+
watch: false,
|
|
1536
|
+
run: true
|
|
1537
|
+
});
|
|
1538
|
+
const { tests, errors } = await ctx.collect(cliFilters.map(normalize));
|
|
1539
|
+
if (errors.length) {
|
|
1540
|
+
console.error("\nThere were unhandled errors during test collection");
|
|
1541
|
+
errors.forEach((e) => console.error(e));
|
|
1542
|
+
console.error("\n\n");
|
|
1543
|
+
await ctx.close();
|
|
1544
|
+
return;
|
|
1545
|
+
}
|
|
1546
|
+
processCollected(ctx, tests, options);
|
|
1547
|
+
await ctx.close();
|
|
1548
|
+
} catch (e) {
|
|
1549
|
+
const { divider } = await import('./utils.BVMrsl6E.js').then(function (n) { return n.u; });
|
|
1550
|
+
console.error(`
|
|
1551
|
+
${c.red(divider(c.bold(c.inverse(" Collect Error "))))}`);
|
|
1552
|
+
console.error(e);
|
|
1553
|
+
console.error("\n\n");
|
|
1554
|
+
if (process.exitCode == null) {
|
|
1555
|
+
process.exitCode = 1;
|
|
1556
|
+
}
|
|
1557
|
+
process.exit();
|
|
1558
|
+
}
|
|
1464
1559
|
}
|
|
1465
1560
|
|
|
1466
1561
|
export { createCLI as c, parseCLI as p, version as v };
|