vitest 2.0.4 → 2.1.0-beta.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.
Files changed (80) hide show
  1. package/dist/browser.d.ts +21 -42
  2. package/dist/browser.js +5 -5
  3. package/dist/chunks/RandomSequencer.B4M2ux5b.js +952 -0
  4. package/dist/{vendor/base.DRHPZCCj.js → chunks/base.BH-FAiX7.js} +2 -2
  5. package/dist/{vendor/base.Csk7BT3h.js → chunks/base.BYvKfYzm.js} +3 -3
  6. package/dist/{vendor/benchmark.B6pblCp2.js → chunks/benchmark.C8CRJYG4.js} +1 -1
  7. package/dist/chunks/benchmark.puBFxyfE.d.ts +22 -0
  8. package/dist/{vendor/cac.DFtWvZc2.js → chunks/cac.CaYKA7Wt.js} +19 -21
  9. package/dist/{vendor/cli-api.CTkP2Ier.js → chunks/cli-api.B8LE391_.js} +500 -4615
  10. package/dist/chunks/config.CHuotKvS.d.ts +206 -0
  11. package/dist/chunks/{runtime-console.C2L2zykk.js → console.DI3gHgtH.js} +11 -14
  12. package/dist/{vendor/constants.CsnA4eRy.js → chunks/constants.CaAN7icJ.js} +1 -3
  13. package/dist/{vendor/coverage.BhYSDdTT.js → chunks/coverage.CqfT4xaf.js} +4 -7
  14. package/dist/chunks/{browser-creator.CyaOd8pl.js → creator.GreKbaUc.js} +10 -11
  15. package/dist/chunks/env.CmHVDJnw.js +7 -0
  16. package/dist/chunks/environment.0M5R1SX_.d.ts +173 -0
  17. package/dist/{vendor/execute.jzOWtys_.js → chunks/execute.DT9BA6zp.js} +28 -20
  18. package/dist/chunks/globals.DRPLtPOv.js +31 -0
  19. package/dist/{vendor/index.D6GZqexG.js → chunks/index.CM5UI-4O.js} +2 -2
  20. package/dist/{vendor/index.DI9daj1Q.js → chunks/index.CNZXZ9PJ.js} +43 -43
  21. package/dist/{vendor/index.BJmtb_7W.js → chunks/index.CxRxs566.js} +2 -2
  22. package/dist/{vendor/index.CVqMv71L.js → chunks/index.CxWPpGJz.js} +11 -12
  23. package/dist/{vendor/index.CuuL9y4g.js → chunks/index.YuPJueCg.js} +505 -1185
  24. package/dist/{vendor/index.D4nqnQWz.js → chunks/index.lVXYBqEP.js} +1 -18
  25. package/dist/{vendor/inspector.-FCQUzqR.js → chunks/inspector.70d6emsh.js} +4 -5
  26. package/dist/chunks/{environments-node.XE5FbRPQ.js → node.Bx4JZjMG.js} +2 -2
  27. package/dist/{reporters-B7ebVMkT.d.ts → chunks/reporters.DRZ7ndzr.d.ts} +860 -1000
  28. package/dist/chunks/resolveConfig.CGobt8AB.js +8120 -0
  29. package/dist/{vendor/rpc.BGx7q_k2.js → chunks/rpc.B7Mfb-Yf.js} +3 -5
  30. package/dist/{vendor/run-once.Db8Hgq9X.js → chunks/run-once.Sxe67Wng.js} +1 -1
  31. package/dist/chunks/{runtime-runBaseTests.Dq_sJZq9.js → runBaseTests.BAhL8UH_.js} +21 -23
  32. package/dist/{vendor/setup-common.symvFZPh.js → chunks/setup-common.KBrCO5LJ.js} +2 -2
  33. package/dist/{suite-CRLAhsm0.d.ts → chunks/suite.CcK46U-P.d.ts} +1 -1
  34. package/dist/{vendor/tasks.DhVtQBtW.js → chunks/tasks.BZnCS9aT.js} +2 -3
  35. package/dist/{vendor/utils.DkxLWvS1.js → chunks/utils.C3_cBsyn.js} +3 -4
  36. package/dist/{vendor/global.7bFbnyXl.js → chunks/utils.Ck2hJTRs.js} +1 -1
  37. package/dist/{vendor/utils.BySfPUwy.js → chunks/utils.DO38lwfj.js} +8 -21
  38. package/dist/{vendor/vi.Elqer9-7.js → chunks/vi.B6QZ938s.js} +13 -18
  39. package/dist/{vendor/vm.img-AOox.js → chunks/vm.kl9T_5ai.js} +40 -68
  40. package/dist/chunks/worker.BANO5ak1.d.ts +144 -0
  41. package/dist/chunks/worker.Cx2xE71X.d.ts +8 -0
  42. package/dist/cli.js +3 -3
  43. package/dist/config.cjs +6 -8
  44. package/dist/config.d.ts +10 -8
  45. package/dist/config.js +6 -8
  46. package/dist/coverage.d.ts +10 -8
  47. package/dist/coverage.js +35 -15
  48. package/dist/environments.d.ts +3 -19
  49. package/dist/environments.js +1 -1
  50. package/dist/execute.d.ts +5 -14
  51. package/dist/execute.js +2 -2
  52. package/dist/index.d.ts +267 -34
  53. package/dist/index.js +12 -12
  54. package/dist/node.d.ts +15 -9
  55. package/dist/node.js +26 -28
  56. package/dist/reporters.d.ts +10 -8
  57. package/dist/reporters.js +16 -18
  58. package/dist/runners.d.ts +15 -20
  59. package/dist/runners.js +12 -13
  60. package/dist/snapshot.js +3 -3
  61. package/dist/suite.d.ts +2 -16
  62. package/dist/suite.js +4 -4
  63. package/dist/worker.js +7 -8
  64. package/dist/workers/forks.js +5 -5
  65. package/dist/workers/runVmTests.js +18 -19
  66. package/dist/workers/threads.js +5 -5
  67. package/dist/workers/vmForks.js +8 -8
  68. package/dist/workers/vmThreads.js +8 -8
  69. package/dist/workers.d.ts +13 -8
  70. package/dist/workers.js +13 -13
  71. package/package.json +16 -17
  72. package/dist/chunks/integrations-globals.nDMtdOcn.js +0 -31
  73. package/dist/vendor/env.2ltrQNq0.js +0 -8
  74. package/dist/vendor/index.BMmMjLIQ.js +0 -3975
  75. /package/dist/{vendor → chunks}/_commonjsHelpers.BFTU3MAI.js +0 -0
  76. /package/dist/{vendor → chunks}/date.W2xKR2qe.js +0 -0
  77. /package/dist/chunks/{node-git.ZtkbKc8u.js → git.ZtkbKc8u.js} +0 -0
  78. /package/dist/{vendor → chunks}/index.BpSiYbpB.js +0 -0
  79. /package/dist/chunks/{install-pkg.DNUmWFkO.js → index.DNUmWFkO.js} +0 -0
  80. /package/dist/{vendor → chunks}/spy.Cf_4R5Oe.js +0 -0
@@ -8,7 +8,7 @@ function collectOwnProperties(obj, collector) {
8
8
  function groupBy(collection, iteratee) {
9
9
  return collection.reduce((acc, item) => {
10
10
  const key = iteratee(item);
11
- acc[key] || (acc[key] = []);
11
+ acc[key] ||= [];
12
12
  acc[key].push(item);
13
13
  return acc;
14
14
  }, {});
@@ -123,4 +123,4 @@ function nanoid(size = 21) {
123
123
  return id;
124
124
  }
125
125
 
126
- export { AggregateErrorPonyfill as A, slash as a, isPrimitive as b, groupBy as c, deepMerge as d, nanoid as e, stdout as f, getAllMockableProperties as g, isChildProcess as i, noop as n, setProcessTitle as s, toArray as t, wildcardPatternToRegExp as w };
126
+ export { AggregateErrorPonyfill as A, slash as a, groupBy as b, isPrimitive as c, deepMerge as d, nanoid as e, stdout as f, getAllMockableProperties as g, isChildProcess as i, noop as n, setProcessTitle as s, toArray as t, wildcardPatternToRegExp as w };
@@ -1,6 +1,6 @@
1
1
  import { ModuleCacheMap } from 'vite-node/client';
2
- import { p as provideWorkerState } from './global.7bFbnyXl.js';
3
- import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.jzOWtys_.js';
2
+ import { p as provideWorkerState } from './utils.Ck2hJTRs.js';
3
+ import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.DT9BA6zp.js';
4
4
 
5
5
  let _viteNode;
6
6
  const moduleCache = new ModuleCacheMap();
@@ -26,7 +26,7 @@ async function runBaseTests(method, state) {
26
26
  ctx.files.forEach((i) => state.moduleCache.delete(i));
27
27
  const [executor, { run }] = await Promise.all([
28
28
  startViteNode({ state, requestStubs: getDefaultRequestStubs() }),
29
- import('../chunks/runtime-runBaseTests.Dq_sJZq9.js')
29
+ import('./runBaseTests.BAhL8UH_.js')
30
30
  ]);
31
31
  await run(
32
32
  method,
@@ -1,7 +1,7 @@
1
1
  import { getCurrentSuite } from '@vitest/runner';
2
2
  import { createChainable } from '@vitest/runner/utils';
3
3
  import { noop } from '@vitest/utils';
4
- import { i as isRunningInBenchmark } from './index.BJmtb_7W.js';
4
+ import { i as isRunningInBenchmark } from './index.CxRxs566.js';
5
5
 
6
6
  const benchFns = /* @__PURE__ */ new WeakMap();
7
7
  const benchOptsMap = /* @__PURE__ */ new WeakMap();
@@ -0,0 +1,22 @@
1
+ import { Custom } from '@vitest/runner';
2
+ import { ChainableFunction } from '@vitest/runner/utils';
3
+ import { TaskResult, Bench, Options } from 'tinybench';
4
+
5
+ interface Benchmark extends Custom {
6
+ meta: {
7
+ benchmark: true;
8
+ result?: TaskResult;
9
+ };
10
+ }
11
+ interface BenchmarkResult extends TaskResult {
12
+ name: string;
13
+ rank: number;
14
+ }
15
+ type BenchFunction = (this: Bench) => Promise<void> | void;
16
+ type ChainableBenchmarkAPI = ChainableFunction<'skip' | 'only' | 'todo', (name: string | Function, fn?: BenchFunction, options?: Options) => void>;
17
+ type BenchmarkAPI = ChainableBenchmarkAPI & {
18
+ skipIf: (condition: any) => ChainableBenchmarkAPI;
19
+ runIf: (condition: any) => ChainableBenchmarkAPI;
20
+ };
21
+
22
+ export type { BenchmarkResult as B, Benchmark as a, BenchFunction as b, BenchmarkAPI as c };
@@ -1,8 +1,8 @@
1
1
  import { normalize } from 'pathe';
2
2
  import { EventEmitter } from 'events';
3
3
  import c from 'tinyrainbow';
4
- import { t as toArray } from './base.DRHPZCCj.js';
5
- import { d as defaultPort, a as defaultBrowserPort } from './constants.CsnA4eRy.js';
4
+ import { t as toArray } from './base.BH-FAiX7.js';
5
+ import { d as defaultPort, a as defaultBrowserPort } from './constants.CaAN7icJ.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.4";
621
+ var version = "2.1.0-beta.1";
622
622
 
623
623
  const apiConfig = (port) => ({
624
624
  port: {
@@ -741,7 +741,7 @@ const cliOptionsConfig = {
741
741
  },
742
742
  outputFile: {
743
743
  argument: "<filename/-s>",
744
- description: "Write test results to a file when supporter reporter is also specified, use cac's dot notation for individual outputs of multiple reporters (example: --outputFile.tap=./tap.txt)",
744
+ description: "Write test results to a file when supporter reporter is also specified, use cac's dot notation for individual outputs of multiple reporters (example: `--outputFile.tap=./tap.txt`)",
745
745
  subcommands: null
746
746
  },
747
747
  coverage: {
@@ -956,7 +956,8 @@ const cliOptionsConfig = {
956
956
  commands: null,
957
957
  viewport: null,
958
958
  screenshotDirectory: null,
959
- screenshotFailures: null
959
+ screenshotFailures: null,
960
+ locators: null
960
961
  }
961
962
  },
962
963
  pool: {
@@ -1062,7 +1063,7 @@ const cliOptionsConfig = {
1062
1063
  description: "Make tests run in parallel (default: `false`)"
1063
1064
  },
1064
1065
  seed: {
1065
- description: 'Set the randomization seed. This option will have no effect if --sequence.shuffle is falsy. Visit ["Random Seed" page](https://en.wikipedia.org/wiki/Random_seed) for more information',
1066
+ description: 'Set the randomization seed. This option will have no effect if `--sequence.shuffle` is falsy. Visit ["Random Seed" page](https://en.wikipedia.org/wiki/Random_seed) for more information',
1066
1067
  argument: "<seed>"
1067
1068
  },
1068
1069
  hooks: {
@@ -1377,10 +1378,7 @@ function createCLI(options = {}) {
1377
1378
  cli.version(version);
1378
1379
  addCliOptions(cli, cliOptionsConfig);
1379
1380
  cli.help((info) => {
1380
- const helpSection = info.find((current) => {
1381
- var _a;
1382
- return (_a = current.title) == null ? void 0 : _a.startsWith("For more info, run any command");
1383
- });
1381
+ const helpSection = info.find((current) => current.title?.startsWith("For more info, run any command"));
1384
1382
  if (helpSection) {
1385
1383
  helpSection.body += "\n $ vitest --help --expand-help";
1386
1384
  }
@@ -1401,8 +1399,8 @@ function createCLI(options = {}) {
1401
1399
  const subcommandMarker = "$SUB_COMMAND_MARKER$";
1402
1400
  const banner = info.find((current) => /^vitest\/\d+\.\d+\.\d+$/.test(current.body));
1403
1401
  function addBannerWarning(warning) {
1404
- if (typeof (banner == null ? void 0 : banner.body) === "string") {
1405
- if (banner == null ? void 0 : banner.body.includes(warning)) {
1402
+ if (typeof banner?.body === "string") {
1403
+ if (banner?.body.includes(warning)) {
1406
1404
  return;
1407
1405
  }
1408
1406
  banner.body = `${banner.body}
@@ -1460,7 +1458,7 @@ function parseCLI(argv, config = {}) {
1460
1458
  }
1461
1459
  if (arrayArgs[2] === "related") {
1462
1460
  options.related = args;
1463
- options.passWithNoTests ?? (options.passWithNoTests = true);
1461
+ options.passWithNoTests ??= true;
1464
1462
  args = [];
1465
1463
  }
1466
1464
  return {
@@ -1470,7 +1468,7 @@ function parseCLI(argv, config = {}) {
1470
1468
  }
1471
1469
  async function runRelated(relatedFiles, argv) {
1472
1470
  argv.related = relatedFiles;
1473
- argv.passWithNoTests ?? (argv.passWithNoTests = true);
1471
+ argv.passWithNoTests ??= true;
1474
1472
  await start("test", [], argv);
1475
1473
  }
1476
1474
  async function watch(cliFilters, options) {
@@ -1498,13 +1496,13 @@ async function start(mode, cliFilters, options) {
1498
1496
  } catch {
1499
1497
  }
1500
1498
  try {
1501
- const { startVitest } = await import('./cli-api.CTkP2Ier.js').then(function (n) { return n.h; });
1499
+ const { startVitest } = await import('./cli-api.B8LE391_.js').then(function (n) { return n.d; });
1502
1500
  const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(options));
1503
- if (!(ctx == null ? void 0 : ctx.shouldKeepServer())) {
1504
- await (ctx == null ? void 0 : ctx.exit());
1501
+ if (!ctx?.shouldKeepServer()) {
1502
+ await ctx?.exit();
1505
1503
  }
1506
1504
  } catch (e) {
1507
- const { divider } = await import('./utils.BySfPUwy.js').then(function (n) { return n.u; });
1505
+ const { divider } = await import('./utils.DO38lwfj.js').then(function (n) { return n.u; });
1508
1506
  console.error(`
1509
1507
  ${c.red(divider(c.bold(c.inverse(" Startup Error "))))}`);
1510
1508
  console.error(e);
@@ -1520,7 +1518,7 @@ async function init(project) {
1520
1518
  console.error(new Error('Only the "browser" project is supported. Use "vitest init browser" to create a new project.'));
1521
1519
  process.exit(1);
1522
1520
  }
1523
- const { create } = await import('../chunks/browser-creator.CyaOd8pl.js');
1521
+ const { create } = await import('./creator.GreKbaUc.js');
1524
1522
  await create();
1525
1523
  }
1526
1524
  async function collect(mode, cliFilters, options) {
@@ -1529,7 +1527,7 @@ async function collect(mode, cliFilters, options) {
1529
1527
  } catch {
1530
1528
  }
1531
1529
  try {
1532
- const { prepareVitest, processCollected } = await import('./cli-api.CTkP2Ier.js').then(function (n) { return n.h; });
1530
+ const { prepareVitest, processCollected } = await import('./cli-api.B8LE391_.js').then(function (n) { return n.d; });
1533
1531
  const ctx = await prepareVitest(mode, {
1534
1532
  ...normalizeCliOptions(options),
1535
1533
  watch: false,
@@ -1546,7 +1544,7 @@ async function collect(mode, cliFilters, options) {
1546
1544
  processCollected(ctx, tests, options);
1547
1545
  await ctx.close();
1548
1546
  } catch (e) {
1549
- const { divider } = await import('./utils.BySfPUwy.js').then(function (n) { return n.u; });
1547
+ const { divider } = await import('./utils.DO38lwfj.js').then(function (n) { return n.u; });
1550
1548
  console.error(`
1551
1549
  ${c.red(divider(c.bold(c.inverse(" Collect Error "))))}`);
1552
1550
  console.error(e);