vitest 1.5.3 → 2.0.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 (74) hide show
  1. package/LICENSE.md +172 -0
  2. package/dist/browser.d.ts +1 -1
  3. package/dist/browser.js +4 -4
  4. package/dist/chunks/environments-node.39w4gmlF.js +19 -0
  5. package/dist/chunks/{install-pkg.LE8oaA1t.js → install-pkg.DNUmWFkO.js} +2 -2
  6. package/dist/chunks/integrations-globals.B5Jl0grA.js +31 -0
  7. package/dist/chunks/{runtime-console.EO5ha7qv.js → runtime-console.CUES-L8X.js} +9 -9
  8. package/dist/chunks/{runtime-runBaseTests.l6qXp5eU.js → runtime-runBaseTests._dXkRAZc.js} +21 -22
  9. package/dist/cli.js +3 -3
  10. package/dist/config.cjs +2 -3
  11. package/dist/config.d.ts +1 -1
  12. package/dist/config.js +2 -3
  13. package/dist/coverage.d.ts +1 -1
  14. package/dist/coverage.js +2 -2
  15. package/dist/environments.d.ts +1 -1
  16. package/dist/environments.js +1 -1
  17. package/dist/execute.d.ts +7 -4
  18. package/dist/execute.js +3 -3
  19. package/dist/index.d.ts +770 -21
  20. package/dist/index.js +12 -12
  21. package/dist/node.d.ts +2 -2
  22. package/dist/node.js +21 -22
  23. package/dist/{reporters-BXNXFKfg.d.ts → reporters-MGvT5U9f.d.ts} +128 -55
  24. package/dist/reporters.d.ts +1 -1
  25. package/dist/reporters.js +11 -12
  26. package/dist/runners.d.ts +1 -1
  27. package/dist/runners.js +17 -18
  28. package/dist/snapshot.d.ts +9 -0
  29. package/dist/snapshot.js +8 -0
  30. package/dist/{suite-KPWE530F.d.ts → suite-8WAe-urM.d.ts} +1 -1
  31. package/dist/suite.d.ts +2 -2
  32. package/dist/suite.js +4 -4
  33. package/dist/vendor/{base.oIzAvGLe.js → base.VFkIJ66g.js} +3 -3
  34. package/dist/vendor/{base.Xt0Omgh7.js → base._gnK9Slw.js} +8 -1
  35. package/dist/vendor/{benchmark.yGkUTKnC.js → benchmark.BNLebNi5.js} +1 -1
  36. package/dist/vendor/{cac.RDd_SGOd.js → cac.DzKZaJu2.js} +39 -17
  37. package/dist/vendor/{cli-api.AmIc1Dmz.js → cli-api.DTeni0Qq.js} +3201 -404
  38. package/dist/vendor/{execute.2_yoIC01.js → execute.CLLNVNnK.js} +8 -3
  39. package/dist/vendor/{index.Fm6OikHU.js → index.BfoZyXD1.js} +20 -21
  40. package/dist/vendor/{index.8bPxjt7g.js → index.BpSiYbpB.js} +5 -1
  41. package/dist/vendor/{index.X7lgIMc_.js → index.CRxYS9H3.js} +586 -230
  42. package/dist/vendor/{index.QVcwRDVW.js → index.CmILuxzC.js} +8 -6
  43. package/dist/vendor/{index.xL8XjTLv.js → index.DP-km6lF.js} +1 -1
  44. package/dist/vendor/{index.SMVOaj7F.js → index._7XLd8Kd.js} +2 -2
  45. package/dist/vendor/{rpc.joBhAkyK.js → rpc.DRDE9Pu1.js} +2 -2
  46. package/dist/vendor/{run-once.Olz_Zkd8.js → run-once.DLomgGUH.js} +1 -1
  47. package/dist/vendor/{setup-common.5nUd4r76.js → setup-common.XeoZAW8t.js} +2 -2
  48. package/dist/vendor/{tasks.IknbGB2n.js → tasks.WC7M-K-v.js} +4 -1
  49. package/dist/vendor/{utils.VYmeMh-u.js → utils.D5gGkwyH.js} +1 -1
  50. package/dist/vendor/{vi.Y_w82WR8.js → vi.ClD3hi7L.js} +23 -10
  51. package/dist/vendor/{vm.i4FO5N37.js → vm.Bi3bljci.js} +132 -54
  52. package/dist/worker.js +13 -7
  53. package/dist/workers/forks.js +6 -6
  54. package/dist/workers/runVmTests.js +22 -20
  55. package/dist/workers/threads.js +6 -6
  56. package/dist/workers/vmForks.js +9 -9
  57. package/dist/workers/vmThreads.js +9 -9
  58. package/dist/workers.d.ts +1 -1
  59. package/dist/workers.js +14 -14
  60. package/package.json +33 -29
  61. package/snapshot.d.ts +1 -0
  62. package/vitest.mjs +1 -1
  63. package/dist/chunks/integrations-globals.Hr6znn-f.js +0 -31
  64. package/dist/cli-wrapper.js +0 -119
  65. /package/dist/chunks/{node-git.Hw101KjS.js → node-git.CCI8evVZ.js} +0 -0
  66. /package/dist/vendor/{_commonjsHelpers.jjO7Zipk.js → _commonjsHelpers.BFTU3MAI.js} +0 -0
  67. /package/dist/vendor/{constants.5J7I254_.js → constants.5SOfHUj0.js} +0 -0
  68. /package/dist/vendor/{coverage.E7sG1b3r.js → coverage.ChSqD-qS.js} +0 -0
  69. /package/dist/vendor/{date.Ns1pGd_X.js → date.BKM1wewY.js} +0 -0
  70. /package/dist/vendor/{env.AtSIuHFg.js → env.bmJgw1qP.js} +0 -0
  71. /package/dist/vendor/{global.CkGT_TMy.js → global.7bFbnyXl.js} +0 -0
  72. /package/dist/vendor/{index.GVFv9dZ0.js → index.DeR1hhfY.js} +0 -0
  73. /package/dist/vendor/{inspector.IgLX3ur5.js → inspector.hPQncR7V.js} +0 -0
  74. /package/dist/vendor/{utils.0uYuCbzo.js → utils.CUjzkRH7.js} +0 -0
package/dist/runners.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { VitestRunner, VitestRunnerImportSource, Suite, Task, CancelReason, Test, Custom, TaskContext, ExtendedContext } from '@vitest/runner';
2
- import { R as ResolvedConfig } from './reporters-BXNXFKfg.js';
2
+ import { R as ResolvedConfig } from './reporters-MGvT5U9f.js';
3
3
  import * as tinybench from 'tinybench';
4
4
  import 'vite';
5
5
  import 'vite-node';
package/dist/runners.js CHANGED
@@ -1,25 +1,25 @@
1
1
  import { setState, GLOBAL_EXPECT, getState } from '@vitest/expect';
2
- import { g as getSnapshotClient, c as createExpect, v as vi } from './vendor/vi.Y_w82WR8.js';
2
+ import { g as getSnapshotClient, c as createExpect, v as vi } from './vendor/vi.ClD3hi7L.js';
3
3
  import 'pathe';
4
- import { g as getFullName } from './vendor/tasks.IknbGB2n.js';
4
+ import { g as getTestName } from './vendor/tasks.WC7M-K-v.js';
5
5
  import { createDefer, getSafeTimers } from '@vitest/utils';
6
- import { g as getWorkerState } from './vendor/global.CkGT_TMy.js';
7
- import './vendor/env.AtSIuHFg.js';
8
- import { r as rpc } from './vendor/rpc.joBhAkyK.js';
6
+ import { g as getWorkerState } from './vendor/global.7bFbnyXl.js';
7
+ import './vendor/env.bmJgw1qP.js';
8
+ import { r as rpc } from './vendor/rpc.DRDE9Pu1.js';
9
9
  import { getTests, getNames } from '@vitest/runner/utils';
10
10
  import { updateTask } from '@vitest/runner';
11
- import { a as getBenchOptions, g as getBenchFn } from './vendor/benchmark.yGkUTKnC.js';
11
+ import { a as getBenchOptions, g as getBenchFn } from './vendor/benchmark.BNLebNi5.js';
12
12
  import 'chai';
13
- import './vendor/_commonjsHelpers.jjO7Zipk.js';
13
+ import './vendor/_commonjsHelpers.BFTU3MAI.js';
14
14
  import '@vitest/snapshot';
15
15
  import '@vitest/utils/error';
16
16
  import '@vitest/utils/source-map';
17
- import './vendor/base.Xt0Omgh7.js';
18
- import './vendor/date.Ns1pGd_X.js';
17
+ import './vendor/base._gnK9Slw.js';
18
+ import './vendor/date.BKM1wewY.js';
19
19
  import '@vitest/spy';
20
20
  import 'std-env';
21
- import './vendor/index.8bPxjt7g.js';
22
- import './vendor/index.SMVOaj7F.js';
21
+ import './vendor/index.BpSiYbpB.js';
22
+ import './vendor/index._7XLd8Kd.js';
23
23
 
24
24
  class VitestTestRunner {
25
25
  constructor(config) {
@@ -43,7 +43,7 @@ class VitestTestRunner {
43
43
  async onAfterRunSuite(suite) {
44
44
  if (this.config.logHeapUsage && typeof process !== "undefined")
45
45
  suite.result.heap = process.memoryUsage().heapUsed;
46
- if (suite.mode !== "skip" && typeof suite.filepath !== "undefined") {
46
+ if (suite.mode !== "skip" && "filepath" in suite) {
47
47
  for (const test of getTests(suite)) {
48
48
  if (test.mode === "skip") {
49
49
  const name = getNames(test).slice(1).join(" > ");
@@ -54,13 +54,13 @@ class VitestTestRunner {
54
54
  if (result)
55
55
  await rpc().snapshotSaved(result);
56
56
  }
57
- this.workerState.current = suite.suite;
57
+ this.workerState.current = suite.suite || suite.file;
58
58
  }
59
59
  onAfterRunTask(test) {
60
60
  this.snapshotClient.clearTest();
61
61
  if (this.config.logHeapUsage && typeof process !== "undefined")
62
62
  test.result.heap = process.memoryUsage().heapUsed;
63
- this.workerState.current = test.suite;
63
+ this.workerState.current = test.suite || test.file;
64
64
  }
65
65
  onCancel(_reason) {
66
66
  this.cancelRun = true;
@@ -76,21 +76,20 @@ class VitestTestRunner {
76
76
  async onBeforeRunSuite(suite) {
77
77
  if (this.cancelRun)
78
78
  suite.mode = "skip";
79
- if (suite.mode !== "skip" && typeof suite.filepath !== "undefined") {
79
+ if (suite.mode !== "skip" && "filepath" in suite) {
80
80
  await this.snapshotClient.startCurrentRun(suite.filepath, "__default_name_", this.workerState.config.snapshotOptions);
81
81
  }
82
82
  this.workerState.current = suite;
83
83
  }
84
84
  onBeforeTryTask(test) {
85
- var _a, _b;
86
85
  setState({
87
86
  assertionCalls: 0,
88
87
  isExpectingAssertions: false,
89
88
  isExpectingAssertionsError: null,
90
89
  expectedAssertionsNumber: null,
91
90
  expectedAssertionsNumberErrorGen: null,
92
- testPath: (_b = (_a = test.suite) == null ? void 0 : _a.file) == null ? void 0 : _b.filepath,
93
- currentTestName: getFullName(test),
91
+ testPath: test.file.filepath,
92
+ currentTestName: getTestName(test),
94
93
  snapshotState: this.snapshotClient.snapshotState
95
94
  }, globalThis[GLOBAL_EXPECT]);
96
95
  }
@@ -0,0 +1,9 @@
1
+ import { NodeSnapshotEnvironment } from '@vitest/snapshot/environment';
2
+ export { SnapshotEnvironment } from '@vitest/snapshot/environment';
3
+
4
+ declare class VitestNodeSnapshotEnvironment extends NodeSnapshotEnvironment {
5
+ getHeader(): string;
6
+ resolvePath(filepath: string): Promise<string>;
7
+ }
8
+
9
+ export { VitestNodeSnapshotEnvironment as VitestSnapshotEnvironment };
@@ -0,0 +1,8 @@
1
+ export { VitestNodeSnapshotEnvironment as VitestSnapshotEnvironment } from './chunks/environments-node.39w4gmlF.js';
2
+ import '@vitest/snapshot/environment';
3
+ import 'pathe';
4
+ import '@vitest/runner/utils';
5
+ import '@vitest/utils';
6
+ import './vendor/global.7bFbnyXl.js';
7
+ import './vendor/env.bmJgw1qP.js';
8
+ import 'std-env';
@@ -1,6 +1,6 @@
1
1
  import { Custom } from '@vitest/runner';
2
2
  import '@vitest/runner/utils';
3
- import { an as BenchFunction, ao as BenchmarkAPI } from './reporters-BXNXFKfg.js';
3
+ import { ap as BenchFunction, aq as BenchmarkAPI } from './reporters-MGvT5U9f.js';
4
4
  import { Options } from 'tinybench';
5
5
 
6
6
  declare function getBenchOptions(key: Custom): Options;
package/dist/suite.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { createTaskCollector, getCurrentSuite, getCurrentTest, getFn, getHooks, setFn, setHooks } from '@vitest/runner';
2
2
  export { createChainable } from '@vitest/runner/utils';
3
- export { g as getBenchFn, a as getBenchOptions } from './suite-KPWE530F.js';
4
- import './reporters-BXNXFKfg.js';
3
+ export { g as getBenchFn, a as getBenchOptions } from './suite-8WAe-urM.js';
4
+ import './reporters-MGvT5U9f.js';
5
5
  import 'vite';
6
6
  import 'vite-node';
7
7
  import '@vitest/snapshot';
package/dist/suite.js CHANGED
@@ -1,9 +1,9 @@
1
1
  export { createTaskCollector, getCurrentSuite, getCurrentTest, getFn, getHooks, setFn, setHooks } from '@vitest/runner';
2
2
  export { createChainable } from '@vitest/runner/utils';
3
- export { g as getBenchFn, a as getBenchOptions } from './vendor/benchmark.yGkUTKnC.js';
3
+ export { g as getBenchFn, a as getBenchOptions } from './vendor/benchmark.BNLebNi5.js';
4
4
  import '@vitest/utils';
5
- import './vendor/index.SMVOaj7F.js';
5
+ import './vendor/index._7XLd8Kd.js';
6
6
  import 'pathe';
7
- import './vendor/global.CkGT_TMy.js';
8
- import './vendor/env.AtSIuHFg.js';
7
+ import './vendor/global.7bFbnyXl.js';
8
+ import './vendor/env.bmJgw1qP.js';
9
9
  import 'std-env';
@@ -1,6 +1,6 @@
1
1
  import { ModuleCacheMap } from 'vite-node/client';
2
- import { p as provideWorkerState } from './global.CkGT_TMy.js';
3
- import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.2_yoIC01.js';
2
+ import { p as provideWorkerState } from './global.7bFbnyXl.js';
3
+ import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.CLLNVNnK.js';
4
4
 
5
5
  let _viteNode;
6
6
  const moduleCache = new ModuleCacheMap();
@@ -25,7 +25,7 @@ async function runBaseTests(state) {
25
25
  ctx.files.forEach((i) => state.moduleCache.delete(i));
26
26
  const [executor, { run }] = await Promise.all([
27
27
  startViteNode({ state, requestStubs: getDefaultRequestStubs() }),
28
- import('../chunks/runtime-runBaseTests.l6qXp5eU.js')
28
+ import('../chunks/runtime-runBaseTests._dXkRAZc.js')
29
29
  ]);
30
30
  await run(
31
31
  ctx.files,
@@ -107,5 +107,12 @@ function escapeRegExp(s) {
107
107
  function wildcardPatternToRegExp(pattern) {
108
108
  return new RegExp(`^${pattern.split("*").map(escapeRegExp).join(".*")}$`, "i");
109
109
  }
110
+ const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
111
+ function nanoid(size = 21) {
112
+ let id = "";
113
+ let i = size;
114
+ while (i--) id += urlAlphabet[Math.random() * 64 | 0];
115
+ return id;
116
+ }
110
117
 
111
- export { AggregateErrorPonyfill as A, slash as a, isPrimitive as b, groupBy as c, deepMerge as d, stdout as e, getAllMockableProperties as g, isChildProcess as i, noop as n, setProcessTitle as s, toArray as t, wildcardPatternToRegExp as w };
118
+ 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 };
@@ -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.SMVOaj7F.js';
4
+ import { i as isRunningInBenchmark } from './index._7XLd8Kd.js';
5
5
 
6
6
  const benchFns = /* @__PURE__ */ new WeakMap();
7
7
  const benchOptsMap = /* @__PURE__ */ new WeakMap();
@@ -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.Xt0Omgh7.js';
5
- import { d as defaultPort, a as defaultBrowserPort } from './constants.5J7I254_.js';
4
+ import { t as toArray } from './base._gnK9Slw.js';
5
+ import { d as defaultPort, a as defaultBrowserPort } from './constants.5SOfHUj0.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 = "1.5.3";
621
+ var version = "2.0.0-beta.1";
622
622
 
623
623
  const apiConfig = (port) => ({
624
624
  port: {
@@ -793,13 +793,13 @@ const cliOptionsConfig = {
793
793
  array: true
794
794
  },
795
795
  reportOnFailure: {
796
- description: "Generate coverage report even when tests fail (default: false)"
796
+ description: "Generate coverage report even when tests fail (default: `false`)"
797
797
  },
798
798
  allowExternal: {
799
- description: "Collect coverage of files outside the project root (default: false)"
799
+ description: "Collect coverage of files outside the project root (default: `false`)"
800
800
  },
801
801
  skipFull: {
802
- description: "Do not show files with 100% statement, branch, and function coverage (default: false)"
802
+ description: "Do not show files with 100% statement, branch, and function coverage (default: `false`)"
803
803
  },
804
804
  thresholds: {
805
805
  description: null,
@@ -944,7 +944,9 @@ const cliOptionsConfig = {
944
944
  },
945
945
  fileParallelism: {
946
946
  description: "Should all test files run in parallel. Use `--browser.file-parallelism=false` to disable (default: same as `--file-parallelism`)"
947
- }
947
+ },
948
+ indexScripts: null,
949
+ testerScripts: null
948
950
  }
949
951
  },
950
952
  pool: {
@@ -1199,6 +1201,9 @@ const cliOptionsConfig = {
1199
1201
  clearScreen: {
1200
1202
  description: "Clear terminal screen when re-running tests during watch mode (default: `true`)"
1201
1203
  },
1204
+ standalone: {
1205
+ description: "Start Vitest without running tests. File filters will be ignored, tests will be running only on change (default: `false`)"
1206
+ },
1202
1207
  // disable CLI options
1203
1208
  cliExclude: null,
1204
1209
  server: null,
@@ -1207,7 +1212,6 @@ const cliOptionsConfig = {
1207
1212
  snapshotFormat: null,
1208
1213
  snapshotSerializers: null,
1209
1214
  includeSource: null,
1210
- watchExclude: null,
1211
1215
  alias: null,
1212
1216
  env: null,
1213
1217
  environmentMatchGlobs: null,
@@ -1230,7 +1234,20 @@ const cliOptionsConfig = {
1230
1234
  poolMatchGlobs: null,
1231
1235
  deps: null,
1232
1236
  name: null,
1233
- includeTaskLocation: null
1237
+ includeTaskLocation: null,
1238
+ snapshotEnvironment: null,
1239
+ compare: null,
1240
+ outputJson: null
1241
+ };
1242
+ const benchCliOptionsConfig = {
1243
+ compare: {
1244
+ description: "benchmark output file to compare against",
1245
+ argument: "<filename>"
1246
+ },
1247
+ outputJson: {
1248
+ description: "benchmark output file",
1249
+ argument: "<filename>"
1250
+ }
1234
1251
  };
1235
1252
 
1236
1253
  function addCommand(cli, name, option) {
@@ -1270,14 +1287,16 @@ function addCommand(cli, name, option) {
1270
1287
  }
1271
1288
  }
1272
1289
  }
1273
- function createCLI(options = {}) {
1274
- const cli = cac("vitest");
1275
- cli.version(version);
1276
- for (const optionName in cliOptionsConfig) {
1277
- const option = cliOptionsConfig[optionName];
1290
+ function addCliOptions(cli, options) {
1291
+ for (const [optionName, option] of Object.entries(options)) {
1278
1292
  if (option)
1279
1293
  addCommand(cli, optionName, option);
1280
1294
  }
1295
+ }
1296
+ function createCLI(options = {}) {
1297
+ const cli = cac("vitest");
1298
+ cli.version(version);
1299
+ addCliOptions(cli, cliOptionsConfig);
1281
1300
  cli.help((info) => {
1282
1301
  const helpSection = info.find((current) => {
1283
1302
  var _a;
@@ -1328,7 +1347,10 @@ function createCLI(options = {}) {
1328
1347
  cli.command("related [...filters]", void 0, options).action(runRelated);
1329
1348
  cli.command("watch [...filters]", void 0, options).action(watch);
1330
1349
  cli.command("dev [...filters]", void 0, options).action(watch);
1331
- cli.command("bench [...filters]", void 0, options).action(benchmark);
1350
+ addCliOptions(
1351
+ cli.command("bench [...filters]", void 0, options).action(benchmark),
1352
+ benchCliOptionsConfig
1353
+ );
1332
1354
  cli.command("typecheck [...filters]").action(() => {
1333
1355
  throw new Error(`Running typecheck via "typecheck" command is removed. Please use "--typecheck" to run your regular tests alongside typechecking, or "--typecheck.only" to run only typecheck tests.`);
1334
1356
  });
@@ -1388,13 +1410,13 @@ async function start(mode, cliFilters, options) {
1388
1410
  } catch {
1389
1411
  }
1390
1412
  try {
1391
- const { startVitest } = await import('./cli-api.AmIc1Dmz.js').then(function (n) { return n.d; });
1413
+ const { startVitest } = await import('./cli-api.DTeni0Qq.js').then(function (n) { return n.d; });
1392
1414
  const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(options));
1393
1415
  if (!(ctx == null ? void 0 : ctx.shouldKeepServer()))
1394
1416
  await (ctx == null ? void 0 : ctx.exit());
1395
1417
  return ctx;
1396
1418
  } catch (e) {
1397
- const { divider } = await import('./utils.VYmeMh-u.js').then(function (n) { return n.u; });
1419
+ const { divider } = await import('./utils.D5gGkwyH.js').then(function (n) { return n.u; });
1398
1420
  console.error(`
1399
1421
  ${c.red(divider(c.bold(c.inverse(" Unhandled Error "))))}`);
1400
1422
  console.error(e);