vitest 2.0.0-beta.1 → 2.0.0-beta.10

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 (52) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/browser.d.ts +22 -2
  3. package/dist/browser.js +3 -1
  4. package/dist/chunks/{integrations-globals.B5Jl0grA.js → integrations-globals.C6Ah-pUW.js} +3 -3
  5. package/dist/chunks/{runtime-console.CUES-L8X.js → runtime-console.DiVMr5d4.js} +54 -24
  6. package/dist/chunks/{runtime-runBaseTests._dXkRAZc.js → runtime-runBaseTests.Cukyr5-I.js} +5 -5
  7. package/dist/cli.js +2 -2
  8. package/dist/config.cjs +3 -3
  9. package/dist/config.d.ts +2 -2
  10. package/dist/config.js +3 -3
  11. package/dist/coverage.d.ts +1 -1
  12. package/dist/coverage.js +33 -7
  13. package/dist/environments.d.ts +1 -1
  14. package/dist/environments.js +1 -1
  15. package/dist/execute.d.ts +2 -2
  16. package/dist/execute.js +1 -1
  17. package/dist/index.d.ts +11 -47
  18. package/dist/index.js +3 -3
  19. package/dist/node.d.ts +7 -7
  20. package/dist/node.js +12 -10
  21. package/dist/{reporters-MGvT5U9f.d.ts → reporters-CYVC6LOl.d.ts} +424 -201
  22. package/dist/reporters.d.ts +1 -1
  23. package/dist/reporters.js +4 -4
  24. package/dist/runners.d.ts +4 -2
  25. package/dist/runners.js +9 -1
  26. package/dist/{suite-8WAe-urM.d.ts → suite-Dpu9EC_k.d.ts} +1 -1
  27. package/dist/suite.d.ts +2 -2
  28. package/dist/vendor/{base.VFkIJ66g.js → base.Dln9yllP.js} +2 -2
  29. package/dist/vendor/{cac.DzKZaJu2.js → cac.CtYFkoSJ.js} +65 -23
  30. package/dist/vendor/{cli-api.DTeni0Qq.js → cli-api.CUtJc4r3.js} +2425 -549
  31. package/dist/vendor/{constants.5SOfHUj0.js → constants.TCjCaw2D.js} +4 -3
  32. package/dist/vendor/{execute.CLLNVNnK.js → execute.BHj6OMh4.js} +3 -3
  33. package/dist/vendor/{index.BfoZyXD1.js → index.B5SKBLvV.js} +1 -1
  34. package/dist/vendor/{index.CRxYS9H3.js → index.BOMEjpjj.js} +271 -52
  35. package/dist/vendor/{index.DP-km6lF.js → index.CThipSqB.js} +2537 -2524
  36. package/dist/vendor/{index.CmILuxzC.js → index.D3hs2WiI.js} +1 -1
  37. package/dist/vendor/{index.DeR1hhfY.js → index.kpsSqFiz.js} +2 -1
  38. package/dist/vendor/{setup-common.XeoZAW8t.js → setup-common.DAu7t7mY.js} +1 -1
  39. package/dist/vendor/spy.Cf_4R5Oe.js +22 -0
  40. package/dist/vendor/{utils.D5gGkwyH.js → utils.YuQ3LT2a.js} +1 -1
  41. package/dist/vendor/{vi.ClD3hi7L.js → vi.hATFzZbX.js} +101 -46
  42. package/dist/vendor/{vm.Bi3bljci.js → vm.Ow-X2mkS.js} +2 -2
  43. package/dist/worker.js +1 -1
  44. package/dist/workers/forks.js +2 -2
  45. package/dist/workers/runVmTests.js +4 -4
  46. package/dist/workers/threads.js +2 -2
  47. package/dist/workers/vmForks.js +3 -3
  48. package/dist/workers/vmThreads.js +3 -3
  49. package/dist/workers.d.ts +1 -1
  50. package/dist/workers.js +5 -5
  51. package/package.json +20 -20
  52. package/suppress-warnings.cjs +2 -1
@@ -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-MGvT5U9f.js';
1
+ export { b4 as BaseReporter, aX as BasicReporter, bc as BenchmarkBuiltinReporters, bb as BenchmarkReportsMap, b7 as BuiltinReporterOptions, b6 as BuiltinReporters, aW as DefaultReporter, aY as DotReporter, b3 as GithubActionsReporter, b2 as HangingProcessReporter, b0 as JUnitReporter, b8 as JsonAssertionResult, aZ as JsonReporter, b9 as JsonTestResult, ba as JsonTestResults, N as Reporter, b5 as ReportersMap, b1 as TapFlatReporter, a$ as TapReporter, a_ as VerboseReporter } from './reporters-CYVC6LOl.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.BOMEjpjj.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-MGvT5U9f.js';
1
+ import { VitestRunner, VitestRunnerImportSource, File, Suite, Task, CancelReason, Test, Custom, TaskContext, ExtendedContext } from '@vitest/runner';
2
+ import { R as ResolvedConfig } from './reporters-CYVC6LOl.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.hATFzZbX.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-MGvT5U9f.js';
3
+ import { ag as BenchFunction, ah as BenchmarkAPI } from './reporters-CYVC6LOl.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-8WAe-urM.js';
4
- import './reporters-MGvT5U9f.js';
3
+ export { g as getBenchFn, a as getBenchOptions } from './suite-Dpu9EC_k.js';
4
+ import './reporters-CYVC6LOl.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.Cukyr5-I.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.1";
621
+ var version = "2.0.0-beta.10";
622
622
 
623
623
  const apiConfig = (port) => ({
624
624
  port: {
@@ -925,7 +925,7 @@ const cliOptionsConfig = {
925
925
  subcommands: apiConfig(defaultBrowserPort)
926
926
  },
927
927
  provider: {
928
- description: 'Provider used to run browser tests. Some browsers are only available for specific providers. Can be "webdriverio", "playwright", or the path to a custom provider. Visit [`browser.provider`](https://vitest.dev/config/#browser-provider) for more information (default: `"webdriverio"`)',
928
+ description: 'Provider used to run browser tests. Some browsers are only available for specific providers. Can be "webdriverio", "playwright", "preview", or the path to a custom provider. Visit [`browser.provider`](https://vitest.dev/config/#browser-provider) for more information (default: `"preview"`)',
929
929
  argument: "<name>",
930
930
  subcommands: null
931
931
  // don't support custom objects
@@ -936,17 +936,20 @@ 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
  },
942
+ ui: {
943
+ description: "Show Vitest UI when running tests (default: `!process.env.CI`)"
944
+ },
945
945
  fileParallelism: {
946
- description: "Should all test files run in parallel. Use `--browser.file-parallelism=false` to disable (default: same as `--file-parallelism`)"
946
+ description: "Should browser test files run in parallel. Use `--browser.fileParallelism=false` to disable (default: `true`)"
947
947
  },
948
- indexScripts: null,
949
- testerScripts: null
948
+ orchestratorScripts: null,
949
+ testerScripts: null,
950
+ commands: null,
951
+ viewport: null,
952
+ screenshotDirectory: null
950
953
  }
951
954
  },
952
955
  pool: {
@@ -1044,7 +1047,7 @@ const cliOptionsConfig = {
1044
1047
  description: "Run files in a random order. Long running tests will not start earlier if you enable this option. (default: `false`)"
1045
1048
  },
1046
1049
  tests: {
1047
- description: "Run tests in a random oder (default: `false`)"
1050
+ description: "Run tests in a random order (default: `false`)"
1048
1051
  }
1049
1052
  }
1050
1053
  },
@@ -1111,7 +1114,8 @@ const cliOptionsConfig = {
1111
1114
  },
1112
1115
  exclude: {
1113
1116
  description: "Additional file globs to be excluded from test",
1114
- argument: "<glob>"
1117
+ argument: "<glob>",
1118
+ array: true
1115
1119
  },
1116
1120
  expandSnapshotDiff: {
1117
1121
  description: "Show full diff when snapshot fails"
@@ -1132,7 +1136,7 @@ const cliOptionsConfig = {
1132
1136
  description: "Run only typecheck tests. This automatically enables typecheck (default: `false`)"
1133
1137
  },
1134
1138
  checker: {
1135
- description: 'Specify the typechecker to use. Available values are: "tcs" and "vue-tsc" and a path to an executable (default: `"tsc"`)',
1139
+ description: 'Specify the typechecker to use. Available values are: "tsc" and "vue-tsc" and a path to an executable (default: `"tsc"`)',
1136
1140
  argument: "<name>",
1137
1141
  subcommands: null
1138
1142
  },
@@ -1185,15 +1189,47 @@ const cliOptionsConfig = {
1185
1189
  description: "Maximum number of concurrent tests in a suite (default: `5`)",
1186
1190
  argument: "<number>"
1187
1191
  },
1192
+ expect: {
1193
+ description: "Configuration options for `expect()` matches",
1194
+ argument: "",
1195
+ // no displayed
1196
+ subcommands: {
1197
+ requireAssertions: {
1198
+ description: "Require that all tests have at least one assertion"
1199
+ },
1200
+ poll: {
1201
+ description: "Default options for `expect.poll()`",
1202
+ argument: "",
1203
+ subcommands: {
1204
+ interval: {
1205
+ description: "Poll interval in milliseconds for `expect.poll()` assertions (default: `50`)",
1206
+ argument: "<interval>"
1207
+ },
1208
+ timeout: {
1209
+ description: "Poll timeout in milliseconds for `expect.poll()` assertions (default: `1000`)",
1210
+ argument: "<timeout>"
1211
+ }
1212
+ },
1213
+ transform(value) {
1214
+ if (typeof value !== "object")
1215
+ throw new Error(`Unexpected value for --expect.poll: ${value}. If you need to configure timeout, use --expect.poll.timeout=<timeout>`);
1216
+ return value;
1217
+ }
1218
+ }
1219
+ },
1220
+ transform(value) {
1221
+ if (typeof value !== "object")
1222
+ throw new Error(`Unexpected value for --expect: ${value}. If you need to configure expect options, use --expect.{name}=<value> syntax`);
1223
+ return value;
1224
+ }
1225
+ },
1226
+ printConsoleTrace: {
1227
+ description: "Always print console stack traces"
1228
+ },
1188
1229
  // CLI only options
1189
1230
  run: {
1190
1231
  description: "Disable watch mode"
1191
1232
  },
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
1233
  color: {
1198
1234
  description: "Removes colors from the console output",
1199
1235
  alias: "no-color"
@@ -1204,6 +1240,15 @@ const cliOptionsConfig = {
1204
1240
  standalone: {
1205
1241
  description: "Start Vitest without running tests. File filters will be ignored, tests will be running only on change (default: `false`)"
1206
1242
  },
1243
+ mergeReports: {
1244
+ description: "Paths to blob reports directory. If this options is used, Vitest won't run any tests, it will only report previously recorded tests",
1245
+ argument: "[path]",
1246
+ transform(value) {
1247
+ if (!value || typeof value === "boolean")
1248
+ return ".vitest-reports";
1249
+ return value;
1250
+ }
1251
+ },
1207
1252
  // disable CLI options
1208
1253
  cliExclude: null,
1209
1254
  server: null,
@@ -1317,7 +1362,7 @@ function createCLI(options = {}) {
1317
1362
  if (subcommands.length === 1 && (subcommands[0] === "--expand-help" || subcommands[0] === "--expandHelp"))
1318
1363
  return info;
1319
1364
  const subcommandMarker = "$SUB_COMMAND_MARKER$";
1320
- const banner = info.find((current) => /^vitest\/[0-9]+\.[0-9]+\.[0-9]+$/.test(current.body));
1365
+ const banner = info.find((current) => /^vitest\/\d+\.\d+\.\d+$/.test(current.body));
1321
1366
  function addBannerWarning(warning) {
1322
1367
  if (typeof (banner == null ? void 0 : banner.body) === "string") {
1323
1368
  if (banner == null ? void 0 : banner.body.includes(warning))
@@ -1351,9 +1396,6 @@ function createCLI(options = {}) {
1351
1396
  cli.command("bench [...filters]", void 0, options).action(benchmark),
1352
1397
  benchCliOptionsConfig
1353
1398
  );
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
1399
  cli.command("[...filters]", void 0, options).action((filters, options2) => start("test", filters, options2));
1358
1400
  return cli;
1359
1401
  }
@@ -1410,13 +1452,13 @@ async function start(mode, cliFilters, options) {
1410
1452
  } catch {
1411
1453
  }
1412
1454
  try {
1413
- const { startVitest } = await import('./cli-api.DTeni0Qq.js').then(function (n) { return n.d; });
1455
+ const { startVitest } = await import('./cli-api.CUtJc4r3.js').then(function (n) { return n.d; });
1414
1456
  const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(options));
1415
1457
  if (!(ctx == null ? void 0 : ctx.shouldKeepServer()))
1416
1458
  await (ctx == null ? void 0 : ctx.exit());
1417
1459
  return ctx;
1418
1460
  } catch (e) {
1419
- const { divider } = await import('./utils.D5gGkwyH.js').then(function (n) { return n.u; });
1461
+ const { divider } = await import('./utils.YuQ3LT2a.js').then(function (n) { return n.u; });
1420
1462
  console.error(`
1421
1463
  ${c.red(divider(c.bold(c.inverse(" Unhandled Error "))))}`);
1422
1464
  console.error(e);