vitest 2.0.0-beta.11 → 2.0.0-beta.13

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.
Files changed (56) hide show
  1. package/LICENSE.md +0 -21
  2. package/dist/browser.d.ts +3 -2
  3. package/dist/browser.js +2 -2
  4. package/dist/chunks/browser-creator.DSqYDthP.js +673 -0
  5. package/dist/chunks/{environments-node.39w4gmlF.js → environments-node.XE5FbRPQ.js} +1 -1
  6. package/dist/chunks/{integrations-globals.CC2ed6Py.js → integrations-globals.CzYWb38r.js} +6 -6
  7. package/dist/chunks/{runtime-console.Ckl0vEQr.js → runtime-console.O41g23Zj.js} +1 -1
  8. package/dist/chunks/{runtime-runBaseTests.BXW_BJeO.js → runtime-runBaseTests.DX3h28Mp.js} +15 -11
  9. package/dist/cli.js +2 -2
  10. package/dist/config.cjs +6 -4
  11. package/dist/config.d.ts +2 -1
  12. package/dist/config.js +6 -4
  13. package/dist/coverage.d.ts +4 -2
  14. package/dist/coverage.js +3 -2
  15. package/dist/environments.d.ts +2 -1
  16. package/dist/execute.d.ts +4 -3
  17. package/dist/execute.js +1 -1
  18. package/dist/index.d.ts +7 -6
  19. package/dist/index.js +6 -6
  20. package/dist/node.d.ts +19 -5
  21. package/dist/node.js +15 -14
  22. package/dist/{reporters-fiIq_dT9.d.ts → reporters-DrywOHjt.d.ts} +73 -23
  23. package/dist/reporters.d.ts +2 -1
  24. package/dist/reporters.js +5 -5
  25. package/dist/runners.d.ts +3 -1
  26. package/dist/runners.js +5 -4
  27. package/dist/snapshot.js +2 -2
  28. package/dist/{suite-D4aoU9rI.d.ts → suite-CrOPuDIk.d.ts} +1 -1
  29. package/dist/suite.d.ts +3 -2
  30. package/dist/suite.js +3 -3
  31. package/dist/vendor/{base.C2DbLEfT.js → base.CdA1i5tB.js} +4 -3
  32. package/dist/vendor/{benchmark.CMp8QfyL.js → benchmark.B6pblCp2.js} +1 -1
  33. package/dist/vendor/{cac.BcJW7n2j.js → cac.CpoEMnGk.js} +71 -14
  34. package/dist/vendor/{cli-api.C8t8m4__.js → cli-api.CXFLjKVN.js} +400 -6675
  35. package/dist/vendor/{constants.BWsVtsAj.js → constants.CsnA4eRy.js} +1 -2
  36. package/dist/vendor/env.2ltrQNq0.js +8 -0
  37. package/dist/vendor/{execute.T3gg2ZK6.js → execute.Dx503nGn.js} +12 -4
  38. package/dist/vendor/{index.BC5zhX9y.js → index.3x3MdmUV.js} +139 -82
  39. package/dist/vendor/{index.C9Thslzw.js → index.BJmtb_7W.js} +1 -1
  40. package/dist/vendor/{index.-dbR4KUi.js → index.CROIsoiT.js} +2 -2
  41. package/dist/vendor/index.D6GZqexG.js +6575 -0
  42. package/dist/vendor/{index.CQJ2m700.js → index.Hqvcg1pf.js} +2 -2
  43. package/dist/vendor/{setup-common.uqZOEWuR.js → setup-common.yHaxjRhz.js} +1 -1
  44. package/dist/vendor/{utils.DSO2UK15.js → utils.BVMrsl6E.js} +15 -5
  45. package/dist/vendor/{vi.BPjl8cAZ.js → vi.DXACdGTu.js} +1 -1
  46. package/dist/vendor/{vm.CycSoHnJ.js → vm.BrDS6p7h.js} +8 -6
  47. package/dist/worker.js +11 -4
  48. package/dist/workers/forks.js +10 -4
  49. package/dist/workers/runVmTests.js +14 -10
  50. package/dist/workers/threads.js +6 -3
  51. package/dist/workers/vmForks.js +12 -6
  52. package/dist/workers/vmThreads.js +8 -5
  53. package/dist/workers.d.ts +7 -4
  54. package/dist/workers.js +6 -6
  55. package/package.json +12 -12
  56. package/dist/vendor/env.bmJgw1qP.js +0 -7
@@ -2,7 +2,7 @@ import { normalize } from 'pathe';
2
2
  import { EventEmitter } from 'events';
3
3
  import c from 'picocolors';
4
4
  import { t as toArray } from './base.CTYV4Gnz.js';
5
- import { d as defaultPort, a as defaultBrowserPort } from './constants.BWsVtsAj.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.0-beta.11";
621
+ var version = "2.0.0-beta.13";
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,11 +662,11 @@ 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
@@ -955,7 +955,8 @@ const cliOptionsConfig = {
955
955
  testerScripts: null,
956
956
  commands: null,
957
957
  viewport: null,
958
- screenshotDirectory: null
958
+ screenshotDirectory: null,
959
+ screenshotFailures: null
959
960
  }
960
961
  },
961
962
  pool: {
@@ -1301,18 +1302,25 @@ const cliOptionsConfig = {
1301
1302
  includeTaskLocation: null,
1302
1303
  snapshotEnvironment: null,
1303
1304
  compare: null,
1304
- outputJson: null
1305
+ outputJson: null,
1306
+ json: null
1305
1307
  };
1306
1308
  const benchCliOptionsConfig = {
1307
1309
  compare: {
1308
- description: "benchmark output file to compare against",
1310
+ description: "Benchmark output file to compare against",
1309
1311
  argument: "<filename>"
1310
1312
  },
1311
1313
  outputJson: {
1312
- description: "benchmark output file",
1314
+ description: "Benchmark output file",
1313
1315
  argument: "<filename>"
1314
1316
  }
1315
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
+ };
1316
1324
 
1317
1325
  function addCommand(cli, name, option) {
1318
1326
  const commandName = option.alias || name;
@@ -1426,6 +1434,11 @@ function createCLI(options = {}) {
1426
1434
  cli.command("bench [...filters]", void 0, options).action(benchmark),
1427
1435
  benchCliOptionsConfig
1428
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
+ );
1429
1442
  cli.command("[...filters]", void 0, options).action((filters, options2) => start("test", filters, options2));
1430
1443
  return cli;
1431
1444
  }
@@ -1485,20 +1498,64 @@ async function start(mode, cliFilters, options) {
1485
1498
  } catch {
1486
1499
  }
1487
1500
  try {
1488
- const { startVitest } = await import('./cli-api.C8t8m4__.js').then(function (n) { return n.h; });
1501
+ const { startVitest } = await import('./cli-api.CXFLjKVN.js').then(function (n) { return n.h; });
1489
1502
  const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(options));
1490
1503
  if (!(ctx == null ? void 0 : ctx.shouldKeepServer())) {
1491
1504
  await (ctx == null ? void 0 : ctx.exit());
1492
1505
  }
1493
- return ctx;
1494
1506
  } catch (e) {
1495
- const { divider } = await import('./utils.DSO2UK15.js').then(function (n) { return n.u; });
1507
+ const { divider } = await import('./utils.BVMrsl6E.js').then(function (n) { return n.u; });
1496
1508
  console.error(`
1497
- ${c.red(divider(c.bold(c.inverse(" Unhandled Error "))))}`);
1509
+ ${c.red(divider(c.bold(c.inverse(" Startup Error "))))}`);
1498
1510
  console.error(e);
1499
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.'));
1500
1521
  process.exit(1);
1501
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.CXFLjKVN.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
+ }
1502
1559
  }
1503
1560
 
1504
1561
  export { createCLI as c, parseCLI as p, version as v };