vitest 2.1.4 → 2.1.6

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 (44) hide show
  1. package/dist/browser.d.ts +9 -9
  2. package/dist/browser.js +1 -1
  3. package/dist/chunks/{base.C3xNdjV6.js → base.BZZh4cSm.js} +1 -1
  4. package/dist/chunks/{cac.DrfPaMvZ.js → cac.DPEe9SCx.js} +5 -5
  5. package/dist/chunks/{cli-api.CKrRYkw8.js → cli-api.FAAw0S6C.js} +106 -77
  6. package/dist/chunks/{config.Crbj2GAb.d.ts → config.Cy0C388Z.d.ts} +0 -1
  7. package/dist/chunks/{globals.Bp645TTJ.js → globals.D8ZVAdXd.js} +2 -2
  8. package/dist/chunks/{index.Bn81VaWg.js → index.DsZFoqi9.js} +205 -303
  9. package/dist/chunks/{index.BMoXz_-n.js → index.K90BXFOx.js} +1 -1
  10. package/dist/chunks/{index.Dqe5k2Rk.js → index.ckWaX2gY.js} +1 -1
  11. package/dist/chunks/{index.D3d79vc8.js → index.nEwtF0bu.js} +1 -1
  12. package/dist/chunks/{reporters.anwo7Y6a.d.ts → reporters.D7Jzd9GS.d.ts} +26 -16
  13. package/dist/chunks/{resolveConfig.DPmbhVlP.js → resolveConfig.RxKrDli4.js} +4 -2
  14. package/dist/chunks/{runBaseTests.Dm-659zB.js → runBaseTests.3qpJUEJM.js} +4 -4
  15. package/dist/chunks/{setup-common.DDmVKp6O.js → setup-common.Dj6BZI3u.js} +1 -1
  16. package/dist/chunks/{utils.BB4zjzR8.js → utils.DNoFbBUZ.js} +6 -2
  17. package/dist/chunks/{vi.JMQoNY_Z.js → vi.DgezovHB.js} +85 -3
  18. package/dist/chunks/{vite.BdBj-UWY.d.ts → vite.C-N5BBZe.d.ts} +1 -1
  19. package/dist/chunks/{vm.jpyrB0xy.js → vm.Zr4qWzDJ.js} +3 -0
  20. package/dist/chunks/{worker.DHnGaO2M.d.ts → worker.B9FxPCaC.d.ts} +1 -1
  21. package/dist/chunks/{worker.BAlI9hII.d.ts → worker.tN5KGIih.d.ts} +2 -1
  22. package/dist/cli.js +1 -1
  23. package/dist/config.d.ts +9 -9
  24. package/dist/coverage.d.ts +7 -7
  25. package/dist/coverage.js +1 -1
  26. package/dist/environments.js +1 -1
  27. package/dist/execute.d.ts +2 -2
  28. package/dist/index.d.ts +37 -8
  29. package/dist/index.js +2 -2
  30. package/dist/node.d.ts +8 -8
  31. package/dist/node.js +7 -7
  32. package/dist/reporters.d.ts +9 -9
  33. package/dist/reporters.js +2 -2
  34. package/dist/runners.d.ts +1 -1
  35. package/dist/runners.js +1 -1
  36. package/dist/worker.js +6 -2
  37. package/dist/workers/forks.js +1 -1
  38. package/dist/workers/runVmTests.js +4 -4
  39. package/dist/workers/threads.js +1 -1
  40. package/dist/workers/vmForks.js +1 -1
  41. package/dist/workers/vmThreads.js +1 -1
  42. package/dist/workers.d.ts +3 -3
  43. package/dist/workers.js +4 -3
  44. package/package.json +18 -18
@@ -408,7 +408,7 @@ var happy = {
408
408
  const { keys, originals } = populateGlobal(global, win, {
409
409
  bindFunctions: true,
410
410
  // jsdom doesn't support Request and Response, but happy-dom does
411
- additionalKeys: ["Request", "Response"]
411
+ additionalKeys: ["Request", "Response", "MessagePort", "fetch"]
412
412
  });
413
413
  return {
414
414
  async teardown(global2) {
@@ -1,4 +1,4 @@
1
- import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.JMQoNY_Z.js';
1
+ import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.DgezovHB.js';
2
2
  import { g as getWorkerState } from './utils.C8RiOc4B.js';
3
3
  import { i as isFirstRun, a as runOnce } from './run-once.2ogXb3JV.js';
4
4
  import { b as bench } from './benchmark.Cdu9hjj4.js';
@@ -3,7 +3,7 @@ import { resolve } from 'node:path';
3
3
  import { t as takeCoverageInsideWorker } from './coverage.BoMDb1ip.js';
4
4
  import { distDir } from '../path.js';
5
5
  import { r as rpc } from './rpc.C3q9uwRX.js';
6
- import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.DDmVKp6O.js';
6
+ import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.Dj6BZI3u.js';
7
7
  import { g as getWorkerState } from './utils.C8RiOc4B.js';
8
8
 
9
9
  function setupChaiConfig(config) {
@@ -1,21 +1,21 @@
1
- import { S as SerializedConfig, F as FakeTimerInstallOpts } from './config.Crbj2GAb.js';
2
- import { PrettyFormatOptions } from '@vitest/pretty-format';
3
1
  import * as _vitest_runner from '@vitest/runner';
4
2
  import { File, TaskResultPack, Task, Test, Suite, CancelReason, Custom, TaskMeta, SequenceHooks, SequenceSetupFiles } from '@vitest/runner';
5
- import { SnapshotSummary, SnapshotStateOptions } from '@vitest/snapshot';
3
+ import { b as Awaitable, U as UserConsoleLog, P as ProvidedContext, A as AfterSuiteRunMeta, c as Arrayable$1, f as EnvironmentOptions, d as ArgumentsType, O as OnServerRestartHandler } from './environment.LoooBwUu.js';
4
+ import { Writable } from 'node:stream';
6
5
  import * as vite from 'vite';
7
6
  import { ViteDevServer, TransformResult as TransformResult$1, ServerOptions, DepOptimizationConfig, AliasOptions, UserConfig as UserConfig$1, ConfigEnv } from 'vite';
7
+ import { ParsedStack, Awaitable as Awaitable$1, ErrorWithDiff, TestError, Arrayable } from '@vitest/utils';
8
+ import { S as SerializedConfig, F as FakeTimerInstallOpts } from './config.Cy0C388Z.js';
9
+ import { PrettyFormatOptions } from '@vitest/pretty-format';
10
+ import { SnapshotSummary, SnapshotStateOptions } from '@vitest/snapshot';
8
11
  import { RawSourceMap, ViteNodeServerOptions } from 'vite-node';
9
12
  import * as chai from 'chai';
10
- import { b as Awaitable, U as UserConsoleLog, P as ProvidedContext, A as AfterSuiteRunMeta, c as Arrayable$1, f as EnvironmentOptions, d as ArgumentsType, O as OnServerRestartHandler } from './environment.LoooBwUu.js';
11
- import { Writable } from 'node:stream';
12
- import { ParsedStack, Awaitable as Awaitable$1, ErrorWithDiff, TestError, Arrayable } from '@vitest/utils';
13
13
  import { StackTraceParserOptions } from '@vitest/utils/source-map';
14
14
  import { ViteNodeRunner } from 'vite-node/client';
15
15
  import { ViteNodeServer } from 'vite-node/server';
16
+ import { B as BenchmarkResult } from './benchmark.geERunq4.js';
16
17
  import { SnapshotManager } from '@vitest/snapshot/manager';
17
18
  import { Stats } from 'node:fs';
18
- import { B as BenchmarkResult } from './benchmark.geERunq4.js';
19
19
 
20
20
  type SerializedTestSpecification = [
21
21
  project: {
@@ -57,14 +57,14 @@ declare abstract class BaseReporter implements Reporter {
57
57
  ctx: Vitest;
58
58
  protected verbose: boolean;
59
59
  private _filesInWatchMode;
60
+ private _timeStart;
60
61
  private _lastRunTimeout;
61
62
  private _lastRunTimer;
62
63
  private _lastRunCount;
63
- private _timeStart;
64
- private _offUnhandledRejection?;
65
64
  constructor(options?: BaseOptions);
66
- get mode(): VitestRunMode;
67
65
  onInit(ctx: Vitest): void;
66
+ log(...messages: any): void;
67
+ error(...messages: any): void;
68
68
  relative(path: string): string;
69
69
  onFinished(files?: File[], errors?: unknown[]): void;
70
70
  onTaskUpdate(packs: TaskResultPack[]): void;
@@ -74,6 +74,7 @@ declare abstract class BaseReporter implements Reporter {
74
74
  private resetLastRunLog;
75
75
  onWatcherRerun(files: string[], trigger?: string): void;
76
76
  onUserConsoleLog(log: UserConsoleLog): void;
77
+ onTestRemoved(trigger?: string): void;
77
78
  shouldLog(log: UserConsoleLog): boolean;
78
79
  onServerRestart(reason?: string): void;
79
80
  reportSummary(files: File[], errors: unknown[]): void;
@@ -81,7 +82,6 @@ declare abstract class BaseReporter implements Reporter {
81
82
  private printErrorsSummary;
82
83
  reportBenchmarkSummary(files: File[]): void;
83
84
  private printTaskErrors;
84
- registerUnhandledRejection(): void;
85
85
  }
86
86
 
87
87
  interface ParsedFile extends File {
@@ -293,7 +293,7 @@ declare class Logger {
293
293
  log(...args: any[]): void;
294
294
  error(...args: any[]): void;
295
295
  warn(...args: any[]): void;
296
- clearFullScreen(message: string): void;
296
+ clearFullScreen(message?: string): void;
297
297
  clearScreen(message: string, force?: boolean): void;
298
298
  private _clearScreen;
299
299
  printError(err: unknown, options?: ErrorOptions): PrintErrorResult | undefined;
@@ -301,8 +301,10 @@ declare class Logger {
301
301
  highlight(filename: string, source: string): string;
302
302
  printNoTestFound(filters?: string[]): void;
303
303
  printBanner(): void;
304
+ printBrowserBanner(project: WorkspaceProject): void;
304
305
  printUnhandledErrors(errors: unknown[]): void;
305
306
  printSourceTypeErrors(errors: TypeCheckError[]): void;
307
+ private registerUnhandledRejection;
306
308
  }
307
309
 
308
310
  interface BrowserProviderInitializationOptions {
@@ -467,6 +469,7 @@ interface BrowserServerStateContext {
467
469
  interface BrowserOrchestrator {
468
470
  createTesters: (files: string[]) => Promise<void>;
469
471
  onCancel: (reason: CancelReason) => Promise<void>;
472
+ $close: () => void;
470
473
  }
471
474
  interface BrowserServerState {
472
475
  orchestrators: Map<string, BrowserOrchestrator>;
@@ -577,7 +580,7 @@ declare class WorkspaceProject {
577
580
  isTargetFile(id: string, source?: string): Promise<boolean>;
578
581
  isInSourceTestFile(code: string): boolean;
579
582
  filterFiles(testFiles: string[], filters: string[], dir: string): string[];
580
- initBrowserServer(configFile: string | undefined): Promise<void>;
583
+ initBrowserServer(): Promise<void>;
581
584
  static createBasicProject(ctx: Vitest): WorkspaceProject;
582
585
  static createCoreProject(ctx: Vitest): Promise<WorkspaceProject>;
583
586
  setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
@@ -2465,6 +2468,10 @@ declare class TestProject {
2465
2468
  * @experimental The public Vitest API is experimental and does not follow semver.
2466
2469
  */
2467
2470
  readonly workspaceProject: WorkspaceProject;
2471
+ /**
2472
+ * Vite's dev server instance. Every workspace project has its own server.
2473
+ */
2474
+ readonly vite: ViteDevServer;
2468
2475
  /**
2469
2476
  * Resolved project configuration.
2470
2477
  */
@@ -2663,10 +2670,12 @@ declare class Vitest {
2663
2670
  runner: ViteNodeRunner;
2664
2671
  packageInstaller: VitestPackageInstaller;
2665
2672
  private coreWorkspaceProject;
2666
- private resolvedProjects;
2673
+ /** @private */
2674
+ resolvedProjects: WorkspaceProject[];
2667
2675
  projects: WorkspaceProject[];
2668
2676
  distPath: string;
2669
2677
  private _cachedSpecs;
2678
+ private _workspaceConfigPath?;
2670
2679
  /** @deprecated use `_cachedSpecs` */
2671
2680
  projectTestFiles: Map<string, WorkspaceSpec[]>;
2672
2681
  /** @private */
@@ -2695,7 +2704,6 @@ declare class Vitest {
2695
2704
  private getWorkspaceConfigPath;
2696
2705
  private resolveWorkspace;
2697
2706
  private initCoverageProvider;
2698
- private initBrowserProviders;
2699
2707
  mergeReports(): Promise<void>;
2700
2708
  collect(filters?: string[]): Promise<{
2701
2709
  tests: File[];
@@ -2715,7 +2723,8 @@ declare class Vitest {
2715
2723
  runFiles(specs: TestSpecification[], allTestsRun: boolean): Promise<void>;
2716
2724
  collectFiles(specs: WorkspaceSpec[]): Promise<void>;
2717
2725
  cancelCurrentRun(reason: CancelReason): Promise<void>;
2718
- rerunFiles(files?: string[], trigger?: string): Promise<void>;
2726
+ initBrowserServers(): Promise<void>;
2727
+ rerunFiles(files?: string[], trigger?: string, allTestsRun?: boolean): Promise<void>;
2719
2728
  changeProjectName(pattern: string): Promise<void>;
2720
2729
  changeNamePattern(pattern: string, files?: string[], trigger?: string): Promise<void>;
2721
2730
  changeFilenamePattern(pattern: string, files?: string[]): Promise<void>;
@@ -2732,6 +2741,7 @@ declare class Vitest {
2732
2741
  onChange: (id: string) => void;
2733
2742
  onUnlink: (id: string) => void;
2734
2743
  onAdd: (id: string) => Promise<void>;
2744
+ checkUnhandledErrors(errors: unknown[]): void;
2735
2745
  private unregisterWatcher;
2736
2746
  private registerWatcher;
2737
2747
  /**
@@ -6672,7 +6672,9 @@ function createMethodsRPC(project, options = {}) {
6672
6672
  ctx.state.catchError(err, type);
6673
6673
  },
6674
6674
  onFinished(files) {
6675
- return ctx.report("onFinished", files, ctx.state.getUnhandledErrors());
6675
+ const errors = ctx.state.getUnhandledErrors();
6676
+ ctx.checkUnhandledErrors(errors);
6677
+ return ctx.report("onFinished", files, errors);
6676
6678
  },
6677
6679
  onCancel(reason) {
6678
6680
  ctx.cancelCurrentRun(reason);
@@ -6683,7 +6685,7 @@ function createMethodsRPC(project, options = {}) {
6683
6685
  };
6684
6686
  }
6685
6687
  function handleRollupError(e) {
6686
- if (e instanceof Error && "plugin" in e) {
6688
+ if (e instanceof Error && ("plugin" in e || "frame" in e || "id" in e)) {
6687
6689
  throw {
6688
6690
  name: e.name,
6689
6691
  message: e.message,
@@ -1,8 +1,8 @@
1
1
  import { performance } from 'node:perf_hooks';
2
2
  import { startTests, collectTests } from '@vitest/runner';
3
- import { a as resolveSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './index.D3d79vc8.js';
3
+ import { a as resolveSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './index.nEwtF0bu.js';
4
4
  import { s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './coverage.BoMDb1ip.js';
5
- import { a as globalExpect, v as vi } from './vi.JMQoNY_Z.js';
5
+ import { a as globalExpect, v as vi } from './vi.DgezovHB.js';
6
6
  import { c as closeInspector } from './inspector.70d6emsh.js';
7
7
  import { createRequire } from 'node:module';
8
8
  import timers from 'node:timers';
@@ -10,8 +10,8 @@ import util from 'node:util';
10
10
  import { getSafeTimers } from '@vitest/utils';
11
11
  import { KNOWN_ASSET_TYPES } from 'vite-node/constants';
12
12
  import { installSourcemapsSupport } from 'vite-node/source-map';
13
- import { V as VitestIndex } from './index.Dqe5k2Rk.js';
14
- import { s as setupCommonEnv } from './setup-common.DDmVKp6O.js';
13
+ import { V as VitestIndex } from './index.ckWaX2gY.js';
14
+ import { s as setupCommonEnv } from './setup-common.Dj6BZI3u.js';
15
15
  import { g as getWorkerState, r as resetModules } from './utils.C8RiOc4B.js';
16
16
  import 'chai';
17
17
  import 'node:path';
@@ -13,7 +13,7 @@ async function setupCommonEnv(config) {
13
13
  globalSetup = true;
14
14
  setSafeTimers();
15
15
  if (config.globals) {
16
- (await import('./globals.Bp645TTJ.js')).registerApiGlobally();
16
+ (await import('./globals.D8ZVAdXd.js')).registerApiGlobally();
17
17
  }
18
18
  }
19
19
  function setupDefines(defines) {
@@ -179,6 +179,9 @@ function formatProjectName(name, suffix = " ") {
179
179
  const colors = [c.blue, c.yellow, c.cyan, c.green, c.magenta];
180
180
  return colors[index % colors.length](`|${name}|`) + suffix;
181
181
  }
182
+ function withLabel(color, label, message) {
183
+ return `${c.bold(c.inverse(c[color](` ${label} `)))} ${c[color](message)}`;
184
+ }
182
185
 
183
186
  var utils = /*#__PURE__*/Object.freeze({
184
187
  __proto__: null,
@@ -202,7 +205,8 @@ var utils = /*#__PURE__*/Object.freeze({
202
205
  spinnerMap: spinnerMap,
203
206
  suiteFail: suiteFail,
204
207
  taskFail: taskFail,
205
- testPass: testPass
208
+ testPass: testPass,
209
+ withLabel: withLabel
206
210
  });
207
211
 
208
- export { F_POINTER as F, F_RIGHT as a, F_CHECK as b, getStateString as c, divider as d, formatTimeString as e, formatProjectName as f, getStateSymbol as g, countTestErrors as h, getCols as i, getHookStateSymbol as j, renderSnapshotSummary as r, taskFail as t, utils as u };
212
+ export { F_POINTER as F, formatTimeString as a, F_RIGHT as b, F_CHECK as c, divider as d, getStateString as e, formatProjectName as f, getStateSymbol as g, countTestErrors as h, getCols as i, getHookStateSymbol as j, renderSnapshotSummary as r, taskFail as t, utils as u, withLabel as w };
@@ -44,6 +44,10 @@ function createExpectPoll(expect) {
44
44
  poll: true
45
45
  });
46
46
  fn = fn.bind(assertion);
47
+ const test = chai$1.util.flag(assertion, "vitest-test");
48
+ if (!test) {
49
+ throw new Error("expect.poll() must be called inside a test");
50
+ }
47
51
  const proxy = new Proxy(assertion, {
48
52
  get(target, key, receiver) {
49
53
  const assertionFunction = Reflect.get(target, key, receiver);
@@ -60,7 +64,7 @@ function createExpectPoll(expect) {
60
64
  }
61
65
  return function(...args) {
62
66
  const STACK_TRACE_ERROR = new Error("STACK_TRACE_ERROR");
63
- return new Promise((resolve, reject) => {
67
+ const promise = () => new Promise((resolve, reject) => {
64
68
  let intervalId;
65
69
  let lastError;
66
70
  const { setTimeout, clearTimeout } = getSafeTimers();
@@ -90,6 +94,36 @@ function createExpectPoll(expect) {
90
94
  };
91
95
  check();
92
96
  });
97
+ let awaited = false;
98
+ test.onFinished ??= [];
99
+ test.onFinished.push(() => {
100
+ if (!awaited) {
101
+ const negated = chai$1.util.flag(assertion, "negate") ? "not." : "";
102
+ const name = chai$1.util.flag(assertion, "_poll.element") ? "element(locator)" : "poll(assertion)";
103
+ const assertionString = `expect.${name}.${negated}${String(key)}()`;
104
+ const error = new Error(
105
+ `${assertionString} was not awaited. This assertion is asynchronous and must be awaited; otherwise, it is not executed to avoid unhandled rejections:
106
+
107
+ await ${assertionString}
108
+ `
109
+ );
110
+ throw copyStackTrace$1(error, STACK_TRACE_ERROR);
111
+ }
112
+ });
113
+ let resultPromise;
114
+ return {
115
+ then(onFulfilled, onRejected) {
116
+ awaited = true;
117
+ return (resultPromise ||= promise()).then(onFulfilled, onRejected);
118
+ },
119
+ catch(onRejected) {
120
+ return (resultPromise ||= promise()).catch(onRejected);
121
+ },
122
+ finally(onFinally) {
123
+ return (resultPromise ||= promise()).finally(onFinally);
124
+ },
125
+ [Symbol.toStringTag]: "Promise"
126
+ };
93
127
  };
94
128
  }
95
129
  });
@@ -202,9 +236,20 @@ function requireChaiSubset () {
202
236
  var chaiSubsetExports = requireChaiSubset();
203
237
  var Subset = /*@__PURE__*/getDefaultExportFromCjs(chaiSubsetExports);
204
238
 
205
- function recordAsyncExpect(test, promise) {
239
+ function createAssertionMessage(util, assertion, hasArgs) {
240
+ const not = util.flag(assertion, "negate") ? "not." : "";
241
+ const name = `${util.flag(assertion, "_name")}(${"expected" })`;
242
+ const promiseName = util.flag(assertion, "promise");
243
+ const promise = promiseName ? `.${promiseName}` : "";
244
+ return `expect(actual)${promise}.${not}${name}`;
245
+ }
246
+ function recordAsyncExpect(_test, promise, assertion, error) {
247
+ const test = _test;
206
248
  if (test && promise instanceof Promise) {
207
249
  promise = promise.finally(() => {
250
+ if (!test.promises) {
251
+ return;
252
+ }
208
253
  const index = test.promises.indexOf(promise);
209
254
  if (index !== -1) {
210
255
  test.promises.splice(index, 1);
@@ -214,6 +259,33 @@ function recordAsyncExpect(test, promise) {
214
259
  test.promises = [];
215
260
  }
216
261
  test.promises.push(promise);
262
+ let resolved = false;
263
+ test.onFinished ??= [];
264
+ test.onFinished.push(() => {
265
+ if (!resolved) {
266
+ const processor = globalThis.__vitest_worker__?.onFilterStackTrace || ((s) => s || "");
267
+ const stack = processor(error.stack);
268
+ console.warn([
269
+ `Promise returned by \`${assertion}\` was not awaited. `,
270
+ "Vitest currently auto-awaits hanging assertions at the end of the test, but this will cause the test to fail in Vitest 3. ",
271
+ "Please remember to await the assertion.\n",
272
+ stack
273
+ ].join(""));
274
+ }
275
+ });
276
+ return {
277
+ then(onFullfilled, onRejected) {
278
+ resolved = true;
279
+ return promise.then(onFullfilled, onRejected);
280
+ },
281
+ catch(onRejected) {
282
+ return promise.catch(onRejected);
283
+ },
284
+ finally(onFinally) {
285
+ return promise.finally(onFinally);
286
+ },
287
+ [Symbol.toStringTag]: "Promise"
288
+ };
217
289
  }
218
290
  return promise;
219
291
  }
@@ -260,6 +332,7 @@ const SnapshotPlugin = (chai, utils) => {
260
332
  chai.Assertion.prototype,
261
333
  key,
262
334
  function(properties, message) {
335
+ utils.flag(this, "_name", key);
263
336
  const isNot = utils.flag(this, "negate");
264
337
  if (isNot) {
265
338
  throw new Error(`${key} cannot be used with "not"`);
@@ -286,10 +359,12 @@ const SnapshotPlugin = (chai, utils) => {
286
359
  chai.Assertion.prototype,
287
360
  "toMatchFileSnapshot",
288
361
  function(file, message) {
362
+ utils.flag(this, "_name", "toMatchFileSnapshot");
289
363
  const isNot = utils.flag(this, "negate");
290
364
  if (isNot) {
291
365
  throw new Error('toMatchFileSnapshot cannot be used with "not"');
292
366
  }
367
+ const error = new Error("resolves");
293
368
  const expected = utils.flag(this, "object");
294
369
  const test = utils.flag(this, "vitest-test");
295
370
  const errorMessage = utils.flag(this, "message");
@@ -303,13 +378,19 @@ const SnapshotPlugin = (chai, utils) => {
303
378
  errorMessage,
304
379
  ...getTestNames(test)
305
380
  });
306
- return recordAsyncExpect(test, promise);
381
+ return recordAsyncExpect(
382
+ test,
383
+ promise,
384
+ createAssertionMessage(utils, this),
385
+ error
386
+ );
307
387
  }
308
388
  );
309
389
  utils.addMethod(
310
390
  chai.Assertion.prototype,
311
391
  "toMatchInlineSnapshot",
312
392
  function __INLINE_SNAPSHOT__(properties, inlineSnapshot, message) {
393
+ utils.flag(this, "_name", "toMatchInlineSnapshot");
313
394
  const isNot = utils.flag(this, "negate");
314
395
  if (isNot) {
315
396
  throw new Error('toMatchInlineSnapshot cannot be used with "not"');
@@ -348,6 +429,7 @@ const SnapshotPlugin = (chai, utils) => {
348
429
  chai.Assertion.prototype,
349
430
  "toThrowErrorMatchingSnapshot",
350
431
  function(message) {
432
+ utils.flag(this, "_name", "toThrowErrorMatchingSnapshot");
351
433
  const isNot = utils.flag(this, "negate");
352
434
  if (isNot) {
353
435
  throw new Error(
@@ -1,4 +1,4 @@
1
- import { I as InlineConfig } from './reporters.anwo7Y6a.js';
1
+ import { I as InlineConfig } from './reporters.D7Jzd9GS.js';
2
2
 
3
3
  type VitestInlineConfig = InlineConfig;
4
4
  declare module 'vite' {
@@ -116,6 +116,9 @@ class CommonjsExecutor {
116
116
  // @ts-expect-error not typed
117
117
  static globalPaths = Module.globalPaths;
118
118
  static isBuiltin = Module.isBuiltin;
119
+ static constants = Module.constants;
120
+ static enableCompileCache = Module.enableCompileCache;
121
+ static getCompileCacheDir = Module.getCompileCacheDir;
119
122
  static Module = Module$1;
120
123
  };
121
124
  this.extensions[".js"] = this.requireJs;
@@ -1,5 +1,5 @@
1
1
  import { MessagePort } from 'node:worker_threads';
2
- import { C as ContextRPC } from './worker.BAlI9hII.js';
2
+ import { C as ContextRPC } from './worker.tN5KGIih.js';
3
3
 
4
4
  interface WorkerContext extends ContextRPC {
5
5
  port: MessagePort;
@@ -1,6 +1,6 @@
1
1
  import { File, TaskResultPack, CancelReason, Task } from '@vitest/runner';
2
2
  import { ViteNodeResolveId, ModuleCacheMap } from 'vite-node';
3
- import { S as SerializedConfig } from './config.Crbj2GAb.js';
3
+ import { S as SerializedConfig } from './config.Cy0C388Z.js';
4
4
  import { T as TransformMode, U as UserConsoleLog, A as AfterSuiteRunMeta, E as Environment } from './environment.LoooBwUu.js';
5
5
  import { SnapshotResult } from '@vitest/snapshot';
6
6
 
@@ -150,6 +150,7 @@ interface WorkerGlobalState {
150
150
  environment: number;
151
151
  prepare: number;
152
152
  };
153
+ onFilterStackTrace?: (trace: string) => string;
153
154
  }
154
155
 
155
156
  export type { BirpcOptions as B, ContextRPC as C, RuntimeRPC as R, WorkerGlobalState as W, BirpcReturn as a, WorkerRPC as b, RunnerRPC as c, ContextTestEnvironment as d, ResolveIdFunction as e };
package/dist/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- import { c as createCLI } from './chunks/cac.DrfPaMvZ.js';
1
+ import { c as createCLI } from './chunks/cac.DPEe9SCx.js';
2
2
  import '@vitest/utils';
3
3
  import 'events';
4
4
  import 'pathe';
package/dist/config.d.ts CHANGED
@@ -1,25 +1,25 @@
1
1
  import { UserConfig as UserConfig$1, ConfigEnv } from 'vite';
2
2
  export { ConfigEnv, Plugin, UserConfig as ViteUserConfig, mergeConfig } from 'vite';
3
- import { R as ResolvedCoverageOptions, c as CoverageV8Options, U as UserWorkspaceConfig, d as UserProjectConfigFn, e as UserProjectConfigExport, W as WorkspaceProjectConfiguration } from './chunks/reporters.anwo7Y6a.js';
4
- import './chunks/vite.BdBj-UWY.js';
5
- import './chunks/config.Crbj2GAb.js';
6
- import '@vitest/pretty-format';
3
+ import { R as ResolvedCoverageOptions, c as CoverageV8Options, U as UserWorkspaceConfig, d as UserProjectConfigFn, e as UserProjectConfigExport, W as WorkspaceProjectConfiguration } from './chunks/reporters.D7Jzd9GS.js';
4
+ import './chunks/vite.C-N5BBZe.js';
7
5
  import '@vitest/runner';
6
+ import './chunks/environment.LoooBwUu.js';
7
+ import 'node:stream';
8
+ import '@vitest/utils';
9
+ import './chunks/config.Cy0C388Z.js';
10
+ import '@vitest/pretty-format';
8
11
  import '@vitest/snapshot';
9
12
  import '@vitest/snapshot/environment';
10
13
  import 'vite-node';
11
14
  import 'chai';
12
- import './chunks/environment.LoooBwUu.js';
13
- import 'node:stream';
14
- import '@vitest/utils';
15
15
  import '@vitest/utils/source-map';
16
16
  import 'vite-node/client';
17
17
  import 'vite-node/server';
18
- import '@vitest/snapshot/manager';
19
- import 'node:fs';
20
18
  import './chunks/benchmark.geERunq4.js';
21
19
  import '@vitest/runner/utils';
22
20
  import 'tinybench';
21
+ import '@vitest/snapshot/manager';
22
+ import 'node:fs';
23
23
 
24
24
  declare const defaultBrowserPort = 63315;
25
25
  declare const extraInlineDeps: RegExp[];
@@ -1,23 +1,23 @@
1
1
  import * as vite from 'vite';
2
- import { R as ResolvedCoverageOptions, V as Vitest, a as ReportContext } from './chunks/reporters.anwo7Y6a.js';
2
+ import { R as ResolvedCoverageOptions, V as Vitest, a as ReportContext } from './chunks/reporters.D7Jzd9GS.js';
3
3
  import { A as AfterSuiteRunMeta } from './chunks/environment.LoooBwUu.js';
4
- import './chunks/config.Crbj2GAb.js';
5
- import '@vitest/pretty-format';
6
4
  import '@vitest/runner';
5
+ import 'node:stream';
6
+ import '@vitest/utils';
7
+ import './chunks/config.Cy0C388Z.js';
8
+ import '@vitest/pretty-format';
7
9
  import '@vitest/snapshot';
8
10
  import '@vitest/snapshot/environment';
9
11
  import 'vite-node';
10
12
  import 'chai';
11
- import 'node:stream';
12
- import '@vitest/utils';
13
13
  import '@vitest/utils/source-map';
14
14
  import 'vite-node/client';
15
15
  import 'vite-node/server';
16
- import '@vitest/snapshot/manager';
17
- import 'node:fs';
18
16
  import './chunks/benchmark.geERunq4.js';
19
17
  import '@vitest/runner/utils';
20
18
  import 'tinybench';
19
+ import '@vitest/snapshot/manager';
20
+ import 'node:fs';
21
21
 
22
22
  interface CoverageSummaryData {
23
23
  lines: Totals;
package/dist/coverage.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { existsSync, promises, readdirSync, writeFileSync } from 'node:fs';
2
- import { c as coverageConfigDefaults, r as resolveCoverageReporters, m as mm } from './chunks/resolveConfig.DPmbhVlP.js';
2
+ import { c as coverageConfigDefaults, r as resolveCoverageReporters, m as mm } from './chunks/resolveConfig.RxKrDli4.js';
3
3
  import { resolve, relative } from 'pathe';
4
4
  import c from 'tinyrainbow';
5
5
  import '@vitest/utils';
@@ -1,2 +1,2 @@
1
- export { e as builtinEnvironments, p as populateGlobal } from './chunks/index.BMoXz_-n.js';
1
+ export { e as builtinEnvironments, p as populateGlobal } from './chunks/index.K90BXFOx.js';
2
2
  import 'node:console';
package/dist/execute.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { ViteNodeRunnerOptions } from 'vite-node';
2
2
  import { ViteNodeRunner } from 'vite-node/client';
3
- import { R as RuntimeRPC, W as WorkerGlobalState } from './chunks/worker.BAlI9hII.js';
3
+ import { R as RuntimeRPC, W as WorkerGlobalState } from './chunks/worker.tN5KGIih.js';
4
4
  import vm from 'node:vm';
5
5
  import * as _vitest_mocker from '@vitest/mocker';
6
6
  import { MockedModuleType } from '@vitest/mocker';
7
7
  import { P as PendingSuiteMock, b as MockFactory, a as MockOptions } from './chunks/mocker.cRtM890J.js';
8
8
  import '@vitest/runner';
9
- import './chunks/config.Crbj2GAb.js';
9
+ import './chunks/config.Cy0C388Z.js';
10
10
  import '@vitest/pretty-format';
11
11
  import '@vitest/snapshot';
12
12
  import '@vitest/snapshot/environment';
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { TaskResultPack as TaskResultPack$1, File as File$1, TaskPopulated, Suite as Suite$1, Test as Test$1, Custom as Custom$1, Task as Task$1, TaskBase as TaskBase$1, TaskResult as TaskResult$1, DoneCallback as DoneCallback$1, RuntimeContext as RuntimeContext$1, SuiteHooks as SuiteHooks$1, SequenceHooks as SequenceHooks$1, SequenceSetupFiles as SequenceSetupFiles$1 } from '@vitest/runner';
2
2
  export { CancelReason, ExtendedContext, HookCleanupCallback, HookListener, OnTestFailedHandler, OnTestFinishedHandler, RunMode, Custom as RunnerCustomCase, Task as RunnerTask, TaskBase as RunnerTaskBase, TaskResult as RunnerTaskResult, TaskResultPack as RunnerTaskResultPack, Test as RunnerTestCase, File as RunnerTestFile, Suite as RunnerTestSuite, SuiteAPI, SuiteCollector, SuiteFactory, TaskContext, TaskCustomOptions, TaskMeta, TaskState, TestAPI, TestContext, TestFunction, TestOptions, afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
3
- import { f as VitestEnvironment$1, S as SerializedTestSpecification, g as RawErrsMap$1, T as TscErrorInfo$1, h as CollectLineNumbers$1, i as CollectLines$1, j as RootAndTarget$1, k as Context$1, C as CoverageProvider$1, a as ReportContext$1, b as CoverageProviderModule$1, l as CoverageReporter$1, m as CoverageProviderName, n as CoverageOptions$1, R as ResolvedCoverageOptions$1, B as BaseCoverageOptions$1, o as CoverageIstanbulOptions$1, c as CoverageV8Options$1, p as CustomProviderOptions$1, q as Reporter$1, V as Vitest$1, r as BrowserScript$1, s as BrowserConfigOptions$1, t as BuiltinEnvironment$1, P as Pool$1, u as PoolOptions$1, v as CSSModuleScopeStrategy$1, A as ApiConfig$1, w as VitestRunMode$1, D as DepsOptimizationOptions$1, x as TransformModePatterns$1, I as InlineConfig$1, y as TypecheckConfig$1, z as UserConfig$1, E as ResolvedConfig$1, F as ProjectConfig$1, U as UserWorkspaceConfig$1, G as BenchmarkUserOptions$1 } from './chunks/reporters.anwo7Y6a.js';
4
- import { W as WorkerContext$1 } from './chunks/worker.DHnGaO2M.js';
3
+ import { f as VitestEnvironment$1, S as SerializedTestSpecification, g as RawErrsMap$1, T as TscErrorInfo$1, h as CollectLineNumbers$1, i as CollectLines$1, j as RootAndTarget$1, k as Context$1, C as CoverageProvider$1, a as ReportContext$1, b as CoverageProviderModule$1, l as CoverageReporter$1, m as CoverageProviderName, n as CoverageOptions$1, R as ResolvedCoverageOptions$1, B as BaseCoverageOptions$1, o as CoverageIstanbulOptions$1, c as CoverageV8Options$1, p as CustomProviderOptions$1, q as Reporter$1, V as Vitest$1, r as BrowserScript$1, s as BrowserConfigOptions$1, t as BuiltinEnvironment$1, P as Pool$1, u as PoolOptions$1, v as CSSModuleScopeStrategy$1, A as ApiConfig$1, w as VitestRunMode$1, D as DepsOptimizationOptions$1, x as TransformModePatterns$1, I as InlineConfig$1, y as TypecheckConfig$1, z as UserConfig$1, E as ResolvedConfig$1, F as ProjectConfig$1, U as UserWorkspaceConfig$1, G as BenchmarkUserOptions$1 } from './chunks/reporters.D7Jzd9GS.js';
4
+ import { W as WorkerContext$1 } from './chunks/worker.B9FxPCaC.js';
5
5
  import { U as UserConsoleLog, M as ModuleGraphData, b as Awaitable$1, P as ProvidedContext, N as Nullable$1, c as Arrayable$1, d as ArgumentsType$1, e as MutableArray$1, C as Constructable$1, O as OnServerRestartHandler$1, a as EnvironmentReturn$1, V as VmEnvironmentReturn$1, E as Environment$1, R as ResolvedTestEnvironment$1, J as JSDOMOptions$1, H as HappyDOMOptions$1, f as EnvironmentOptions$1 } from './chunks/environment.LoooBwUu.js';
6
6
  export { A as AfterSuiteRunMeta, g as ModuleCache } from './chunks/environment.LoooBwUu.js';
7
- import { a as BirpcReturn, b as WorkerRPC$1 } from './chunks/worker.BAlI9hII.js';
8
- export { C as ContextRPC, d as ContextTestEnvironment, e as ResolveIdFunction, c as RunnerRPC, R as RuntimeRPC, W as WorkerGlobalState } from './chunks/worker.BAlI9hII.js';
9
- import './chunks/vite.BdBj-UWY.js';
7
+ import { a as BirpcReturn, b as WorkerRPC$1 } from './chunks/worker.tN5KGIih.js';
8
+ export { C as ContextRPC, d as ContextTestEnvironment, e as ResolveIdFunction, c as RunnerRPC, R as RuntimeRPC, W as WorkerGlobalState } from './chunks/worker.tN5KGIih.js';
9
+ import './chunks/vite.C-N5BBZe.js';
10
10
  import { PromisifyAssertion, Tester, ExpectStatic } from '@vitest/expect';
11
11
  export { Assertion, AsymmetricMatchersContaining, ExpectPollOptions, ExpectStatic, JestAssertion } from '@vitest/expect';
12
12
  import { Plugin } from '@vitest/pretty-format';
@@ -14,8 +14,8 @@ import { SnapshotState } from '@vitest/snapshot';
14
14
  export { SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotSerializer, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, UncheckedSnapshot } from '@vitest/snapshot';
15
15
  import { B as BenchmarkResult } from './chunks/benchmark.geERunq4.js';
16
16
  export { a as BenchFunction, b as Benchmark, c as BenchmarkAPI } from './chunks/benchmark.geERunq4.js';
17
- import { S as SerializedConfig, F as FakeTimerInstallOpts, R as RuntimeOptions } from './chunks/config.Crbj2GAb.js';
18
- export { b as RuntimeConfig, a as SerializedCoverageConfig } from './chunks/config.Crbj2GAb.js';
17
+ import { S as SerializedConfig, F as FakeTimerInstallOpts, R as RuntimeOptions } from './chunks/config.Cy0C388Z.js';
18
+ export { b as RuntimeConfig, a as SerializedCoverageConfig } from './chunks/config.Cy0C388Z.js';
19
19
  import { spyOn, fn, MaybeMockedDeep, MaybeMocked, MaybePartiallyMocked, MaybePartiallyMockedDeep, MockInstance } from '@vitest/spy';
20
20
  export { Mock, MockContext, MockInstance, Mocked, MockedClass, MockedFunction, MockedObject } from '@vitest/spy';
21
21
  import { M as MockFactoryWithHelper, a as MockOptions } from './chunks/mocker.cRtM890J.js';
@@ -27,9 +27,9 @@ import * as chai from 'chai';
27
27
  export { chai };
28
28
  export { assert, should } from 'chai';
29
29
  export { Bench as BenchFactory, Options as BenchOptions, Task as BenchTask, TaskResult as BenchTaskResult } from 'tinybench';
30
+ import 'node:stream';
30
31
  import 'vite';
31
32
  import 'vite-node';
32
- import 'node:stream';
33
33
  import '@vitest/utils/source-map';
34
34
  import 'vite-node/client';
35
35
  import 'vite-node/server';
@@ -85,8 +85,37 @@ declare module '@vitest/expect' {
85
85
  matchSnapshot: SnapshotMatcher<T>;
86
86
  toMatchSnapshot: SnapshotMatcher<T>;
87
87
  toMatchInlineSnapshot: InlineSnapshotMatcher<T>;
88
+ /**
89
+ * Checks that an error thrown by a function matches a previously recorded snapshot.
90
+ *
91
+ * @param message - Optional custom error message.
92
+ *
93
+ * @example
94
+ * expect(functionWithError).toThrowErrorMatchingSnapshot();
95
+ */
88
96
  toThrowErrorMatchingSnapshot: (message?: string) => void;
97
+ /**
98
+ * Checks that an error thrown by a function matches an inline snapshot within the test file.
99
+ * Useful for keeping snapshots close to the test code.
100
+ *
101
+ * @param snapshot - Optional inline snapshot string to match.
102
+ * @param message - Optional custom error message.
103
+ *
104
+ * @example
105
+ * const throwError = () => { throw new Error('Error occurred') };
106
+ * expect(throwError).toThrowErrorMatchingInlineSnapshot(`"Error occurred"`);
107
+ */
89
108
  toThrowErrorMatchingInlineSnapshot: (snapshot?: string, message?: string) => void;
109
+ /**
110
+ * Compares the received value to a snapshot saved in a specified file.
111
+ * Useful for cases where snapshot content is large or needs to be shared across tests.
112
+ *
113
+ * @param filepath - Path to the snapshot file.
114
+ * @param message - Optional custom error message.
115
+ *
116
+ * @example
117
+ * await expect(largeData).toMatchFileSnapshot('path/to/snapshot.json');
118
+ */
90
119
  toMatchFileSnapshot: (filepath: string, message?: string) => Promise<void>;
91
120
  }
92
121
  }
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- export { c as createExpect, a as expect, v as vi, b as vitest } from './chunks/vi.JMQoNY_Z.js';
2
- export { b as assertType, g as getRunningMode, i as inject, a as isWatchMode } from './chunks/index.Dqe5k2Rk.js';
1
+ export { c as createExpect, a as expect, v as vi, b as vitest } from './chunks/vi.DgezovHB.js';
2
+ export { b as assertType, g as getRunningMode, i as inject, a as isWatchMode } from './chunks/index.ckWaX2gY.js';
3
3
  export { i as isFirstRun, a as runOnce } from './chunks/run-once.2ogXb3JV.js';
4
4
  export { b as bench } from './chunks/benchmark.Cdu9hjj4.js';
5
5
  export { expectTypeOf } from 'expect-type';