vitest 2.0.0-beta.10 → 2.0.0-beta.11
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/dist/browser.d.ts +1 -1
- package/dist/browser.js +3 -3
- package/dist/chunks/{integrations-globals.C6Ah-pUW.js → integrations-globals.CC2ed6Py.js} +9 -9
- package/dist/chunks/{node-git.CCI8evVZ.js → node-git.ZtkbKc8u.js} +14 -15
- package/dist/chunks/{runtime-console.DiVMr5d4.js → runtime-console.Ckl0vEQr.js} +25 -10
- package/dist/chunks/{runtime-runBaseTests.Cukyr5-I.js → runtime-runBaseTests.BXW_BJeO.js} +40 -32
- package/dist/cli.js +3 -3
- package/dist/config.cjs +42 -19
- package/dist/config.d.ts +1 -1
- package/dist/config.js +42 -20
- package/dist/coverage.d.ts +4 -4
- package/dist/coverage.js +98 -36
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +1 -1
- package/dist/execute.js +2 -2
- package/dist/index.d.ts +34 -8
- package/dist/index.js +9 -9
- package/dist/node.d.ts +19 -6
- package/dist/node.js +24 -16
- package/dist/path.js +4 -1
- package/dist/{reporters-CYVC6LOl.d.ts → reporters-fiIq_dT9.d.ts} +118 -179
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +7 -7
- package/dist/runners.d.ts +1 -1
- package/dist/runners.js +98 -60
- package/dist/{suite-Dpu9EC_k.d.ts → suite-D4aoU9rI.d.ts} +1 -1
- package/dist/suite.d.ts +2 -2
- package/dist/suite.js +2 -2
- package/dist/utils.d.ts +1 -5
- package/dist/utils.js +1 -6
- package/dist/vendor/{base.Dln9yllP.js → base.C2DbLEfT.js} +4 -3
- package/dist/vendor/{base._gnK9Slw.js → base.CTYV4Gnz.js} +24 -17
- package/dist/vendor/{benchmark.BNLebNi5.js → benchmark.CMp8QfyL.js} +13 -14
- package/dist/vendor/{cac.CtYFkoSJ.js → cac.BcJW7n2j.js} +71 -37
- package/dist/vendor/{cli-api.CUtJc4r3.js → cli-api.C8t8m4__.js} +4012 -4828
- package/dist/vendor/{constants.TCjCaw2D.js → constants.BWsVtsAj.js} +5 -22
- 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/{execute.BHj6OMh4.js → execute.T3gg2ZK6.js} +174 -60
- package/dist/vendor/{index.B5SKBLvV.js → index.-dbR4KUi.js} +17 -9
- package/dist/vendor/{index.BOMEjpjj.js → index.BC5zhX9y.js} +960 -469
- package/dist/vendor/{index.CThipSqB.js → index.BMmMjLIQ.js} +2540 -2540
- package/dist/vendor/{index._7XLd8Kd.js → index.C9Thslzw.js} +2 -1
- package/dist/vendor/{index.D3hs2WiI.js → index.CQJ2m700.js} +3 -3
- package/dist/vendor/{index.kpsSqFiz.js → index.D4nqnQWz.js} +69 -73
- package/dist/vendor/{rpc.DRDE9Pu1.js → rpc.BGx7q_k2.js} +30 -19
- package/dist/vendor/{run-once.DLomgGUH.js → run-once.Db8Hgq9X.js} +2 -1
- package/dist/vendor/{setup-common.DAu7t7mY.js → setup-common.uqZOEWuR.js} +30 -15
- package/dist/vendor/{tasks.WC7M-K-v.js → tasks.DhVtQBtW.js} +3 -1
- package/dist/vendor/{utils.YuQ3LT2a.js → utils.DSO2UK15.js} +40 -25
- package/dist/vendor/{utils.CUjzkRH7.js → utils.DkxLWvS1.js} +12 -5
- package/dist/vendor/{vi.hATFzZbX.js → vi.BPjl8cAZ.js} +266 -137
- package/dist/vendor/{vm.Ow-X2mkS.js → vm.CycSoHnJ.js} +151 -86
- package/dist/worker.js +31 -15
- package/dist/workers/forks.js +4 -4
- package/dist/workers/runVmTests.js +14 -13
- 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 +2 -2
- package/dist/workers.js +9 -9
- package/package.json +11 -11
- package/suppress-warnings.cjs +1 -4
|
@@ -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.BWsVtsAj.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.0-beta.
|
|
621
|
+
var version = "2.0.0-beta.11";
|
|
622
622
|
|
|
623
623
|
const apiConfig = (port) => ({
|
|
624
624
|
port: {
|
|
@@ -672,13 +672,15 @@ const poolForksCommands = {
|
|
|
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: {
|
|
@@ -1072,10 +1078,12 @@ const cliOptionsConfig = {
|
|
|
1072
1078
|
description: "Enable Node.js inspector (default: `127.0.0.1:9229`)",
|
|
1073
1079
|
argument: "[[host:]port]",
|
|
1074
1080
|
transform(portOrEnabled) {
|
|
1075
|
-
if (portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes")
|
|
1081
|
+
if (portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes") {
|
|
1076
1082
|
return true;
|
|
1077
|
-
|
|
1083
|
+
}
|
|
1084
|
+
if (portOrEnabled === "false" || portOrEnabled === "no") {
|
|
1078
1085
|
return false;
|
|
1086
|
+
}
|
|
1079
1087
|
return portOrEnabled;
|
|
1080
1088
|
}
|
|
1081
1089
|
},
|
|
@@ -1083,10 +1091,12 @@ const cliOptionsConfig = {
|
|
|
1083
1091
|
description: "Enable Node.js inspector and break before the test starts",
|
|
1084
1092
|
argument: "[[host:]port]",
|
|
1085
1093
|
transform(portOrEnabled) {
|
|
1086
|
-
if (portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes")
|
|
1094
|
+
if (portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes") {
|
|
1087
1095
|
return true;
|
|
1088
|
-
|
|
1096
|
+
}
|
|
1097
|
+
if (portOrEnabled === "false" || portOrEnabled === "no") {
|
|
1089
1098
|
return false;
|
|
1099
|
+
}
|
|
1090
1100
|
return portOrEnabled;
|
|
1091
1101
|
}
|
|
1092
1102
|
},
|
|
@@ -1178,10 +1188,12 @@ const cliOptionsConfig = {
|
|
|
1178
1188
|
default: true,
|
|
1179
1189
|
// cache can only be "false" or an object
|
|
1180
1190
|
transform(cache) {
|
|
1181
|
-
if (typeof cache !== "boolean" && cache)
|
|
1191
|
+
if (typeof cache !== "boolean" && cache) {
|
|
1182
1192
|
throw new Error("--cache.dir is deprecated");
|
|
1183
|
-
|
|
1193
|
+
}
|
|
1194
|
+
if (cache) {
|
|
1184
1195
|
return {};
|
|
1196
|
+
}
|
|
1185
1197
|
return cache;
|
|
1186
1198
|
}
|
|
1187
1199
|
},
|
|
@@ -1211,15 +1223,21 @@ const cliOptionsConfig = {
|
|
|
1211
1223
|
}
|
|
1212
1224
|
},
|
|
1213
1225
|
transform(value) {
|
|
1214
|
-
if (typeof value !== "object")
|
|
1215
|
-
throw new
|
|
1226
|
+
if (typeof value !== "object") {
|
|
1227
|
+
throw new TypeError(
|
|
1228
|
+
`Unexpected value for --expect.poll: ${value}. If you need to configure timeout, use --expect.poll.timeout=<timeout>`
|
|
1229
|
+
);
|
|
1230
|
+
}
|
|
1216
1231
|
return value;
|
|
1217
1232
|
}
|
|
1218
1233
|
}
|
|
1219
1234
|
},
|
|
1220
1235
|
transform(value) {
|
|
1221
|
-
if (typeof value !== "object")
|
|
1222
|
-
throw new
|
|
1236
|
+
if (typeof value !== "object") {
|
|
1237
|
+
throw new TypeError(
|
|
1238
|
+
`Unexpected value for --expect: ${value}. If you need to configure expect options, use --expect.{name}=<value> syntax`
|
|
1239
|
+
);
|
|
1240
|
+
}
|
|
1223
1241
|
return value;
|
|
1224
1242
|
}
|
|
1225
1243
|
},
|
|
@@ -1244,8 +1262,9 @@ const cliOptionsConfig = {
|
|
|
1244
1262
|
description: "Paths to blob reports directory. If this options is used, Vitest won't run any tests, it will only report previously recorded tests",
|
|
1245
1263
|
argument: "[path]",
|
|
1246
1264
|
transform(value) {
|
|
1247
|
-
if (!value || typeof value === "boolean")
|
|
1265
|
+
if (!value || typeof value === "boolean") {
|
|
1248
1266
|
return ".vitest-reports";
|
|
1267
|
+
}
|
|
1249
1268
|
return value;
|
|
1250
1269
|
}
|
|
1251
1270
|
},
|
|
@@ -1298,8 +1317,9 @@ const benchCliOptionsConfig = {
|
|
|
1298
1317
|
function addCommand(cli, name, option) {
|
|
1299
1318
|
const commandName = option.alias || name;
|
|
1300
1319
|
let command = option.shorthand ? `-${option.shorthand}, --${commandName}` : `--${commandName}`;
|
|
1301
|
-
if ("argument" in option)
|
|
1320
|
+
if ("argument" in option) {
|
|
1302
1321
|
command += ` ${option.argument}`;
|
|
1322
|
+
}
|
|
1303
1323
|
function transform(value) {
|
|
1304
1324
|
if (!option.array && Array.isArray(value)) {
|
|
1305
1325
|
const received = value.map((s) => typeof s === "string" ? `"${s}"` : s).join(", ");
|
|
@@ -1307,19 +1327,23 @@ function addCommand(cli, name, option) {
|
|
|
1307
1327
|
`Expected a single value for option "${command}", received [${received}]`
|
|
1308
1328
|
);
|
|
1309
1329
|
}
|
|
1310
|
-
if (option.transform)
|
|
1330
|
+
if (option.transform) {
|
|
1311
1331
|
return option.transform(value);
|
|
1312
|
-
|
|
1332
|
+
}
|
|
1333
|
+
if (option.array) {
|
|
1313
1334
|
return toArray(value);
|
|
1314
|
-
|
|
1335
|
+
}
|
|
1336
|
+
if (option.normalize) {
|
|
1315
1337
|
return normalize(String(value));
|
|
1338
|
+
}
|
|
1316
1339
|
return value;
|
|
1317
1340
|
}
|
|
1318
1341
|
const hasSubcommands = "subcommands" in option && option.subcommands;
|
|
1319
1342
|
if (option.description) {
|
|
1320
1343
|
let description = option.description.replace(/\[.*\]\((.*)\)/, "$1").replace(/`/g, "");
|
|
1321
|
-
if (hasSubcommands)
|
|
1344
|
+
if (hasSubcommands) {
|
|
1322
1345
|
description += `. Use '--help --${commandName}' for more info.`;
|
|
1346
|
+
}
|
|
1323
1347
|
cli.option(command, description, {
|
|
1324
1348
|
type: transform
|
|
1325
1349
|
});
|
|
@@ -1327,15 +1351,17 @@ function addCommand(cli, name, option) {
|
|
|
1327
1351
|
if (hasSubcommands) {
|
|
1328
1352
|
for (const commandName2 in option.subcommands) {
|
|
1329
1353
|
const subcommand = option.subcommands[commandName2];
|
|
1330
|
-
if (subcommand)
|
|
1354
|
+
if (subcommand) {
|
|
1331
1355
|
addCommand(cli, `${name}.${commandName2}`, subcommand);
|
|
1356
|
+
}
|
|
1332
1357
|
}
|
|
1333
1358
|
}
|
|
1334
1359
|
}
|
|
1335
1360
|
function addCliOptions(cli, options) {
|
|
1336
1361
|
for (const [optionName, option] of Object.entries(options)) {
|
|
1337
|
-
if (option)
|
|
1362
|
+
if (option) {
|
|
1338
1363
|
addCommand(cli, optionName, option);
|
|
1364
|
+
}
|
|
1339
1365
|
}
|
|
1340
1366
|
}
|
|
1341
1367
|
function createCLI(options = {}) {
|
|
@@ -1347,11 +1373,13 @@ function createCLI(options = {}) {
|
|
|
1347
1373
|
var _a;
|
|
1348
1374
|
return (_a = current.title) == null ? void 0 : _a.startsWith("For more info, run any command");
|
|
1349
1375
|
});
|
|
1350
|
-
if (helpSection)
|
|
1376
|
+
if (helpSection) {
|
|
1351
1377
|
helpSection.body += "\n $ vitest --help --expand-help";
|
|
1378
|
+
}
|
|
1352
1379
|
const options2 = info.find((current) => current.title === "Options");
|
|
1353
|
-
if (typeof options2 !== "object")
|
|
1380
|
+
if (typeof options2 !== "object") {
|
|
1354
1381
|
return info;
|
|
1382
|
+
}
|
|
1355
1383
|
const helpIndex = process.argv.findIndex((arg) => arg === "--help");
|
|
1356
1384
|
const subcommands = process.argv.slice(helpIndex + 1);
|
|
1357
1385
|
const defaultOutput = options2.body.split("\n").filter((line) => /^\s+--\S+\./.test(line) === false).join("\n");
|
|
@@ -1359,14 +1387,16 @@ function createCLI(options = {}) {
|
|
|
1359
1387
|
options2.body = defaultOutput;
|
|
1360
1388
|
return info;
|
|
1361
1389
|
}
|
|
1362
|
-
if (subcommands.length === 1 && (subcommands[0] === "--expand-help" || subcommands[0] === "--expandHelp"))
|
|
1390
|
+
if (subcommands.length === 1 && (subcommands[0] === "--expand-help" || subcommands[0] === "--expandHelp")) {
|
|
1363
1391
|
return info;
|
|
1392
|
+
}
|
|
1364
1393
|
const subcommandMarker = "$SUB_COMMAND_MARKER$";
|
|
1365
1394
|
const banner = info.find((current) => /^vitest\/\d+\.\d+\.\d+$/.test(current.body));
|
|
1366
1395
|
function addBannerWarning(warning) {
|
|
1367
1396
|
if (typeof (banner == null ? void 0 : banner.body) === "string") {
|
|
1368
|
-
if (banner == null ? void 0 : banner.body.includes(warning))
|
|
1397
|
+
if (banner == null ? void 0 : banner.body.includes(warning)) {
|
|
1369
1398
|
return;
|
|
1399
|
+
}
|
|
1370
1400
|
banner.body = `${banner.body}
|
|
1371
1401
|
WARN: ${warning}`;
|
|
1372
1402
|
}
|
|
@@ -1401,17 +1431,20 @@ function createCLI(options = {}) {
|
|
|
1401
1431
|
}
|
|
1402
1432
|
function parseCLI(argv, config = {}) {
|
|
1403
1433
|
const arrayArgs = typeof argv === "string" ? argv.split(" ") : argv;
|
|
1404
|
-
if (arrayArgs[0] !== "vitest")
|
|
1434
|
+
if (arrayArgs[0] !== "vitest") {
|
|
1405
1435
|
throw new Error(`Expected "vitest" as the first argument, received "${arrayArgs[0]}"`);
|
|
1436
|
+
}
|
|
1406
1437
|
arrayArgs[0] = "/index.js";
|
|
1407
1438
|
arrayArgs.unshift("node");
|
|
1408
1439
|
let { args, options } = createCLI(config).parse(arrayArgs, {
|
|
1409
1440
|
run: false
|
|
1410
1441
|
});
|
|
1411
|
-
if (arrayArgs[2] === "watch" || arrayArgs[2] === "dev")
|
|
1442
|
+
if (arrayArgs[2] === "watch" || arrayArgs[2] === "dev") {
|
|
1412
1443
|
options.watch = true;
|
|
1413
|
-
|
|
1444
|
+
}
|
|
1445
|
+
if (arrayArgs[2] === "run") {
|
|
1414
1446
|
options.run = true;
|
|
1447
|
+
}
|
|
1415
1448
|
if (arrayArgs[2] === "related") {
|
|
1416
1449
|
options.related = args;
|
|
1417
1450
|
options.passWithNoTests ?? (options.passWithNoTests = true);
|
|
@@ -1452,13 +1485,14 @@ async function start(mode, cliFilters, options) {
|
|
|
1452
1485
|
} catch {
|
|
1453
1486
|
}
|
|
1454
1487
|
try {
|
|
1455
|
-
const { startVitest } = await import('./cli-api.
|
|
1488
|
+
const { startVitest } = await import('./cli-api.C8t8m4__.js').then(function (n) { return n.h; });
|
|
1456
1489
|
const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(options));
|
|
1457
|
-
if (!(ctx == null ? void 0 : ctx.shouldKeepServer()))
|
|
1490
|
+
if (!(ctx == null ? void 0 : ctx.shouldKeepServer())) {
|
|
1458
1491
|
await (ctx == null ? void 0 : ctx.exit());
|
|
1492
|
+
}
|
|
1459
1493
|
return ctx;
|
|
1460
1494
|
} catch (e) {
|
|
1461
|
-
const { divider } = await import('./utils.
|
|
1495
|
+
const { divider } = await import('./utils.DSO2UK15.js').then(function (n) { return n.u; });
|
|
1462
1496
|
console.error(`
|
|
1463
1497
|
${c.red(divider(c.bold(c.inverse(" Unhandled Error "))))}`);
|
|
1464
1498
|
console.error(e);
|