vitest 2.0.0-beta.2 → 2.0.0-beta.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 (46) hide show
  1. package/dist/browser.d.ts +5 -1
  2. package/dist/browser.js +18 -2
  3. package/dist/chunks/{integrations-globals.B5Jl0grA.js → integrations-globals.BK0Cn4q1.js} +3 -4
  4. package/dist/chunks/{runtime-console.CUES-L8X.js → runtime-console.DiVMr5d4.js} +54 -24
  5. package/dist/chunks/{runtime-runBaseTests._dXkRAZc.js → runtime-runBaseTests.C-Bkopka.js} +5 -6
  6. package/dist/cli.js +2 -2
  7. package/dist/config.cjs +2 -2
  8. package/dist/config.d.ts +2 -2
  9. package/dist/config.js +2 -2
  10. package/dist/coverage.d.ts +1 -1
  11. package/dist/environments.d.ts +1 -1
  12. package/dist/execute.d.ts +2 -2
  13. package/dist/execute.js +1 -1
  14. package/dist/index-C7JhjWOq.d.ts +1565 -0
  15. package/dist/index.d.ts +6 -1445
  16. package/dist/index.js +3 -4
  17. package/dist/node.d.ts +3 -6
  18. package/dist/node.js +7 -7
  19. package/dist/{reporters-DFgqsvtL.d.ts → reporters-qky6mwBH.d.ts} +398 -195
  20. package/dist/reporters.d.ts +1 -1
  21. package/dist/reporters.js +4 -4
  22. package/dist/runners.d.ts +4 -2
  23. package/dist/runners.js +9 -1
  24. package/dist/{suite-C_sqQjdz.d.ts → suite-B5_jYIf8.d.ts} +1 -1
  25. package/dist/suite.d.ts +2 -2
  26. package/dist/vendor/{base.VFkIJ66g.js → base.D4XK-wRp.js} +2 -2
  27. package/dist/vendor/{cac.CtP0aXu-.js → cac.sXjWMctD.js} +58 -20
  28. package/dist/vendor/{cli-api.B2QW76dQ.js → cli-api.BH9TJcYU.js} +487 -357
  29. package/dist/vendor/{constants.5SOfHUj0.js → constants.TCjCaw2D.js} +4 -3
  30. package/dist/vendor/{execute.CLLNVNnK.js → execute.BHj6OMh4.js} +3 -3
  31. package/dist/vendor/{index.CRxYS9H3.js → index.CyGfDRbW.js} +266 -49
  32. package/dist/vendor/{index.BfoZyXD1.js → index.DHRpy7zp.js} +1 -1
  33. package/dist/vendor/{index.CmILuxzC.js → index.DwR86H5i.js} +26 -3
  34. package/dist/vendor/{setup-common.XeoZAW8t.js → setup-common.BhJvzjns.js} +2 -2
  35. package/dist/vendor/{utils.D5gGkwyH.js → utils.YuQ3LT2a.js} +1 -1
  36. package/dist/vendor/{vi.ClD3hi7L.js → vi.C6AfDXK6.js} +97 -46
  37. package/dist/vendor/{vm.Bi3bljci.js → vm.Ow-X2mkS.js} +2 -2
  38. package/dist/workers/forks.js +2 -2
  39. package/dist/workers/runVmTests.js +4 -5
  40. package/dist/workers/threads.js +2 -2
  41. package/dist/workers/vmForks.js +3 -3
  42. package/dist/workers/vmThreads.js +3 -3
  43. package/dist/workers.d.ts +1 -1
  44. package/dist/workers.js +4 -4
  45. package/package.json +10 -10
  46. package/dist/vendor/run-once.DLomgGUH.js +0 -27
@@ -1,4 +1,4 @@
1
- export { aS as BaseReporter, aJ as BasicReporter, a_ as BenchmarkBuiltinReporters, aZ as BenchmarkReportsMap, aV as BuiltinReporterOptions, aU as BuiltinReporters, aI as DefaultReporter, aK as DotReporter, aR as GithubActionsReporter, aQ as HangingProcessReporter, aO as JUnitReporter, aW as JsonAssertionResult, aL as JsonReporter, aX as JsonTestResult, aY as JsonTestResults, v as Reporter, aT as ReportersMap, aP as TapFlatReporter, aN as TapReporter, aM as VerboseReporter } from './reporters-DFgqsvtL.js';
1
+ export { b2 as BaseReporter, aV as BasicReporter, ba as BenchmarkBuiltinReporters, b9 as BenchmarkReportsMap, b5 as BuiltinReporterOptions, b4 as BuiltinReporters, aU as DefaultReporter, aW as DotReporter, b1 as GithubActionsReporter, b0 as HangingProcessReporter, a_ as JUnitReporter, b6 as JsonAssertionResult, aX as JsonReporter, b7 as JsonTestResult, b8 as JsonTestResults, ai as Reporter, b3 as ReportersMap, a$ as TapFlatReporter, aZ as TapReporter, aY as VerboseReporter } from './reporters-qky6mwBH.js';
2
2
  import 'vite';
3
3
  import '@vitest/runner';
4
4
  import 'vite-node';
package/dist/reporters.js CHANGED
@@ -1,4 +1,4 @@
1
- export { a as BasicReporter, e as BenchmarkReportsMap, D as DefaultReporter, b as DotReporter, G as GithubActionsReporter, H as HangingProcessReporter, c as JUnitReporter, J as JsonReporter, R as ReportersMap, d as TapFlatReporter, T as TapReporter, V as VerboseReporter } from './vendor/index.CRxYS9H3.js';
1
+ export { a as BasicReporter, e as BenchmarkReportsMap, D as DefaultReporter, b as DotReporter, G as GithubActionsReporter, H as HangingProcessReporter, c as JUnitReporter, J as JsonReporter, R as ReportersMap, d as TapFlatReporter, T as TapReporter, V as VerboseReporter } from './vendor/index.CyGfDRbW.js';
2
2
  import 'node:fs';
3
3
  import 'picocolors';
4
4
  import 'pathe';
@@ -7,17 +7,17 @@ import '@vitest/runner/utils';
7
7
  import '@vitest/utils';
8
8
  import './vendor/env.bmJgw1qP.js';
9
9
  import 'std-env';
10
- import './vendor/utils.D5gGkwyH.js';
10
+ import './vendor/utils.YuQ3LT2a.js';
11
11
  import './vendor/base._gnK9Slw.js';
12
12
  import 'node:perf_hooks';
13
+ import '@vitest/utils/source-map';
13
14
  import './vendor/index._7XLd8Kd.js';
14
15
  import './vendor/global.7bFbnyXl.js';
15
- import './chunks/runtime-console.CUES-L8X.js';
16
+ import './chunks/runtime-console.DiVMr5d4.js';
16
17
  import 'node:stream';
17
18
  import 'node:console';
18
19
  import 'node:path';
19
20
  import './vendor/date.BKM1wewY.js';
20
- import '@vitest/utils/source-map';
21
21
  import 'node:os';
22
22
  import 'node:fs/promises';
23
23
  import 'execa';
package/dist/runners.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { VitestRunner, VitestRunnerImportSource, Suite, Task, CancelReason, Test, Custom, TaskContext, ExtendedContext } from '@vitest/runner';
2
- import { R as ResolvedConfig } from './reporters-DFgqsvtL.js';
1
+ import { VitestRunner, VitestRunnerImportSource, File, Suite, Task, CancelReason, Test, Custom, TaskContext, ExtendedContext } from '@vitest/runner';
2
+ import { R as ResolvedConfig } from './reporters-qky6mwBH.js';
3
3
  import * as tinybench from 'tinybench';
4
4
  import 'vite';
5
5
  import 'vite-node';
@@ -21,8 +21,10 @@ declare class VitestTestRunner implements VitestRunner {
21
21
  private workerState;
22
22
  private __vitest_executor;
23
23
  private cancelRun;
24
+ private assertionsErrors;
24
25
  constructor(config: ResolvedConfig);
25
26
  importFile(filepath: string, source: VitestRunnerImportSource): unknown;
27
+ onCollectStart(file: File): void;
26
28
  onBeforeRunFiles(): void;
27
29
  onAfterRunFiles(): void;
28
30
  onAfterRunSuite(suite: Suite): Promise<void>;
package/dist/runners.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { setState, GLOBAL_EXPECT, getState } from '@vitest/expect';
2
- import { g as getSnapshotClient, c as createExpect, v as vi } from './vendor/vi.ClD3hi7L.js';
2
+ import { g as getSnapshotClient, c as createExpect, v as vi } from './vendor/vi.C6AfDXK6.js';
3
3
  import 'pathe';
4
4
  import { g as getTestName } from './vendor/tasks.WC7M-K-v.js';
5
5
  import { createDefer, getSafeTimers } from '@vitest/utils';
@@ -29,11 +29,15 @@ class VitestTestRunner {
29
29
  workerState = getWorkerState();
30
30
  __vitest_executor;
31
31
  cancelRun = false;
32
+ assertionsErrors = /* @__PURE__ */ new WeakMap();
32
33
  importFile(filepath, source) {
33
34
  if (source === "setup")
34
35
  this.workerState.moduleCache.delete(filepath);
35
36
  return this.__vitest_executor.executeId(filepath);
36
37
  }
38
+ onCollectStart(file) {
39
+ this.workerState.current = file;
40
+ }
37
41
  onBeforeRunFiles() {
38
42
  this.snapshotClient.clear();
39
43
  }
@@ -106,8 +110,12 @@ class VitestTestRunner {
106
110
  throw expectedAssertionsNumberErrorGen();
107
111
  if (isExpectingAssertions === true && assertionCalls === 0)
108
112
  throw isExpectingAssertionsError;
113
+ if (this.config.expect.requireAssertions && assertionCalls === 0)
114
+ throw this.assertionsErrors.get(test);
109
115
  }
110
116
  extendTaskContext(context) {
117
+ if (this.config.expect.requireAssertions)
118
+ this.assertionsErrors.set(context.task, new Error("expected any number of assertion, but got none"));
111
119
  let _expect;
112
120
  Object.defineProperty(context, "expect", {
113
121
  get() {
@@ -1,6 +1,6 @@
1
1
  import { Custom } from '@vitest/runner';
2
2
  import '@vitest/runner/utils';
3
- import { ap as BenchFunction, aq as BenchmarkAPI } from './reporters-DFgqsvtL.js';
3
+ import { z as BenchFunction, G as BenchmarkAPI } from './reporters-qky6mwBH.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-C_sqQjdz.js';
4
- import './reporters-DFgqsvtL.js';
3
+ export { g as getBenchFn, a as getBenchOptions } from './suite-B5_jYIf8.js';
4
+ import './reporters-qky6mwBH.js';
5
5
  import 'vite';
6
6
  import 'vite-node';
7
7
  import '@vitest/snapshot';
@@ -1,6 +1,6 @@
1
1
  import { ModuleCacheMap } from 'vite-node/client';
2
2
  import { p as provideWorkerState } from './global.7bFbnyXl.js';
3
- import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.CLLNVNnK.js';
3
+ import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.BHj6OMh4.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._dXkRAZc.js')
28
+ import('../chunks/runtime-runBaseTests.C-Bkopka.js')
29
29
  ]);
30
30
  await run(
31
31
  ctx.files,
@@ -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._gnK9Slw.js';
5
- import { d as defaultPort, a as defaultBrowserPort } from './constants.5SOfHUj0.js';
5
+ import { d as defaultPort, a as defaultBrowserPort } from './constants.TCjCaw2D.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.2";
621
+ var version = "2.0.0-beta.5";
622
622
 
623
623
  const apiConfig = (port) => ({
624
624
  port: {
@@ -936,17 +936,16 @@ const cliOptionsConfig = {
936
936
  subcommands: null
937
937
  // don't support custom objects
938
938
  },
939
- slowHijackESM: {
940
- description: "Let Vitest use its own module resolution on the browser to enable APIs such as vi.mock and vi.spyOn. Visit [`browser.slowHijackESM`](https://vitest.dev/config/#browser-slowhijackesm) for more information (default: `false`)"
941
- },
942
939
  isolate: {
943
940
  description: "Run every browser test file in isolation. To disable isolation, use `--browser.isolate=false` (default: `true`)"
944
941
  },
945
- fileParallelism: {
946
- description: "Should all test files run in parallel. Use `--browser.file-parallelism=false` to disable (default: same as `--file-parallelism`)"
942
+ ui: {
943
+ description: "Show Vitest UI when running tests (default: `!process.env.CI`)"
947
944
  },
948
945
  indexScripts: null,
949
- testerScripts: null
946
+ testerScripts: null,
947
+ commands: null,
948
+ viewport: null
950
949
  }
951
950
  },
952
951
  pool: {
@@ -1111,7 +1110,8 @@ const cliOptionsConfig = {
1111
1110
  },
1112
1111
  exclude: {
1113
1112
  description: "Additional file globs to be excluded from test",
1114
- argument: "<glob>"
1113
+ argument: "<glob>",
1114
+ array: true
1115
1115
  },
1116
1116
  expandSnapshotDiff: {
1117
1117
  description: "Show full diff when snapshot fails"
@@ -1185,15 +1185,47 @@ const cliOptionsConfig = {
1185
1185
  description: "Maximum number of concurrent tests in a suite (default: `5`)",
1186
1186
  argument: "<number>"
1187
1187
  },
1188
+ expect: {
1189
+ description: "Configuration options for `expect()` matches",
1190
+ argument: "",
1191
+ // no displayed
1192
+ subcommands: {
1193
+ requireAssertions: {
1194
+ description: "Require that all tests have at least one assertion"
1195
+ },
1196
+ poll: {
1197
+ description: "Default options for `expect.poll()`",
1198
+ argument: "",
1199
+ subcommands: {
1200
+ interval: {
1201
+ description: "Poll interval in milliseconds for `expect.poll()` assertions (default: `50`)",
1202
+ argument: "<interval>"
1203
+ },
1204
+ timeout: {
1205
+ description: "Poll timeout in milliseconds for `expect.poll()` assertions (default: `1000`)",
1206
+ argument: "<timeout>"
1207
+ }
1208
+ },
1209
+ transform(value) {
1210
+ if (typeof value !== "object")
1211
+ throw new Error(`Unexpected value for --expect.poll: ${value}. If you need to configure timeout, use --expect.poll.timeout=<timeout>`);
1212
+ return value;
1213
+ }
1214
+ }
1215
+ },
1216
+ transform(value) {
1217
+ if (typeof value !== "object")
1218
+ throw new Error(`Unexpected value for --expect: ${value}. If you need to configure expect options, use --expect.{name}=<value> syntax`);
1219
+ return value;
1220
+ }
1221
+ },
1222
+ printConsoleTrace: {
1223
+ description: "Always print console stack traces"
1224
+ },
1188
1225
  // CLI only options
1189
1226
  run: {
1190
1227
  description: "Disable watch mode"
1191
1228
  },
1192
- segfaultRetry: {
1193
- description: "Retry the test suite if it crashes due to a segfault (default: `true`)",
1194
- argument: "<times>",
1195
- default: 0
1196
- },
1197
1229
  color: {
1198
1230
  description: "Removes colors from the console output",
1199
1231
  alias: "no-color"
@@ -1204,6 +1236,15 @@ const cliOptionsConfig = {
1204
1236
  standalone: {
1205
1237
  description: "Start Vitest without running tests. File filters will be ignored, tests will be running only on change (default: `false`)"
1206
1238
  },
1239
+ mergeReports: {
1240
+ description: "Paths to blob reports directory. If this options is used, Vitest won't run any tests, it will only report previously recorded tests",
1241
+ argument: "[path]",
1242
+ transform(value) {
1243
+ if (!value || typeof value === "boolean")
1244
+ return ".vitest-reports";
1245
+ return value;
1246
+ }
1247
+ },
1207
1248
  // disable CLI options
1208
1249
  cliExclude: null,
1209
1250
  server: null,
@@ -1317,7 +1358,7 @@ function createCLI(options = {}) {
1317
1358
  if (subcommands.length === 1 && (subcommands[0] === "--expand-help" || subcommands[0] === "--expandHelp"))
1318
1359
  return info;
1319
1360
  const subcommandMarker = "$SUB_COMMAND_MARKER$";
1320
- const banner = info.find((current) => /^vitest\/[0-9]+\.[0-9]+\.[0-9]+$/.test(current.body));
1361
+ const banner = info.find((current) => /^vitest\/\d+\.\d+\.\d+$/.test(current.body));
1321
1362
  function addBannerWarning(warning) {
1322
1363
  if (typeof (banner == null ? void 0 : banner.body) === "string") {
1323
1364
  if (banner == null ? void 0 : banner.body.includes(warning))
@@ -1351,9 +1392,6 @@ function createCLI(options = {}) {
1351
1392
  cli.command("bench [...filters]", void 0, options).action(benchmark),
1352
1393
  benchCliOptionsConfig
1353
1394
  );
1354
- cli.command("typecheck [...filters]").action(() => {
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.`);
1356
- });
1357
1395
  cli.command("[...filters]", void 0, options).action((filters, options2) => start("test", filters, options2));
1358
1396
  return cli;
1359
1397
  }
@@ -1410,13 +1448,13 @@ async function start(mode, cliFilters, options) {
1410
1448
  } catch {
1411
1449
  }
1412
1450
  try {
1413
- const { startVitest } = await import('./cli-api.B2QW76dQ.js').then(function (n) { return n.d; });
1451
+ const { startVitest } = await import('./cli-api.BH9TJcYU.js').then(function (n) { return n.d; });
1414
1452
  const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(options));
1415
1453
  if (!(ctx == null ? void 0 : ctx.shouldKeepServer()))
1416
1454
  await (ctx == null ? void 0 : ctx.exit());
1417
1455
  return ctx;
1418
1456
  } catch (e) {
1419
- const { divider } = await import('./utils.D5gGkwyH.js').then(function (n) { return n.u; });
1457
+ const { divider } = await import('./utils.YuQ3LT2a.js').then(function (n) { return n.u; });
1420
1458
  console.error(`
1421
1459
  ${c.red(divider(c.bold(c.inverse(" Unhandled Error "))))}`);
1422
1460
  console.error(e);