vitest 2.0.0-beta.10 → 2.0.0-beta.12
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/browser-creator.Bw94IHrL.js +673 -0
- package/dist/chunks/{environments-node.39w4gmlF.js → environments-node.XE5FbRPQ.js} +1 -1
- package/dist/chunks/{integrations-globals.C6Ah-pUW.js → integrations-globals.DSNOaUHv.js} +10 -10
- 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.Cukyr5-I.js → runtime-runBaseTests.BDt9gQFB.js} +41 -33
- package/dist/cli.js +3 -3
- package/dist/config.cjs +45 -21
- package/dist/config.d.ts +1 -1
- package/dist/config.js +45 -22
- package/dist/coverage.d.ts +5 -4
- package/dist/coverage.js +100 -37
- 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 +37 -11
- package/dist/index.js +10 -10
- package/dist/node.d.ts +20 -7
- package/dist/node.js +29 -20
- package/dist/path.js +4 -1
- package/dist/{reporters-CYVC6LOl.d.ts → reporters-Cd1vkLMZ.d.ts} +134 -182
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +8 -8
- package/dist/runners.d.ts +1 -1
- package/dist/runners.js +99 -61
- package/dist/snapshot.js +2 -2
- package/dist/{suite-Dpu9EC_k.d.ts → suite-BS2CV79a.d.ts} +1 -1
- package/dist/suite.d.ts +2 -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.Dln9yllP.js → base.Cy97mmVC.js} +4 -3
- package/dist/vendor/{benchmark.BNLebNi5.js → benchmark.B6pblCp2.js} +13 -14
- package/dist/vendor/{cac.CtYFkoSJ.js → cac.DRNUX42m.js} +82 -38
- package/dist/vendor/{cli-api.CUtJc4r3.js → cli-api.Bu-PSdzx.js} +5908 -13271
- 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/env.2ltrQNq0.js +8 -0
- package/dist/vendor/{execute.BHj6OMh4.js → execute.T3gg2ZK6.js} +174 -60
- package/dist/vendor/{index.B5SKBLvV.js → index.B7pSlOSa.js} +18 -10
- package/dist/vendor/{index._7XLd8Kd.js → index.BJmtb_7W.js} +3 -2
- package/dist/vendor/{index.CThipSqB.js → index.BMmMjLIQ.js} +2540 -2540
- package/dist/vendor/{index.kpsSqFiz.js → index.D4nqnQWz.js} +69 -73
- package/dist/vendor/index.D6GZqexG.js +6575 -0
- package/dist/vendor/{index.D3hs2WiI.js → index.Hqvcg1pf.js} +3 -3
- package/dist/vendor/{index.BOMEjpjj.js → index.ZtQtNPP2.js} +962 -471
- 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.CWnv_2-5.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.DXACdGTu.js} +267 -138
- package/dist/vendor/{vm.Ow-X2mkS.js → vm.D9wVR14y.js} +152 -87
- package/dist/worker.js +31 -15
- package/dist/workers/forks.js +4 -4
- package/dist/workers/runVmTests.js +15 -14
- package/dist/workers/threads.js +4 -4
- package/dist/workers/vmForks.js +7 -7
- package/dist/workers/vmThreads.js +7 -7
- package/dist/workers.d.ts +2 -2
- package/dist/workers.js +10 -10
- package/package.json +11 -11
- package/suppress-warnings.cjs +1 -4
- 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.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.12";
|
|
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: {
|
|
@@ -949,7 +955,8 @@ const cliOptionsConfig = {
|
|
|
949
955
|
testerScripts: null,
|
|
950
956
|
commands: null,
|
|
951
957
|
viewport: null,
|
|
952
|
-
screenshotDirectory: null
|
|
958
|
+
screenshotDirectory: null,
|
|
959
|
+
screenshotFailures: null
|
|
953
960
|
}
|
|
954
961
|
},
|
|
955
962
|
pool: {
|
|
@@ -1072,10 +1079,12 @@ const cliOptionsConfig = {
|
|
|
1072
1079
|
description: "Enable Node.js inspector (default: `127.0.0.1:9229`)",
|
|
1073
1080
|
argument: "[[host:]port]",
|
|
1074
1081
|
transform(portOrEnabled) {
|
|
1075
|
-
if (portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes")
|
|
1082
|
+
if (portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes") {
|
|
1076
1083
|
return true;
|
|
1077
|
-
|
|
1084
|
+
}
|
|
1085
|
+
if (portOrEnabled === "false" || portOrEnabled === "no") {
|
|
1078
1086
|
return false;
|
|
1087
|
+
}
|
|
1079
1088
|
return portOrEnabled;
|
|
1080
1089
|
}
|
|
1081
1090
|
},
|
|
@@ -1083,10 +1092,12 @@ const cliOptionsConfig = {
|
|
|
1083
1092
|
description: "Enable Node.js inspector and break before the test starts",
|
|
1084
1093
|
argument: "[[host:]port]",
|
|
1085
1094
|
transform(portOrEnabled) {
|
|
1086
|
-
if (portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes")
|
|
1095
|
+
if (portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes") {
|
|
1087
1096
|
return true;
|
|
1088
|
-
|
|
1097
|
+
}
|
|
1098
|
+
if (portOrEnabled === "false" || portOrEnabled === "no") {
|
|
1089
1099
|
return false;
|
|
1100
|
+
}
|
|
1090
1101
|
return portOrEnabled;
|
|
1091
1102
|
}
|
|
1092
1103
|
},
|
|
@@ -1178,10 +1189,12 @@ const cliOptionsConfig = {
|
|
|
1178
1189
|
default: true,
|
|
1179
1190
|
// cache can only be "false" or an object
|
|
1180
1191
|
transform(cache) {
|
|
1181
|
-
if (typeof cache !== "boolean" && cache)
|
|
1192
|
+
if (typeof cache !== "boolean" && cache) {
|
|
1182
1193
|
throw new Error("--cache.dir is deprecated");
|
|
1183
|
-
|
|
1194
|
+
}
|
|
1195
|
+
if (cache) {
|
|
1184
1196
|
return {};
|
|
1197
|
+
}
|
|
1185
1198
|
return cache;
|
|
1186
1199
|
}
|
|
1187
1200
|
},
|
|
@@ -1211,15 +1224,21 @@ const cliOptionsConfig = {
|
|
|
1211
1224
|
}
|
|
1212
1225
|
},
|
|
1213
1226
|
transform(value) {
|
|
1214
|
-
if (typeof value !== "object")
|
|
1215
|
-
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
|
+
}
|
|
1216
1232
|
return value;
|
|
1217
1233
|
}
|
|
1218
1234
|
}
|
|
1219
1235
|
},
|
|
1220
1236
|
transform(value) {
|
|
1221
|
-
if (typeof value !== "object")
|
|
1222
|
-
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
|
+
}
|
|
1223
1242
|
return value;
|
|
1224
1243
|
}
|
|
1225
1244
|
},
|
|
@@ -1244,8 +1263,9 @@ const cliOptionsConfig = {
|
|
|
1244
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",
|
|
1245
1264
|
argument: "[path]",
|
|
1246
1265
|
transform(value) {
|
|
1247
|
-
if (!value || typeof value === "boolean")
|
|
1266
|
+
if (!value || typeof value === "boolean") {
|
|
1248
1267
|
return ".vitest-reports";
|
|
1268
|
+
}
|
|
1249
1269
|
return value;
|
|
1250
1270
|
}
|
|
1251
1271
|
},
|
|
@@ -1298,8 +1318,9 @@ const benchCliOptionsConfig = {
|
|
|
1298
1318
|
function addCommand(cli, name, option) {
|
|
1299
1319
|
const commandName = option.alias || name;
|
|
1300
1320
|
let command = option.shorthand ? `-${option.shorthand}, --${commandName}` : `--${commandName}`;
|
|
1301
|
-
if ("argument" in option)
|
|
1321
|
+
if ("argument" in option) {
|
|
1302
1322
|
command += ` ${option.argument}`;
|
|
1323
|
+
}
|
|
1303
1324
|
function transform(value) {
|
|
1304
1325
|
if (!option.array && Array.isArray(value)) {
|
|
1305
1326
|
const received = value.map((s) => typeof s === "string" ? `"${s}"` : s).join(", ");
|
|
@@ -1307,19 +1328,23 @@ function addCommand(cli, name, option) {
|
|
|
1307
1328
|
`Expected a single value for option "${command}", received [${received}]`
|
|
1308
1329
|
);
|
|
1309
1330
|
}
|
|
1310
|
-
if (option.transform)
|
|
1331
|
+
if (option.transform) {
|
|
1311
1332
|
return option.transform(value);
|
|
1312
|
-
|
|
1333
|
+
}
|
|
1334
|
+
if (option.array) {
|
|
1313
1335
|
return toArray(value);
|
|
1314
|
-
|
|
1336
|
+
}
|
|
1337
|
+
if (option.normalize) {
|
|
1315
1338
|
return normalize(String(value));
|
|
1339
|
+
}
|
|
1316
1340
|
return value;
|
|
1317
1341
|
}
|
|
1318
1342
|
const hasSubcommands = "subcommands" in option && option.subcommands;
|
|
1319
1343
|
if (option.description) {
|
|
1320
1344
|
let description = option.description.replace(/\[.*\]\((.*)\)/, "$1").replace(/`/g, "");
|
|
1321
|
-
if (hasSubcommands)
|
|
1345
|
+
if (hasSubcommands) {
|
|
1322
1346
|
description += `. Use '--help --${commandName}' for more info.`;
|
|
1347
|
+
}
|
|
1323
1348
|
cli.option(command, description, {
|
|
1324
1349
|
type: transform
|
|
1325
1350
|
});
|
|
@@ -1327,15 +1352,17 @@ function addCommand(cli, name, option) {
|
|
|
1327
1352
|
if (hasSubcommands) {
|
|
1328
1353
|
for (const commandName2 in option.subcommands) {
|
|
1329
1354
|
const subcommand = option.subcommands[commandName2];
|
|
1330
|
-
if (subcommand)
|
|
1355
|
+
if (subcommand) {
|
|
1331
1356
|
addCommand(cli, `${name}.${commandName2}`, subcommand);
|
|
1357
|
+
}
|
|
1332
1358
|
}
|
|
1333
1359
|
}
|
|
1334
1360
|
}
|
|
1335
1361
|
function addCliOptions(cli, options) {
|
|
1336
1362
|
for (const [optionName, option] of Object.entries(options)) {
|
|
1337
|
-
if (option)
|
|
1363
|
+
if (option) {
|
|
1338
1364
|
addCommand(cli, optionName, option);
|
|
1365
|
+
}
|
|
1339
1366
|
}
|
|
1340
1367
|
}
|
|
1341
1368
|
function createCLI(options = {}) {
|
|
@@ -1347,11 +1374,13 @@ function createCLI(options = {}) {
|
|
|
1347
1374
|
var _a;
|
|
1348
1375
|
return (_a = current.title) == null ? void 0 : _a.startsWith("For more info, run any command");
|
|
1349
1376
|
});
|
|
1350
|
-
if (helpSection)
|
|
1377
|
+
if (helpSection) {
|
|
1351
1378
|
helpSection.body += "\n $ vitest --help --expand-help";
|
|
1379
|
+
}
|
|
1352
1380
|
const options2 = info.find((current) => current.title === "Options");
|
|
1353
|
-
if (typeof options2 !== "object")
|
|
1381
|
+
if (typeof options2 !== "object") {
|
|
1354
1382
|
return info;
|
|
1383
|
+
}
|
|
1355
1384
|
const helpIndex = process.argv.findIndex((arg) => arg === "--help");
|
|
1356
1385
|
const subcommands = process.argv.slice(helpIndex + 1);
|
|
1357
1386
|
const defaultOutput = options2.body.split("\n").filter((line) => /^\s+--\S+\./.test(line) === false).join("\n");
|
|
@@ -1359,14 +1388,16 @@ function createCLI(options = {}) {
|
|
|
1359
1388
|
options2.body = defaultOutput;
|
|
1360
1389
|
return info;
|
|
1361
1390
|
}
|
|
1362
|
-
if (subcommands.length === 1 && (subcommands[0] === "--expand-help" || subcommands[0] === "--expandHelp"))
|
|
1391
|
+
if (subcommands.length === 1 && (subcommands[0] === "--expand-help" || subcommands[0] === "--expandHelp")) {
|
|
1363
1392
|
return info;
|
|
1393
|
+
}
|
|
1364
1394
|
const subcommandMarker = "$SUB_COMMAND_MARKER$";
|
|
1365
1395
|
const banner = info.find((current) => /^vitest\/\d+\.\d+\.\d+$/.test(current.body));
|
|
1366
1396
|
function addBannerWarning(warning) {
|
|
1367
1397
|
if (typeof (banner == null ? void 0 : banner.body) === "string") {
|
|
1368
|
-
if (banner == null ? void 0 : banner.body.includes(warning))
|
|
1398
|
+
if (banner == null ? void 0 : banner.body.includes(warning)) {
|
|
1369
1399
|
return;
|
|
1400
|
+
}
|
|
1370
1401
|
banner.body = `${banner.body}
|
|
1371
1402
|
WARN: ${warning}`;
|
|
1372
1403
|
}
|
|
@@ -1396,22 +1427,26 @@ function createCLI(options = {}) {
|
|
|
1396
1427
|
cli.command("bench [...filters]", void 0, options).action(benchmark),
|
|
1397
1428
|
benchCliOptionsConfig
|
|
1398
1429
|
);
|
|
1430
|
+
cli.command("init <project>", void 0, options).action(init);
|
|
1399
1431
|
cli.command("[...filters]", void 0, options).action((filters, options2) => start("test", filters, options2));
|
|
1400
1432
|
return cli;
|
|
1401
1433
|
}
|
|
1402
1434
|
function parseCLI(argv, config = {}) {
|
|
1403
1435
|
const arrayArgs = typeof argv === "string" ? argv.split(" ") : argv;
|
|
1404
|
-
if (arrayArgs[0] !== "vitest")
|
|
1436
|
+
if (arrayArgs[0] !== "vitest") {
|
|
1405
1437
|
throw new Error(`Expected "vitest" as the first argument, received "${arrayArgs[0]}"`);
|
|
1438
|
+
}
|
|
1406
1439
|
arrayArgs[0] = "/index.js";
|
|
1407
1440
|
arrayArgs.unshift("node");
|
|
1408
1441
|
let { args, options } = createCLI(config).parse(arrayArgs, {
|
|
1409
1442
|
run: false
|
|
1410
1443
|
});
|
|
1411
|
-
if (arrayArgs[2] === "watch" || arrayArgs[2] === "dev")
|
|
1444
|
+
if (arrayArgs[2] === "watch" || arrayArgs[2] === "dev") {
|
|
1412
1445
|
options.watch = true;
|
|
1413
|
-
|
|
1446
|
+
}
|
|
1447
|
+
if (arrayArgs[2] === "run") {
|
|
1414
1448
|
options.run = true;
|
|
1449
|
+
}
|
|
1415
1450
|
if (arrayArgs[2] === "related") {
|
|
1416
1451
|
options.related = args;
|
|
1417
1452
|
options.passWithNoTests ?? (options.passWithNoTests = true);
|
|
@@ -1452,13 +1487,14 @@ async function start(mode, cliFilters, options) {
|
|
|
1452
1487
|
} catch {
|
|
1453
1488
|
}
|
|
1454
1489
|
try {
|
|
1455
|
-
const { startVitest } = await import('./cli-api.
|
|
1490
|
+
const { startVitest } = await import('./cli-api.Bu-PSdzx.js').then(function (n) { return n.h; });
|
|
1456
1491
|
const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(options));
|
|
1457
|
-
if (!(ctx == null ? void 0 : ctx.shouldKeepServer()))
|
|
1492
|
+
if (!(ctx == null ? void 0 : ctx.shouldKeepServer())) {
|
|
1458
1493
|
await (ctx == null ? void 0 : ctx.exit());
|
|
1494
|
+
}
|
|
1459
1495
|
return ctx;
|
|
1460
1496
|
} catch (e) {
|
|
1461
|
-
const { divider } = await import('./utils.
|
|
1497
|
+
const { divider } = await import('./utils.DSO2UK15.js').then(function (n) { return n.u; });
|
|
1462
1498
|
console.error(`
|
|
1463
1499
|
${c.red(divider(c.bold(c.inverse(" Unhandled Error "))))}`);
|
|
1464
1500
|
console.error(e);
|
|
@@ -1466,5 +1502,13 @@ ${c.red(divider(c.bold(c.inverse(" Unhandled Error "))))}`);
|
|
|
1466
1502
|
process.exit(1);
|
|
1467
1503
|
}
|
|
1468
1504
|
}
|
|
1505
|
+
async function init(project) {
|
|
1506
|
+
if (project !== "browser") {
|
|
1507
|
+
console.error(new Error('Only the "browser" project is supported. Use "vitest init browser" to create a new project.'));
|
|
1508
|
+
process.exit(1);
|
|
1509
|
+
}
|
|
1510
|
+
const { create } = await import('../chunks/browser-creator.Bw94IHrL.js');
|
|
1511
|
+
await create();
|
|
1512
|
+
}
|
|
1469
1513
|
|
|
1470
1514
|
export { createCLI as c, parseCLI as p, version as v };
|