vitest 2.0.4 → 2.0.5

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 (77) hide show
  1. package/dist/browser.d.ts +21 -42
  2. package/dist/browser.js +5 -5
  3. package/dist/{vendor/base.Csk7BT3h.js → chunks/base.CC5R_kgU.js} +3 -3
  4. package/dist/{vendor/base.DRHPZCCj.js → chunks/base.DSsbfkDg.js} +1 -1
  5. package/dist/{vendor/benchmark.B6pblCp2.js → chunks/benchmark.DDmpNjj-.js} +1 -1
  6. package/dist/chunks/benchmark.puBFxyfE.d.ts +22 -0
  7. package/dist/{vendor/cac.DFtWvZc2.js → chunks/cac.DGgmCKmU.js} +17 -20
  8. package/dist/{vendor/cli-api.CTkP2Ier.js → chunks/cli-api.OKfd3qJ0.js} +416 -423
  9. package/dist/chunks/config.DCnyCTbs.d.ts +203 -0
  10. package/dist/chunks/{runtime-console.C2L2zykk.js → console.Bgn7_A1x.js} +11 -14
  11. package/dist/{vendor/constants.CsnA4eRy.js → chunks/constants.CaAN7icJ.js} +1 -3
  12. package/dist/{vendor/coverage.BhYSDdTT.js → chunks/coverage.CqfT4xaf.js} +4 -7
  13. package/dist/chunks/{browser-creator.CyaOd8pl.js → creator.a3OfuIEW.js} +8 -8
  14. package/dist/{vendor/env.2ltrQNq0.js → chunks/env.BU041cs9.js} +2 -3
  15. package/dist/chunks/environment.0M5R1SX_.d.ts +173 -0
  16. package/dist/{vendor/execute.jzOWtys_.js → chunks/execute.Cjlr2CRw.js} +27 -19
  17. package/dist/chunks/globals.BliuJFNR.js +31 -0
  18. package/dist/{vendor/index.DI9daj1Q.js → chunks/index.BfeNhc0N.js} +43 -43
  19. package/dist/{vendor/index.D6GZqexG.js → chunks/index.CM5UI-4O.js} +2 -2
  20. package/dist/{vendor/index.BJmtb_7W.js → chunks/index.DYufA6CZ.js} +2 -2
  21. package/dist/{vendor/index.CuuL9y4g.js → chunks/index.JbiJutJ_.js} +515 -255
  22. package/dist/{vendor/index.CVqMv71L.js → chunks/index.R1VjssW9.js} +11 -12
  23. package/dist/{vendor/index.D4nqnQWz.js → chunks/index.lVXYBqEP.js} +1 -18
  24. package/dist/{vendor/inspector.-FCQUzqR.js → chunks/inspector.70d6emsh.js} +4 -5
  25. package/dist/chunks/{environments-node.XE5FbRPQ.js → node.DS3zEPa7.js} +2 -2
  26. package/dist/{reporters-B7ebVMkT.d.ts → chunks/reporters.C_zwCd4j.d.ts} +847 -1000
  27. package/dist/{vendor/rpc.BGx7q_k2.js → chunks/rpc.B7Mfb-Yf.js} +3 -5
  28. package/dist/{vendor/run-once.Db8Hgq9X.js → chunks/run-once.Sxe67Wng.js} +1 -1
  29. package/dist/chunks/{runtime-runBaseTests.Dq_sJZq9.js → runBaseTests.CyvqmuC9.js} +21 -23
  30. package/dist/{vendor/setup-common.symvFZPh.js → chunks/setup-common.CNzatKMx.js} +2 -2
  31. package/dist/{suite-CRLAhsm0.d.ts → chunks/suite.CcK46U-P.d.ts} +1 -1
  32. package/dist/{vendor/tasks.DhVtQBtW.js → chunks/tasks.BZnCS9aT.js} +2 -3
  33. package/dist/{vendor/utils.DkxLWvS1.js → chunks/utils.C3_cBsyn.js} +3 -4
  34. package/dist/{vendor/global.7bFbnyXl.js → chunks/utils.Ck2hJTRs.js} +1 -1
  35. package/dist/{vendor/utils.BySfPUwy.js → chunks/utils.DpP_sDwr.js} +8 -21
  36. package/dist/{vendor/vi.Elqer9-7.js → chunks/vi.fiQ7lMRF.js} +13 -18
  37. package/dist/{vendor/vm.img-AOox.js → chunks/vm.DcSuuaHr.js} +40 -68
  38. package/dist/chunks/worker.C5iHKIaJ.d.ts +144 -0
  39. package/dist/chunks/worker.DKkAC4Qw.d.ts +8 -0
  40. package/dist/cli.js +3 -3
  41. package/dist/config.cjs +6 -8
  42. package/dist/config.d.ts +10 -8
  43. package/dist/config.js +6 -8
  44. package/dist/coverage.d.ts +10 -8
  45. package/dist/coverage.js +2 -2
  46. package/dist/environments.d.ts +3 -19
  47. package/dist/environments.js +1 -1
  48. package/dist/execute.d.ts +5 -14
  49. package/dist/execute.js +2 -2
  50. package/dist/index.d.ts +267 -34
  51. package/dist/index.js +12 -12
  52. package/dist/node.d.ts +15 -9
  53. package/dist/node.js +16 -19
  54. package/dist/reporters.d.ts +10 -8
  55. package/dist/reporters.js +12 -15
  56. package/dist/runners.d.ts +7 -19
  57. package/dist/runners.js +12 -13
  58. package/dist/snapshot.js +3 -3
  59. package/dist/suite.d.ts +2 -16
  60. package/dist/suite.js +4 -4
  61. package/dist/worker.js +7 -8
  62. package/dist/workers/forks.js +5 -5
  63. package/dist/workers/runVmTests.js +18 -19
  64. package/dist/workers/threads.js +5 -5
  65. package/dist/workers/vmForks.js +8 -8
  66. package/dist/workers/vmThreads.js +8 -8
  67. package/dist/workers.d.ts +13 -8
  68. package/dist/workers.js +13 -13
  69. package/package.json +13 -13
  70. package/dist/chunks/integrations-globals.nDMtdOcn.js +0 -31
  71. /package/dist/{vendor → chunks}/_commonjsHelpers.BFTU3MAI.js +0 -0
  72. /package/dist/{vendor → chunks}/date.W2xKR2qe.js +0 -0
  73. /package/dist/chunks/{node-git.ZtkbKc8u.js → git.ZtkbKc8u.js} +0 -0
  74. /package/dist/{vendor → chunks}/index.BMmMjLIQ.js +0 -0
  75. /package/dist/{vendor → chunks}/index.BpSiYbpB.js +0 -0
  76. /package/dist/chunks/{install-pkg.DNUmWFkO.js → index.DNUmWFkO.js} +0 -0
  77. /package/dist/{vendor → chunks}/spy.Cf_4R5Oe.js +0 -0
package/dist/browser.d.ts CHANGED
@@ -1,25 +1,28 @@
1
1
  export { collectTests, processError, startTests } from '@vitest/runner';
2
- import { R as ResolvedConfig, C as CoverageOptions, b as CoverageProvider, c as CoverageProviderModule } from './reporters-B7ebVMkT.js';
3
- import { Formatter } from 'tinyrainbow';
2
+ import { DiffOptions } from '@vitest/expect';
4
3
  import { VitestExecutor } from './execute.js';
4
+ import { S as SerializedConfig, a as SerializedCoverageConfig } from './chunks/config.DCnyCTbs.js';
5
+ import { C as CoverageProvider, a as CoverageProviderModule } from './chunks/reporters.C_zwCd4j.js';
5
6
  import * as spy$1 from '@vitest/spy';
6
- import 'vite';
7
- import '@vitest/pretty-format';
7
+ import 'node:vm';
8
+ import 'vite-node/client';
8
9
  import 'vite-node';
10
+ import './chunks/worker.C5iHKIaJ.js';
9
11
  import '@vitest/snapshot';
10
- import '@vitest/expect';
11
- import '@vitest/runner/utils';
12
- import '@vitest/utils';
13
- import 'tinybench';
12
+ import './chunks/environment.0M5R1SX_.js';
13
+ import '@vitest/pretty-format';
14
+ import '@vitest/snapshot/environment';
15
+ import 'vite';
14
16
  import 'node:stream';
15
- import 'vite-node/client';
16
17
  import '@vitest/snapshot/manager';
17
18
  import 'vite-node/server';
18
- import 'node:worker_threads';
19
+ import '@vitest/utils';
19
20
  import '@vitest/utils/source-map';
20
21
  import 'node:fs';
21
22
  import 'chai';
22
- import 'node:vm';
23
+ import './chunks/benchmark.puBFxyfE.js';
24
+ import '@vitest/runner/utils';
25
+ import 'tinybench';
23
26
 
24
27
  function _mergeNamespaces(n, m) {
25
28
  m.forEach(function (e) {
@@ -40,42 +43,18 @@ var spy = /*#__PURE__*/_mergeNamespaces({
40
43
  __proto__: null
41
44
  }, [spy$1]);
42
45
 
43
- interface DiffOptions {
44
- aAnnotation?: string;
45
- aColor?: Formatter;
46
- aIndicator?: string;
47
- bAnnotation?: string;
48
- bColor?: Formatter;
49
- bIndicator?: string;
50
- changeColor?: Formatter;
51
- changeLineTrailingSpaceColor?: Formatter;
52
- commonColor?: Formatter;
53
- commonIndicator?: string;
54
- commonLineTrailingSpaceColor?: Formatter;
55
- contextLines?: number;
56
- emptyFirstOrLastLinePlaceholder?: string;
57
- expand?: boolean;
58
- includeChangeCounts?: boolean;
59
- omitAnnotationLines?: boolean;
60
- patchColor?: Formatter;
61
- compareKeys?: any;
62
- truncateThreshold?: number;
63
- truncateAnnotation?: string;
64
- truncateAnnotationColor?: Formatter;
65
- }
66
-
67
- declare function setupCommonEnv(config: ResolvedConfig): Promise<void>;
68
- declare function loadDiffConfig(config: ResolvedConfig, executor: VitestExecutor): Promise<DiffOptions | undefined>;
69
- declare function loadSnapshotSerializers(config: ResolvedConfig, executor: VitestExecutor): Promise<void>;
46
+ declare function setupCommonEnv(config: SerializedConfig): Promise<void>;
47
+ declare function loadDiffConfig(config: SerializedConfig, executor: VitestExecutor): Promise<DiffOptions | undefined>;
48
+ declare function loadSnapshotSerializers(config: SerializedConfig, executor: VitestExecutor): Promise<void>;
70
49
 
71
50
  interface Loader {
72
51
  executeId: (id: string) => Promise<{
73
52
  default: CoverageProviderModule;
74
53
  }>;
75
54
  }
76
- declare function getCoverageProvider(options: CoverageOptions | undefined, loader: Loader): Promise<CoverageProvider | null>;
77
- declare function startCoverageInsideWorker(options: CoverageOptions | undefined, loader: Loader): Promise<unknown>;
78
- declare function takeCoverageInsideWorker(options: CoverageOptions | undefined, loader: Loader): Promise<unknown>;
79
- declare function stopCoverageInsideWorker(options: CoverageOptions | undefined, loader: Loader): Promise<unknown>;
55
+ declare function getCoverageProvider(options: SerializedCoverageConfig | undefined, loader: Loader): Promise<CoverageProvider | null>;
56
+ declare function startCoverageInsideWorker(options: SerializedCoverageConfig | undefined, loader: Loader): Promise<unknown>;
57
+ declare function takeCoverageInsideWorker(options: SerializedCoverageConfig | undefined, loader: Loader): Promise<unknown>;
58
+ declare function stopCoverageInsideWorker(options: SerializedCoverageConfig | undefined, loader: Loader): Promise<unknown>;
80
59
 
81
60
  export { spy as SpyModule, getCoverageProvider, loadDiffConfig, loadSnapshotSerializers, setupCommonEnv, startCoverageInsideWorker, stopCoverageInsideWorker, takeCoverageInsideWorker };
package/dist/browser.js CHANGED
@@ -1,9 +1,9 @@
1
1
  export { collectTests, processError, startTests } from '@vitest/runner';
2
- export { l as loadDiffConfig, a as loadSnapshotSerializers, s as setupCommonEnv } from './vendor/setup-common.symvFZPh.js';
3
- export { g as getCoverageProvider, a as startCoverageInsideWorker, s as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './vendor/coverage.BhYSDdTT.js';
4
- export { s as SpyModule } from './vendor/spy.Cf_4R5Oe.js';
2
+ export { l as loadDiffConfig, a as loadSnapshotSerializers, s as setupCommonEnv } from './chunks/setup-common.CNzatKMx.js';
3
+ export { g as getCoverageProvider, a as startCoverageInsideWorker, s as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/coverage.CqfT4xaf.js';
4
+ export { s as SpyModule } from './chunks/spy.Cf_4R5Oe.js';
5
5
  import '@vitest/utils';
6
6
  import '@vitest/snapshot';
7
- import './vendor/run-once.Db8Hgq9X.js';
8
- import './vendor/global.7bFbnyXl.js';
7
+ import './chunks/run-once.Sxe67Wng.js';
8
+ import './chunks/utils.Ck2hJTRs.js';
9
9
  import '@vitest/spy';
@@ -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.Cjlr2CRw.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.CyvqmuC9.js')
30
30
  ]);
31
31
  await run(
32
32
  method,
@@ -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
  }, {});
@@ -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.DYufA6CZ.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.DSsbfkDg.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.0.5";
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: {
@@ -1062,7 +1062,7 @@ const cliOptionsConfig = {
1062
1062
  description: "Make tests run in parallel (default: `false`)"
1063
1063
  },
1064
1064
  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',
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
1066
  argument: "<seed>"
1067
1067
  },
1068
1068
  hooks: {
@@ -1377,10 +1377,7 @@ function createCLI(options = {}) {
1377
1377
  cli.version(version);
1378
1378
  addCliOptions(cli, cliOptionsConfig);
1379
1379
  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
- });
1380
+ const helpSection = info.find((current) => current.title?.startsWith("For more info, run any command"));
1384
1381
  if (helpSection) {
1385
1382
  helpSection.body += "\n $ vitest --help --expand-help";
1386
1383
  }
@@ -1401,8 +1398,8 @@ function createCLI(options = {}) {
1401
1398
  const subcommandMarker = "$SUB_COMMAND_MARKER$";
1402
1399
  const banner = info.find((current) => /^vitest\/\d+\.\d+\.\d+$/.test(current.body));
1403
1400
  function addBannerWarning(warning) {
1404
- if (typeof (banner == null ? void 0 : banner.body) === "string") {
1405
- if (banner == null ? void 0 : banner.body.includes(warning)) {
1401
+ if (typeof banner?.body === "string") {
1402
+ if (banner?.body.includes(warning)) {
1406
1403
  return;
1407
1404
  }
1408
1405
  banner.body = `${banner.body}
@@ -1460,7 +1457,7 @@ function parseCLI(argv, config = {}) {
1460
1457
  }
1461
1458
  if (arrayArgs[2] === "related") {
1462
1459
  options.related = args;
1463
- options.passWithNoTests ?? (options.passWithNoTests = true);
1460
+ options.passWithNoTests ??= true;
1464
1461
  args = [];
1465
1462
  }
1466
1463
  return {
@@ -1470,7 +1467,7 @@ function parseCLI(argv, config = {}) {
1470
1467
  }
1471
1468
  async function runRelated(relatedFiles, argv) {
1472
1469
  argv.related = relatedFiles;
1473
- argv.passWithNoTests ?? (argv.passWithNoTests = true);
1470
+ argv.passWithNoTests ??= true;
1474
1471
  await start("test", [], argv);
1475
1472
  }
1476
1473
  async function watch(cliFilters, options) {
@@ -1498,13 +1495,13 @@ async function start(mode, cliFilters, options) {
1498
1495
  } catch {
1499
1496
  }
1500
1497
  try {
1501
- const { startVitest } = await import('./cli-api.CTkP2Ier.js').then(function (n) { return n.h; });
1498
+ const { startVitest } = await import('./cli-api.OKfd3qJ0.js').then(function (n) { return n.h; });
1502
1499
  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());
1500
+ if (!ctx?.shouldKeepServer()) {
1501
+ await ctx?.exit();
1505
1502
  }
1506
1503
  } catch (e) {
1507
- const { divider } = await import('./utils.BySfPUwy.js').then(function (n) { return n.u; });
1504
+ const { divider } = await import('./utils.DpP_sDwr.js').then(function (n) { return n.u; });
1508
1505
  console.error(`
1509
1506
  ${c.red(divider(c.bold(c.inverse(" Startup Error "))))}`);
1510
1507
  console.error(e);
@@ -1520,7 +1517,7 @@ async function init(project) {
1520
1517
  console.error(new Error('Only the "browser" project is supported. Use "vitest init browser" to create a new project.'));
1521
1518
  process.exit(1);
1522
1519
  }
1523
- const { create } = await import('../chunks/browser-creator.CyaOd8pl.js');
1520
+ const { create } = await import('./creator.a3OfuIEW.js');
1524
1521
  await create();
1525
1522
  }
1526
1523
  async function collect(mode, cliFilters, options) {
@@ -1529,7 +1526,7 @@ async function collect(mode, cliFilters, options) {
1529
1526
  } catch {
1530
1527
  }
1531
1528
  try {
1532
- const { prepareVitest, processCollected } = await import('./cli-api.CTkP2Ier.js').then(function (n) { return n.h; });
1529
+ const { prepareVitest, processCollected } = await import('./cli-api.OKfd3qJ0.js').then(function (n) { return n.h; });
1533
1530
  const ctx = await prepareVitest(mode, {
1534
1531
  ...normalizeCliOptions(options),
1535
1532
  watch: false,
@@ -1546,7 +1543,7 @@ async function collect(mode, cliFilters, options) {
1546
1543
  processCollected(ctx, tests, options);
1547
1544
  await ctx.close();
1548
1545
  } catch (e) {
1549
- const { divider } = await import('./utils.BySfPUwy.js').then(function (n) { return n.u; });
1546
+ const { divider } = await import('./utils.DpP_sDwr.js').then(function (n) { return n.u; });
1550
1547
  console.error(`
1551
1548
  ${c.red(divider(c.bold(c.inverse(" Collect Error "))))}`);
1552
1549
  console.error(e);