vitest 5.0.0-beta.3 → 5.0.0-beta.4

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 (43) hide show
  1. package/dist/browser.d.ts +1 -1
  2. package/dist/browser.js +1 -1
  3. package/dist/chunks/{base.Bay6B1Dz.js → base.BEGVMQrS.js} +6 -6
  4. package/dist/chunks/{browser.d.DM1g8UNp.d.ts → browser.d.BGxB4Xum.d.ts} +4 -25
  5. package/dist/chunks/{cac.DoK9yX-i.js → cac.CyXAEMkE.js} +22 -31
  6. package/dist/chunks/{cli-api.BCY9ylNq.js → cli-api.DJMXq34b.js} +502 -549
  7. package/dist/chunks/{config.d.C0UMwus7.d.ts → config.d.DXq1aBpy.d.ts} +7 -26
  8. package/dist/chunks/{creator.BqL2U_x4.js → creator.D66cVXYh.js} +2 -2
  9. package/dist/chunks/{defaults.DVfzlTkU.js → defaults.CUUnbOrq.js} +5 -3
  10. package/dist/chunks/global.d.BtKPuz2X.d.ts +194 -0
  11. package/dist/chunks/{globals.8_qjZdeE.js → globals.BuY-yD0m.js} +2 -1
  12. package/dist/chunks/{index.ukHtlBbI.js → index.CE58PZNH.js} +355 -146
  13. package/dist/chunks/{index.PuMGMNHF.js → index.CcluKS59.js} +4 -4
  14. package/dist/chunks/{index.CbgUM9E5.js → index.nQFVd50u.js} +2 -1
  15. package/dist/chunks/{init-forks.OoZmDo1g.js → init-forks.Ce3vGWgL.js} +1 -1
  16. package/dist/chunks/{init-threads.eSHAowcx.js → init-threads.8e1OLv5v.js} +1 -1
  17. package/dist/chunks/{init.YjNsCb-_.js → init.6qx-LaHs.js} +30 -2
  18. package/dist/chunks/{nativeModuleMocker.DKpFw0pk.js → nativeModuleMocker.DDZfQXLs.js} +1 -1
  19. package/dist/chunks/{plugin.d.C00LxKL6.d.ts → plugin.d.B7MTG_Fe.d.ts} +71 -82
  20. package/dist/chunks/{rpc.d.7JZuxZ8u.d.ts → rpc.d.OQ_EZi1Z.d.ts} +18 -2
  21. package/dist/chunks/{setup-common.eQsbxe88.js → setup-common.DdEF_hkE.js} +1 -1
  22. package/dist/chunks/{vm.BE_VOfSs.js → vm.Bu7mmcZq.js} +2 -2
  23. package/dist/chunks/{worker.d.Dv3hDCFf.d.ts → worker.d.yR22cs6X.d.ts} +3 -2
  24. package/dist/cli.js +1 -1
  25. package/dist/config.cjs +1 -1
  26. package/dist/config.d.ts +6 -8
  27. package/dist/config.js +1 -1
  28. package/dist/index.d.ts +23 -40
  29. package/dist/index.js +2 -1
  30. package/dist/module-evaluator.d.ts +4 -1
  31. package/dist/module-evaluator.js +14 -19
  32. package/dist/node.d.ts +20 -12
  33. package/dist/node.js +5 -5
  34. package/dist/runtime.js +2 -2
  35. package/dist/worker.d.ts +3 -3
  36. package/dist/worker.js +7 -6
  37. package/dist/workers/forks.js +8 -7
  38. package/dist/workers/runVmTests.js +4 -3
  39. package/dist/workers/threads.js +8 -7
  40. package/dist/workers/vmForks.js +4 -4
  41. package/dist/workers/vmThreads.js +4 -4
  42. package/package.json +15 -15
  43. package/dist/chunks/global.d.DZbA5YnY.d.ts +0 -101
package/dist/browser.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { c as SerializedCoverageConfig, a as SerializedConfig } from './chunks/config.d.C0UMwus7.js';
1
+ import { c as SerializedCoverageConfig, a as SerializedConfig } from './chunks/config.d.DXq1aBpy.js';
2
2
  import { R as RuntimeCoverageModuleLoader } from './chunks/coverage.d.g2xbl2sP.js';
3
3
  import { SerializedDiffOptions } from '@vitest/utils/diff';
4
4
  export { collectTests, startTests } from '@vitest/runner';
package/dist/browser.js CHANGED
@@ -1,4 +1,4 @@
1
- export { l as loadDiffConfig, a as loadSnapshotSerializers, s as setupCommonEnv, b as startCoverageInsideWorker, c as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/setup-common.eQsbxe88.js';
1
+ export { l as loadDiffConfig, a as loadSnapshotSerializers, s as setupCommonEnv, b as startCoverageInsideWorker, c as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/setup-common.DdEF_hkE.js';
2
2
  export { collectTests, startTests } from '@vitest/runner';
3
3
  import * as spyModule from '@vitest/spy';
4
4
  export { spyModule as SpyModule };
@@ -1,15 +1,15 @@
1
1
  import { runInThisContext } from 'node:vm';
2
2
  import * as spyModule from '@vitest/spy';
3
- import { r as resolveTestRunner, a as resolveSnapshotEnvironment, d as detectAsyncLeaks, s as setupChaiConfig } from './index.PuMGMNHF.js';
4
- import { l as loadEnvironment, e as emitModuleRunner, a as listenForErrors } from './init.YjNsCb-_.js';
3
+ import { r as resolveTestRunner, a as resolveSnapshotEnvironment, d as detectAsyncLeaks, s as setupChaiConfig } from './index.CcluKS59.js';
4
+ import { l as loadEnvironment, e as emitModuleRunner, a as listenForErrors } from './init.6qx-LaHs.js';
5
5
  import { N as NativeModuleRunner } from './nativeModuleRunner.BOeMnHl4.js';
6
6
  import { Traces } from '../traces.js';
7
7
  import { V as VitestEvaluatedModules } from './rpc.DFRWVnRh.js';
8
- import { s as startVitestModuleRunner, c as createNodeImportMeta } from './index.CbgUM9E5.js';
8
+ import { s as startVitestModuleRunner, c as createNodeImportMeta } from './index.nQFVd50u.js';
9
9
  import { performance as performance$1 } from 'node:perf_hooks';
10
10
  import { startTests, collectTests } from '@vitest/runner';
11
- import { s as setupCommonEnv, b as startCoverageInsideWorker, c as stopCoverageInsideWorker } from './setup-common.eQsbxe88.js';
12
- import { i as index, g as globalExpect, v as vi } from './index.ukHtlBbI.js';
11
+ import { s as setupCommonEnv, b as startCoverageInsideWorker, c as stopCoverageInsideWorker } from './setup-common.DdEF_hkE.js';
12
+ import { i as index, g as globalExpect, v as vi } from './index.CE58PZNH.js';
13
13
  import { c as closeInspector } from './inspector.CvyFGlXm.js';
14
14
  import { createRequire } from 'node:module';
15
15
  import timers from 'node:timers';
@@ -114,7 +114,7 @@ async function startModuleRunner(options) {
114
114
  let mocker;
115
115
  if (options.state.config.experimental.nodeLoader !== false) {
116
116
  // this additionally imports acorn/magic-string
117
- const { NativeModuleMocker } = await import('./nativeModuleMocker.DKpFw0pk.js');
117
+ const { NativeModuleMocker } = await import('./nativeModuleMocker.DDZfQXLs.js');
118
118
  mocker = new NativeModuleMocker({
119
119
  async resolveId(id, importer) {
120
120
  // TODO: use import.meta.resolve instead
@@ -2,11 +2,9 @@ import { MockInstance } from '@vitest/spy';
2
2
  import { Formatter } from 'tinyrainbow';
3
3
  import { diff, printDiffOrStringify } from '@vitest/utils/diff';
4
4
  import { stringify } from '@vitest/utils/display';
5
- import { Test, FileSpecification } from '@vitest/runner';
6
- import { ChainableFunction } from '@vitest/runner/utils';
7
- import { TaskResult, Bench, Options } from 'tinybench';
8
- import { O as OTELCarrier } from './rpc.d.7JZuxZ8u.js';
9
- import { T as TestExecutionMethod } from './worker.d.Dv3hDCFf.js';
5
+ import { FileSpecification } from '@vitest/runner';
6
+ import { O as OTELCarrier } from './rpc.d.OQ_EZi1Z.js';
7
+ import { T as TestExecutionMethod } from './worker.d.yR22cs6X.js';
10
8
 
11
9
  type SerializedTestSpecification = [project: {
12
10
  name: string | undefined;
@@ -870,25 +868,6 @@ declare global {
870
868
  }
871
869
  }
872
870
 
873
- interface Benchmark extends Test {
874
- meta: {
875
- benchmark: true;
876
- result?: TaskResult;
877
- };
878
- }
879
- interface BenchmarkResult extends TaskResult {
880
- name: string;
881
- rank: number;
882
- sampleCount: number;
883
- median: number;
884
- }
885
- type BenchFunction = (this: Bench) => Promise<void> | void;
886
- type ChainableBenchmarkAPI = ChainableFunction<"skip" | "only" | "todo", (name: string | Function, fn?: BenchFunction, options?: Options) => void>;
887
- type BenchmarkAPI = ChainableBenchmarkAPI & {
888
- skipIf: (condition: any) => ChainableBenchmarkAPI;
889
- runIf: (condition: any) => ChainableBenchmarkAPI;
890
- };
891
-
892
871
  interface BrowserTesterOptions {
893
872
  method: TestExecutionMethod;
894
873
  files: FileSpecification[];
@@ -896,4 +875,4 @@ interface BrowserTesterOptions {
896
875
  otelCarrier?: OTELCarrier;
897
876
  }
898
877
 
899
- export type { AsyncExpectationResult as A, BenchFunction as B, DeeplyAllowMatchers as D, ExpectStatic as E, JestAssertion as J, ModuleDefinitionDurationsDiagnostic as M, PromisifyAssertion as P, RawMatcherFn as R, SerializedTestSpecification as S, Tester as T, UntrackedModuleDefinitionDiagnostic as U, MatcherState as a, SyncExpectationResult as b, ExpectationResult as c, BenchmarkAPI as d, ModuleDefinitionDiagnostic as e, ModuleDefinitionLocation as f, SourceModuleDiagnostic as g, SourceModuleLocations as h, Assertion as i, AsymmetricMatchersContaining as j, Benchmark as k, BenchmarkResult as l, BrowserTesterOptions as m, Matchers as n, MatchersObject as o };
878
+ export type { AsyncExpectationResult as A, BrowserTesterOptions as B, DeeplyAllowMatchers as D, ExpectStatic as E, JestAssertion as J, ModuleDefinitionDurationsDiagnostic as M, PromisifyAssertion as P, RawMatcherFn as R, SerializedTestSpecification as S, Tester as T, UntrackedModuleDefinitionDiagnostic as U, MatcherState as a, SyncExpectationResult as b, ExpectationResult as c, ModuleDefinitionDiagnostic as d, ModuleDefinitionLocation as e, SourceModuleDiagnostic as f, SourceModuleLocations as g, Assertion as h, AsymmetricMatchersContaining as i, Matchers as j, MatchersObject as k };
@@ -1,7 +1,7 @@
1
1
  import { toArray } from '@vitest/utils/helpers';
2
2
  import { EventEmitter } from 'events';
3
3
  import { normalize } from 'pathe';
4
- import c$2, { disableDefaultColors } from 'tinyrainbow';
4
+ import { disableDefaultColors } from 'tinyrainbow';
5
5
  import { i as isForceColor } from './env.BKKtU2WC.js';
6
6
  import { a as defaultPort, d as defaultBrowserPort } from './constants.-juJ8b_4.js';
7
7
  import assert from 'node:assert';
@@ -621,7 +621,7 @@ class CAC extends EventEmitter {
621
621
 
622
622
  const cac = (name = "") => new CAC(name);
623
623
 
624
- var version = "5.0.0-beta.3";
624
+ var version = "5.0.0-beta.4";
625
625
 
626
626
  const apiConfig = (port) => ({
627
627
  port: {
@@ -839,7 +839,7 @@ const cliOptionsConfig = {
839
839
  }
840
840
  },
841
841
  mode: {
842
- description: "Override Vite mode (default: `test` or `benchmark`)",
842
+ description: "Override Vite mode (default: `test`)",
843
843
  argument: "<name>"
844
844
  },
845
845
  isolate: { description: "Run every test file in isolation. To disable isolation, use `--no-isolate` (default: `true`)" },
@@ -907,7 +907,7 @@ const cliOptionsConfig = {
907
907
  argument: "<options>",
908
908
  subcommands: {
909
909
  testIdAttribute: null,
910
- exact: { description: "Should locators match the text exactly by default (default: `false`)" },
910
+ exact: { description: "Should locators match the text exactly by default (default: `true`)" },
911
911
  errorFormat: null
912
912
  },
913
913
  transform(val) {
@@ -1298,8 +1298,6 @@ const cliOptionsConfig = {
1298
1298
  deps: null,
1299
1299
  name: null,
1300
1300
  snapshotEnvironment: null,
1301
- compare: null,
1302
- outputJson: null,
1303
1301
  json: null,
1304
1302
  provide: null,
1305
1303
  filesOnly: null,
@@ -1308,18 +1306,9 @@ const cliOptionsConfig = {
1308
1306
  projects: null,
1309
1307
  watchTriggerPatterns: null,
1310
1308
  tags: null,
1309
+ benchmarkOnly: null,
1311
1310
  taskTitleValueFormatTruncate: null
1312
1311
  };
1313
- const benchCliOptionsConfig = {
1314
- compare: {
1315
- description: "Benchmark output file to compare against",
1316
- argument: "<filename>"
1317
- },
1318
- outputJson: {
1319
- description: "Benchmark output file",
1320
- argument: "<filename>"
1321
- }
1322
- };
1323
1312
  const collectCliOptionsConfig = {
1324
1313
  ...cliOptionsConfig,
1325
1314
  json: {
@@ -2276,10 +2265,10 @@ function createCLI(options = {}) {
2276
2265
  cli.command("related [...filters]", void 0, options).action(runRelated);
2277
2266
  cli.command("watch [...filters]", void 0, options).action(watch);
2278
2267
  cli.command("dev [...filters]", void 0, options).action(watch);
2279
- addCliOptions(cli.command("bench [...filters]", void 0, options).action(benchmark), benchCliOptionsConfig);
2268
+ cli.command("bench [...filters]", void 0, options).action(benchmark);
2280
2269
  cli.command("init <project>", void 0, options).action(init);
2281
- addCliOptions(cli.command("list [...filters]", void 0, options).action((filters, options) => collect("test", filters, options)), collectCliOptionsConfig);
2282
- cli.command("[...filters]", void 0, options).action((filters, options) => start("test", filters, options));
2270
+ addCliOptions(cli.command("list [...filters]", void 0, options).action((filters, options) => collect(filters, options)), collectCliOptionsConfig);
2271
+ cli.command("[...filters]", void 0, options).action((filters, options) => start(filters, options));
2283
2272
  setupTabCompletions(cli);
2284
2273
  return cli;
2285
2274
  }
@@ -2320,20 +2309,22 @@ function parseCLI(argv, config = {}) {
2320
2309
  async function runRelated(relatedFiles, argv) {
2321
2310
  argv.related = relatedFiles;
2322
2311
  argv.passWithNoTests ??= true;
2323
- await start("test", [], argv);
2312
+ await start([], argv);
2324
2313
  }
2325
2314
  async function watch(cliFilters, options) {
2326
2315
  options.watch = true;
2327
- await start("test", cliFilters, options);
2316
+ await start(cliFilters, options);
2328
2317
  }
2329
2318
  async function run(cliFilters, options) {
2330
2319
  // "vitest run --watch" should still be watch mode
2331
2320
  options.run = !options.watch;
2332
- await start("test", cliFilters, options);
2321
+ await start(cliFilters, options);
2333
2322
  }
2334
2323
  async function benchmark(cliFilters, options) {
2335
- console.warn(c$2.yellow("Benchmarking is an experimental feature.\nBreaking changes might not follow SemVer, please pin Vitest's version when using it."));
2336
- await start("benchmark", cliFilters, options);
2324
+ options.benchmarkOnly = true;
2325
+ options.coverage ??= {};
2326
+ options.coverage.enabled = false;
2327
+ await start(cliFilters, options);
2337
2328
  }
2338
2329
  function normalizeCliOptions(cliFilters, argv) {
2339
2330
  if (argv.exclude) {
@@ -2348,10 +2339,10 @@ function normalizeCliOptions(cliFilters, argv) {
2348
2339
  }
2349
2340
  return argv;
2350
2341
  }
2351
- async function start(mode, cliFilters, options) {
2342
+ async function start(cliFilters, options) {
2352
2343
  try {
2353
- const { startVitest } = await import('./cli-api.BCY9ylNq.js').then(function (n) { return n.K; });
2354
- const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
2344
+ const { startVitest } = await import('./cli-api.DJMXq34b.js').then(function (n) { return n.C; });
2345
+ const ctx = await startVitest(cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
2355
2346
  if (!ctx.shouldKeepServer()) await ctx.exit();
2356
2347
  } catch (e) {
2357
2348
  const { errorBanner } = await import('./utils.DKODp04v.js').then(function (n) { return n.u; });
@@ -2367,13 +2358,13 @@ async function init(project) {
2367
2358
  console.error(/* @__PURE__ */ new Error("Only the \"browser\" project is supported. Use \"vitest init browser\" to create a new project."));
2368
2359
  process.exit(1);
2369
2360
  }
2370
- const { create } = await import('./creator.BqL2U_x4.js');
2361
+ const { create } = await import('./creator.D66cVXYh.js');
2371
2362
  await create();
2372
2363
  }
2373
- async function collect(mode, cliFilters, options) {
2364
+ async function collect(cliFilters, options) {
2374
2365
  try {
2375
- const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.BCY9ylNq.js').then(function (n) { return n.K; });
2376
- const ctx = await prepareVitest(mode, {
2366
+ const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.DJMXq34b.js').then(function (n) { return n.C; });
2367
+ const ctx = await prepareVitest({
2377
2368
  ...normalizeCliOptions(cliFilters, options),
2378
2369
  watch: false,
2379
2370
  run: true