vitest 4.1.3 → 4.1.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 (41) hide show
  1. package/dist/browser.d.ts +2 -2
  2. package/dist/browser.js +1 -1
  3. package/dist/chunks/{base.C3wvLFNM.js → base.RR7zL1h0.js} +4 -4
  4. package/dist/chunks/{browser.d.C0zGu1u9.d.ts → browser.d.BcoexmFG.d.ts} +2 -2
  5. package/dist/chunks/{cac.Bb7YBzMA.js → cac.DJJmV0dT.js} +6 -6
  6. package/dist/chunks/{cli-api.CaPRsymo.js → cli-api.Cjt90eJu.js} +28 -15
  7. package/dist/chunks/{config.d.ChUh6-ad.d.ts → config.d.A1h_Y6Jt.d.ts} +6 -1
  8. package/dist/chunks/{coverage.CwUlQe0s.js → coverage.DM_a_rWm.js} +25 -4
  9. package/dist/chunks/{global.d.D74z04P1.d.ts → global.d.DVsSRdQ5.d.ts} +1 -1
  10. package/dist/chunks/{globals.7B-4LHAF.js → globals.Dj1TGiMC.js} +2 -2
  11. package/dist/chunks/{index.Cj9kDiDi.js → index.DXx9Dtk7.js} +2 -2
  12. package/dist/chunks/{index.4L3g53iW.js → index.DdgEv5B1.js} +1 -1
  13. package/dist/chunks/{index.DICur-LY.js → index.UpGiHP7g.js} +36 -27
  14. package/dist/chunks/{plugin.d.BssAumYw.d.ts → plugin.d.BM2TCi12.d.ts} +1 -1
  15. package/dist/chunks/{reporters.d.yJ2fBir5.d.ts → reporters.d.CEnv6XRv.d.ts} +79 -20
  16. package/dist/chunks/{rpc.d.BFMWpdph.d.ts → rpc.d.B_8sPU0w.d.ts} +2 -44
  17. package/dist/chunks/{setup-common.NdrZGMhw.js → setup-common.DYx3LtFI.js} +1 -1
  18. package/dist/chunks/{test.BmQO5GaM.js → test.DNmyFkvJ.js} +107 -20
  19. package/dist/chunks/traces.d.D2T_R8rx.d.ts +60 -0
  20. package/dist/chunks/{utils.DK8FXp4T.js → utils.BS4fH3nR.js} +1 -1
  21. package/dist/chunks/{worker.d.CckNUvI5.d.ts → worker.d.ZpHpO4yb.d.ts} +2 -2
  22. package/dist/cli.js +1 -1
  23. package/dist/config.d.ts +10 -10
  24. package/dist/coverage.d.ts +8 -7
  25. package/dist/coverage.js +2 -1
  26. package/dist/index.d.ts +36 -14
  27. package/dist/index.js +2 -2
  28. package/dist/module-evaluator.d.ts +2 -2
  29. package/dist/node.d.ts +10 -10
  30. package/dist/node.js +7 -7
  31. package/dist/reporters.d.ts +8 -8
  32. package/dist/reporters.js +3 -3
  33. package/dist/runners.d.ts +2 -2
  34. package/dist/runners.js +1 -1
  35. package/dist/worker.d.ts +4 -4
  36. package/dist/worker.js +5 -5
  37. package/dist/workers/forks.js +5 -5
  38. package/dist/workers/runVmTests.js +4 -4
  39. package/dist/workers/threads.js +5 -5
  40. package/package.json +14 -14
  41. package/dist/chunks/traces.d.402V_yFI.d.ts +0 -18
@@ -1,17 +1,16 @@
1
1
  import { TaskMeta, Suite, File, SerializableRetry, TestAnnotation, TestArtifact, ImportDuration, Test, Task, TaskResultPack, FileSpecification, CancelReason, SequenceSetupFiles, SequenceHooks, TestTagDefinition } from '@vitest/runner';
2
2
  import { TestError, SerializedError, Arrayable, ParsedStack, Awaitable } from '@vitest/utils';
3
- import { A as AfterSuiteRunMeta, U as UserConsoleLog, b as AsyncLeak, P as ProvidedContext, L as LabelColor } from './rpc.d.BFMWpdph.js';
3
+ import { a as AfterSuiteRunMeta, U as UserConsoleLog, A as AsyncLeak, P as ProvidedContext, O as OTELCarrier, L as LabelColor } from './traces.d.D2T_R8rx.js';
4
4
  import { Writable } from 'node:stream';
5
5
  import { DevEnvironment, TransformResult as TransformResult$1, ViteDevServer, Plugin, UserConfig as UserConfig$1, DepOptimizationConfig, ServerOptions, ConfigEnv, AliasOptions } from 'vite';
6
- import { S as SerializedTestSpecification, c as SourceModuleDiagnostic, B as BrowserTesterOptions } from './browser.d.C0zGu1u9.js';
7
- import { B as BrowserTraceViewMode, S as SerializedConfig, F as FakeTimerInstallOpts } from './config.d.ChUh6-ad.js';
6
+ import { b as SerializedRootConfig, B as BrowserTraceViewMode, S as SerializedConfig, F as FakeTimerInstallOpts } from './config.d.A1h_Y6Jt.js';
7
+ import { S as SerializedTestSpecification, c as SourceModuleDiagnostic, B as BrowserTesterOptions } from './browser.d.BcoexmFG.js';
8
8
  import { PrettyFormatOptions } from '@vitest/pretty-format';
9
9
  import { SnapshotSummary, SnapshotStateOptions } from '@vitest/snapshot';
10
10
  import { SerializedDiffOptions } from '@vitest/utils/diff';
11
11
  import { chai } from '@vitest/expect';
12
12
  import { happyDomTypes, jsdomTypes } from 'vitest/optional-types.js';
13
- import { c as ContextTestEnvironment, d as WorkerExecuteContext, e as WorkerTestEnvironment } from './worker.d.CckNUvI5.js';
14
- import { O as OTELCarrier } from './traces.d.402V_yFI.js';
13
+ import { c as ContextTestEnvironment, d as WorkerExecuteContext, e as WorkerTestEnvironment } from './worker.d.ZpHpO4yb.js';
15
14
  import { B as BenchmarkResult } from './benchmark.d.DAaHLpsq.js';
16
15
  import { MockedModule } from '@vitest/mocker';
17
16
  import { StackTraceParserOptions } from '@vitest/utils/source-map';
@@ -98,19 +97,19 @@ declare class TestSpecification {
98
97
  /**
99
98
  * Line numbers of the test locations to run.
100
99
  */
101
- readonly testLines: number[] | undefined;
100
+ testLines: number[] | undefined;
102
101
  /**
103
102
  * Regular expression pattern to filter test names.
104
103
  */
105
- readonly testNamePattern: RegExp | undefined;
104
+ testNamePattern: RegExp | undefined;
106
105
  /**
107
106
  * The ids of tasks inside of this specification to run.
108
107
  */
109
- readonly testIds: string[] | undefined;
108
+ testIds: string[] | undefined;
110
109
  /**
111
110
  * The tags of tests to run.
112
111
  */
113
- readonly testTagsFilter: string[] | undefined;
112
+ testTagsFilter: string[] | undefined;
114
113
  /**
115
114
  * Test module associated with the specification. This will be `undefined` if tests have not been run yet.
116
115
  */
@@ -827,6 +826,33 @@ interface CoverageOptions {
827
826
  */
828
827
  ignoreClassMethods?: string[];
829
828
  /**
829
+ * Custom instrumenter factory to use instead of the default `istanbul-lib-instrument`.
830
+ *
831
+ * The factory receives the same runtime coverage options Vitest passes to its
832
+ * built-in Istanbul instrumenter and must return an object implementing the
833
+ * `CoverageInstrumenter` interface.
834
+ *
835
+ * This allows using faster instrumenters (e.g., oxc-coverage-instrument, SWC) while
836
+ * keeping the Istanbul coverage pipeline for collection, merging, and reporting.
837
+ *
838
+ * @example
839
+ * ```ts
840
+ * import { defineConfig } from 'vitest/config'
841
+ * import { createOxcInstrumenter } from 'oxc-coverage-instrument/vitest'
842
+ *
843
+ * export default defineConfig({
844
+ * test: {
845
+ * coverage: {
846
+ * provider: 'istanbul',
847
+ * instrumenter: options => createOxcInstrumenter(options),
848
+ * }
849
+ * }
850
+ * })
851
+ *
852
+ * @experimental
853
+ */
854
+ instrumenter?: (options: InstrumenterOptions) => CoverageInstrumenter;
855
+ /**
830
856
  * Directory of HTML coverage output to be served in UI mode and HTML reporter.
831
857
  * This is automatically configured for builtin reporter with html output (`html`, `html-spa`, and `lcov` reporters).
832
858
  * Use this option to override with custom coverage reporting location.
@@ -863,6 +889,34 @@ interface Thresholds {
863
889
  /** Thresholds for lines */
864
890
  lines?: number;
865
891
  }
892
+ /**
893
+ * Options passed to the custom instrumenter factory.
894
+ */
895
+ interface InstrumenterOptions {
896
+ /** Global variable name that Vitest uses to store coverage data at runtime. */
897
+ coverageVariable: string;
898
+ /** Global scope where the coverage variable is attached at runtime. */
899
+ coverageGlobalScope: string;
900
+ /** Whether the coverage global scope should be resolved through an evaluated function. */
901
+ coverageGlobalScopeFunc: boolean;
902
+ /** Class method names to exclude from function coverage. */
903
+ ignoreClassMethods: string[];
904
+ }
905
+ /**
906
+ * Interface for custom coverage instrumenters.
907
+ *
908
+ * Matches the subset of istanbul-lib-instrument's `Instrumenter` that Vitest
909
+ * actually uses. Implement this to plug in a faster instrumenter while keeping
910
+ * the Istanbul coverage pipeline for collection, merging, and reporting.
911
+ */
912
+ interface CoverageInstrumenter {
913
+ /** Instrument source code synchronously. Returns the instrumented code string. */
914
+ instrumentSync: (code: string, filename: string, inputSourceMap?: any) => string;
915
+ /** Get the source map of the last instrumented file. */
916
+ lastSourceMap: () => any;
917
+ /** Get the Istanbul-compatible file coverage object of the last instrumented file. */
918
+ lastFileCoverage: () => any;
919
+ }
866
920
  /** @deprecated Use `CoverageOptions` instead */
867
921
  interface CoverageV8Options extends CoverageOptions {}
868
922
  /** @deprecated Use `CoverageOptions` instead */
@@ -1272,6 +1326,7 @@ declare class Vitest {
1272
1326
  * Return project that has the root (or "global") config.
1273
1327
  */
1274
1328
  getRootProject(): TestProject;
1329
+ get serializedRootConfig(): SerializedRootConfig;
1275
1330
  getProjectByName(name: string): TestProject;
1276
1331
  /**
1277
1332
  * Import a file using Vite module runner. The file will be transformed by Vite and executed in a separate context.
@@ -2268,6 +2323,8 @@ interface JsonTestResults {
2268
2323
  }
2269
2324
  interface JsonOptions {
2270
2325
  outputFile?: string;
2326
+ /** @experimental */
2327
+ filterMeta?: (key: string, value: unknown) => unknown;
2271
2328
  }
2272
2329
  declare class JsonReporter implements Reporter {
2273
2330
  start: number;
@@ -2328,14 +2385,6 @@ declare class JUnitReporter implements Reporter {
2328
2385
  onTestRunEnd(testModules: ReadonlyArray<TestModule>): Promise<void>;
2329
2386
  }
2330
2387
 
2331
- declare class AgentReporter extends DefaultReporter {
2332
- renderSucceed: boolean;
2333
- constructor(options?: DefaultReporterOptions);
2334
- onTestRunStart(specifications: ReadonlyArray<TestSpecification>): void;
2335
- protected printTestModule(testModule: TestModule): void;
2336
- protected printTestCase(moduleState: TestModuleState, test: TestCase): void;
2337
- }
2338
-
2339
2388
  declare class DotReporter extends BaseReporter {
2340
2389
  private renderer?;
2341
2390
  private tests;
@@ -2358,6 +2407,14 @@ declare class HangingProcessReporter implements Reporter {
2358
2407
  onProcessTimeout(): void;
2359
2408
  }
2360
2409
 
2410
+ declare class MinimalReporter extends DefaultReporter {
2411
+ renderSucceed: boolean;
2412
+ constructor(options?: DefaultReporterOptions);
2413
+ onTestRunStart(specifications: ReadonlyArray<TestSpecification>): void;
2414
+ protected printTestModule(testModule: TestModule): void;
2415
+ protected printTestCase(moduleState: TestModuleState, test: TestCase): void;
2416
+ }
2417
+
2361
2418
  declare class TapReporter implements Reporter {
2362
2419
  protected ctx: Vitest;
2363
2420
  private logger;
@@ -2421,7 +2478,8 @@ type BenchmarkBuiltinReporters = keyof typeof BenchmarkReportsMap;
2421
2478
 
2422
2479
  declare const ReportersMap: {
2423
2480
  default: typeof DefaultReporter;
2424
- agent: typeof AgentReporter;
2481
+ agent: typeof MinimalReporter;
2482
+ minimal: typeof MinimalReporter;
2425
2483
  blob: typeof BlobReporter;
2426
2484
  verbose: typeof VerboseReporter;
2427
2485
  dot: typeof DotReporter;
@@ -2436,6 +2494,7 @@ declare const ReportersMap: {
2436
2494
  type BuiltinReporters = keyof typeof ReportersMap;
2437
2495
  interface BuiltinReporterOptions {
2438
2496
  "default": DefaultReporterOptions;
2497
+ "minimal": DefaultReporterOptions;
2439
2498
  "agent": DefaultReporterOptions;
2440
2499
  "verbose": DefaultReporterOptions;
2441
2500
  "dot": BaseOptions;
@@ -3548,5 +3607,5 @@ type TestProjectInlineConfiguration = (UserWorkspaceConfig & {
3548
3607
  });
3549
3608
  type TestProjectConfiguration = string | TestProjectInlineConfiguration | Promise<UserWorkspaceConfig> | UserProjectConfigFn;
3550
3609
 
3551
- export { DefaultReporter as $, Logger as L, TestProject as T, Vitest as V, DotReporter as a1, GithubActionsReporter as a3, HangingProcessReporter as a5, JUnitReporter as a7, TestCollection as aA, TestModule as aC, TestSuite as aN, VerboseBenchmarkReporter as aS, VerboseReporter as aT, VitestPackageInstaller as aV, experimental_getRunnerTask as aY, CoverageMap as aZ, JsonReporter as aa, ReportersMap as ap, TapFlatReporter as aw, TapReporter as ax, TestCase as az, TestSpecification as h, AgentReporter as l, BaseReporter as m, BenchmarkReporter as o, BenchmarkReportsMap as p };
3552
- export type { ApiConfig as A, BaseCoverageOptions as B, CoverageOptions as C, BrowserScript as D, BrowserServerFactory as E, FieldsWithDefaultValues as F, BrowserServerOptions as G, BrowserServerState as H, InlineConfig as I, BrowserServerStateSession as J, BuiltinEnvironment as K, BuiltinReporterOptions as M, BuiltinReporters as N, CSSModuleScopeStrategy as O, PoolWorker as P, CoverageIstanbulOptions as Q, ResolvedConfig as R, CoverageProvider as S, UserWorkspaceConfig as U, WatcherTriggerPattern as W, CoverageProviderModule as X, CoverageReporter as Y, CoverageV8Options as Z, CustomProviderOptions as _, TestProjectConfiguration as a, DepsOptimizationOptions as a0, EnvironmentOptions as a2, HTMLOptions as a4, JUnitOptions as a6, JsonAssertionResult as a8, JsonOptions as a9, TestDiagnostic as aB, TestModuleState as aD, TestResult as aE, TestResultFailed as aF, TestResultPassed as aG, TestResultSkipped as aH, TestRunEndReason as aI, TestRunResult as aJ, TestSequencerConstructor as aK, TestSpecificationOptions as aL, TestState as aM, TestSuiteState as aO, ToMatchScreenshotComparators as aP, ToMatchScreenshotOptions as aQ, TypecheckConfig as aR, VitestEnvironment as aU, WorkerResponse as aW, _BrowserNames as aX, JsonTestResult as ab, JsonTestResults as ac, ModuleDiagnostic as ad, OnServerRestartHandler as ae, OnTestsRerunHandler as af, ParentProjectBrowser as ag, Pool as ah, PoolRunnerInitializer as ai, PoolTask as aj, ProjectBrowser as ak, ProjectConfig as al, ReportContext as am, ReportedHookContext as an, Reporter as ao, ResolveSnapshotPathHandler as aq, ResolveSnapshotPathHandlerContext as ar, ResolvedBrowserOptions as as, ResolvedCoverageOptions as at, ResolvedProjectConfig as au, SerializedTestProject as av, TaskOptions as ay, UserProjectConfigFn as b, UserProjectConfigExport as c, TestProjectInlineConfiguration as d, UserConfig as e, VitestRunMode as f, VitestOptions as g, PoolOptions as i, WorkerRequest as j, TestSequencer as k, BenchmarkBuiltinReporters as n, BenchmarkUserOptions as q, BrowserBuiltinProvider as r, BrowserCommand as s, BrowserCommandContext as t, BrowserConfigOptions as u, BrowserInstanceOption as v, BrowserModuleMocker as w, BrowserOrchestrator as x, BrowserProvider as y, BrowserProviderOption as z };
3610
+ export { Logger as L, MinimalReporter as M, TestProject as T, Vitest as V, CoverageMap as a$, DefaultReporter as a0, DotReporter as a2, GithubActionsReporter as a4, HangingProcessReporter as a6, JUnitReporter as a9, TestCase as aB, TestCollection as aC, TestModule as aE, TestSuite as aP, VerboseBenchmarkReporter as aU, VerboseReporter as aV, VitestPackageInstaller as aX, experimental_getRunnerTask as a_, JsonReporter as ac, ReportersMap as ar, TapFlatReporter as ay, TapReporter as az, TestSpecification as h, BaseReporter as l, BenchmarkReporter as n, BenchmarkReportsMap as o };
3611
+ export type { CustomProviderOptions as $, ApiConfig as A, BaseCoverageOptions as B, CoverageOptions as C, BrowserServerFactory as D, BrowserServerOptions as E, FieldsWithDefaultValues as F, BrowserServerState as G, BrowserServerStateSession as H, InlineConfig as I, BuiltinEnvironment as J, BuiltinReporterOptions as K, BuiltinReporters as N, CSSModuleScopeStrategy as O, PoolWorker as P, CoverageInstrumenter as Q, ResolvedConfig as R, CoverageIstanbulOptions as S, UserWorkspaceConfig as U, WatcherTriggerPattern as W, CoverageProvider as X, CoverageProviderModule as Y, CoverageReporter as Z, CoverageV8Options as _, TestProjectConfiguration as a, DepsOptimizationOptions as a1, EnvironmentOptions as a3, HTMLOptions as a5, InstrumenterOptions as a7, JUnitOptions as a8, TaskOptions as aA, TestDiagnostic as aD, TestModuleState as aF, TestResult as aG, TestResultFailed as aH, TestResultPassed as aI, TestResultSkipped as aJ, TestRunEndReason as aK, TestRunResult as aL, TestSequencerConstructor as aM, TestSpecificationOptions as aN, TestState as aO, TestSuiteState as aQ, ToMatchScreenshotComparators as aR, ToMatchScreenshotOptions as aS, TypecheckConfig as aT, VitestEnvironment as aW, WorkerResponse as aY, _BrowserNames as aZ, JsonAssertionResult as aa, JsonOptions as ab, JsonTestResult as ad, JsonTestResults as ae, ModuleDiagnostic as af, OnServerRestartHandler as ag, OnTestsRerunHandler as ah, ParentProjectBrowser as ai, Pool as aj, PoolRunnerInitializer as ak, PoolTask as al, ProjectBrowser as am, ProjectConfig as an, ReportContext as ao, ReportedHookContext as ap, Reporter as aq, ResolveSnapshotPathHandler as as, ResolveSnapshotPathHandlerContext as at, ResolvedBrowserOptions as au, ResolvedCoverageOptions as av, ResolvedProjectConfig as aw, SerializedTestProject as ax, UserProjectConfigFn as b, UserProjectConfigExport as c, TestProjectInlineConfiguration as d, UserConfig as e, VitestRunMode as f, VitestOptions as g, PoolOptions as i, WorkerRequest as j, TestSequencer as k, BenchmarkBuiltinReporters as m, BenchmarkUserOptions as p, BrowserBuiltinProvider as q, BrowserCommand as r, BrowserCommandContext as s, BrowserConfigOptions as t, BrowserInstanceOption as u, BrowserModuleMocker as v, BrowserOrchestrator as w, BrowserProvider as x, BrowserProviderOption as y, BrowserScript as z };
@@ -1,49 +1,7 @@
1
1
  import { File, TestArtifact, TaskResultPack, TaskEventPack, CancelReason } from '@vitest/runner';
2
2
  import { SnapshotResult } from '@vitest/snapshot';
3
3
  import { FetchFunctionOptions, FetchResult } from 'vite/module-runner';
4
- import { O as OTELCarrier } from './traces.d.402V_yFI.js';
5
-
6
- interface AfterSuiteRunMeta {
7
- coverage?: unknown;
8
- testFiles: string[];
9
- environment: string;
10
- projectName?: string;
11
- }
12
- interface UserConsoleLog {
13
- content: string;
14
- origin?: string;
15
- browser?: boolean;
16
- type: "stdout" | "stderr";
17
- taskId?: string;
18
- time: number;
19
- size: number;
20
- }
21
- interface ModuleGraphData {
22
- graph: Record<string, string[]>;
23
- externalized: string[];
24
- inlined: string[];
25
- }
26
- interface ProvidedContext {}
27
- interface ResolveFunctionResult {
28
- id: string;
29
- file: string;
30
- url: string;
31
- }
32
- interface FetchCachedFileSystemResult {
33
- cached: true;
34
- tmp: string;
35
- id: string;
36
- file: string | null;
37
- url: string;
38
- invalidate: boolean;
39
- }
40
- type LabelColor = "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white";
41
- interface AsyncLeak {
42
- filename: string;
43
- projectName: string;
44
- stack: string;
45
- type: string;
46
- }
4
+ import { O as OTELCarrier, F as FetchCachedFileSystemResult, R as ResolveFunctionResult, U as UserConsoleLog, A as AsyncLeak, a as AfterSuiteRunMeta } from './traces.d.D2T_R8rx.js';
47
5
 
48
6
  interface RuntimeRPC {
49
7
  fetch: (id: string, importer: string | undefined, environment: string, options?: FetchFunctionOptions, otelCarrier?: OTELCarrier) => Promise<FetchResult | FetchCachedFileSystemResult>;
@@ -69,4 +27,4 @@ interface RunnerRPC {
69
27
  onCancel: (reason: CancelReason) => void;
70
28
  }
71
29
 
72
- export type { AfterSuiteRunMeta as A, LabelColor as L, ModuleGraphData as M, ProvidedContext as P, RuntimeRPC as R, UserConsoleLog as U, RunnerRPC as a, AsyncLeak as b };
30
+ export type { RuntimeRPC as R, RunnerRPC as a };
@@ -26,7 +26,7 @@ async function setupCommonEnv(config) {
26
26
  if (globalSetup) return;
27
27
  globalSetup = true;
28
28
  setSafeTimers();
29
- if (config.globals) (await import('./globals.7B-4LHAF.js')).registerApiGlobally();
29
+ if (config.globals) (await import('./globals.Dj1TGiMC.js')).registerApiGlobally();
30
30
  }
31
31
  function setupDefines(config) {
32
32
  for (const key in config.defines) globalThis[key] = config.defines[key];
@@ -3552,7 +3552,7 @@ function createVitest() {
3552
3552
  waitUntil,
3553
3553
  defineHelper: (fn) => {
3554
3554
  return function __VITEST_HELPER__(...args) {
3555
- const result = fn(...args);
3555
+ const result = fn.apply(this, args);
3556
3556
  if (result && typeof result === "object" && typeof result.then === "function") return (async function __VITEST_HELPER__() {
3557
3557
  return await result;
3558
3558
  })();
@@ -3715,6 +3715,10 @@ function createExpectPoll(expect) {
3715
3715
  // @ts-expect-error private poll access
3716
3716
  const assertion = expect(null, message).withContext({ poll: true });
3717
3717
  fn = fn.bind(assertion);
3718
+ // injected so that domain snapshot can take over poll implementation.
3719
+ chai.util.flag(assertion, "_poll.fn", fn);
3720
+ chai.util.flag(assertion, "_poll.timeout", timeout);
3721
+ chai.util.flag(assertion, "_poll.interval", interval);
3718
3722
  const test = chai.util.flag(assertion, "vitest-test");
3719
3723
  if (!test) throw new Error("expect.poll() must be called inside a test");
3720
3724
  const proxy = new Proxy(assertion, { get(target, key, receiver) {
@@ -3722,17 +3726,50 @@ function createExpectPoll(expect) {
3722
3726
  if (typeof assertionFunction !== "function") return assertionFunction instanceof chai.Assertion ? proxy : assertionFunction;
3723
3727
  if (key === "assert") return assertionFunction;
3724
3728
  if (typeof key === "string" && unsupported.includes(key)) throw new SyntaxError(`expect.poll() is not supported in combination with .${key}(). Use vi.waitFor() if your assertion condition is unstable.`);
3725
- return function(...args) {
3729
+ // Core poll stack-trace trick:
3730
+ // 1. capture STACK_TRACE_ERROR here before entering the async poll loop
3731
+ // 2. when the matcher eventually fails, rethrow via throwWithCause()
3732
+ // so the final error keeps this earlier stack
3733
+ //
3734
+ // For example, when user writes:
3735
+ // await expect.poll(...).toBeSomething()
3736
+ // STACK_TRACE_ERROR.stack would look like
3737
+ // at ...(more internal stacks)...
3738
+ // at __VITEST_POLL_CHAIN__ .../packages/vitest/dist/...
3739
+ // at .../my-file.test.ts:12:3 (this points to `toBeSomething()` callsite in user test file)
3740
+ // Vitest later filters out internal stacks from `vitest/dist`, so the reported errors correctly
3741
+ // points to the user callsite for poll assertion errors.
3742
+ //
3743
+ // Inline snapshots piggyback on the same idea. We pass
3744
+ // STACK_TRACE_ERROR through `chai.util.flag(assertion, 'error', ...)`.
3745
+ // Inline snapshot assertion access the same error stack for
3746
+ // extracting inline snapshot location to validate and update new snapshots.
3747
+ return function __VITEST_POLL_CHAIN__(...args) {
3726
3748
  const STACK_TRACE_ERROR = /* @__PURE__ */ new Error("STACK_TRACE_ERROR");
3727
3749
  const promise = async () => {
3750
+ chai.util.flag(assertion, "_name", key);
3751
+ chai.util.flag(assertion, "error", STACK_TRACE_ERROR);
3752
+ const onSettled = chai.util.flag(assertion, "_poll.onSettled");
3753
+ if (Object.getOwnPropertyDescriptor(assertionFunction, "__vitest_poll_takeover__")?.value) try {
3754
+ const output = await assertionFunction.call(assertion, ...args);
3755
+ await onSettled?.({
3756
+ assertion,
3757
+ status: "pass"
3758
+ });
3759
+ return output;
3760
+ } catch (err) {
3761
+ await onSettled?.({
3762
+ assertion,
3763
+ status: "fail"
3764
+ });
3765
+ throwWithCause(err, STACK_TRACE_ERROR);
3766
+ }
3728
3767
  const { setTimeout, clearTimeout } = getSafeTimers();
3729
3768
  let executionPhase = "fn";
3730
3769
  let hasTimedOut = false;
3731
3770
  const timerId = setTimeout(() => {
3732
3771
  hasTimedOut = true;
3733
3772
  }, timeout);
3734
- chai.util.flag(assertion, "_name", key);
3735
- const onSettled = chai.util.flag(assertion, "_poll.onSettled");
3736
3773
  try {
3737
3774
  while (true) {
3738
3775
  const isLastAttempt = hasTimedOut;
@@ -3847,7 +3884,7 @@ const SnapshotPlugin = (chai, utils) => {
3847
3884
  assertion: this,
3848
3885
  received: utils.flag(this, "object"),
3849
3886
  ...normalizeArguments(propertiesOrHint, hint)
3850
- }));
3887
+ }), chai.util.flag(this, "message"));
3851
3888
  }));
3852
3889
  utils.addMethod(chai.Assertion.prototype, "toMatchFileSnapshot", function(filepath, hint) {
3853
3890
  // set name manually since it's not wrapped by wrapAssertion
@@ -3859,7 +3896,7 @@ const SnapshotPlugin = (chai, utils) => {
3859
3896
  received: utils.flag(this, "object"),
3860
3897
  filepath,
3861
3898
  hint
3862
- }).then((result) => assertMatchResult(result));
3899
+ }).then((result) => assertMatchResult(result, chai.util.flag(this, "message")));
3863
3900
  return recordAsyncExpect(getTest(this), assertPromise, createAssertionMessage(utils, this, true), /* @__PURE__ */ new Error("resolves"), utils.flag(this, "soft"));
3864
3901
  });
3865
3902
  utils.addMethod(chai.Assertion.prototype, "toMatchInlineSnapshot", wrapAssertion(utils, "toMatchInlineSnapshot", function __INLINE_SNAPSHOT_OFFSET_3__(propertiesOrInlineSnapshot, inlineSnapshotOrHint, hint) {
@@ -3868,7 +3905,7 @@ const SnapshotPlugin = (chai, utils) => {
3868
3905
  received: utils.flag(this, "object"),
3869
3906
  isInline: true,
3870
3907
  ...normalizeInlineArguments(propertiesOrInlineSnapshot, inlineSnapshotOrHint, hint)
3871
- }));
3908
+ }), chai.util.flag(this, "message"));
3872
3909
  }));
3873
3910
  utils.addMethod(chai.Assertion.prototype, "toThrowErrorMatchingSnapshot", wrapAssertion(utils, "toThrowErrorMatchingSnapshot", function(propertiesOrHint, hint) {
3874
3911
  validateAssertion(this);
@@ -3878,7 +3915,7 @@ const SnapshotPlugin = (chai, utils) => {
3878
3915
  assertion: this,
3879
3916
  received: getError(received, promise),
3880
3917
  ...normalizeArguments(propertiesOrHint, hint)
3881
- }));
3918
+ }), chai.util.flag(this, "message"));
3882
3919
  }));
3883
3920
  utils.addMethod(chai.Assertion.prototype, "toThrowErrorMatchingInlineSnapshot", wrapAssertion(utils, "toThrowErrorMatchingInlineSnapshot", function __INLINE_SNAPSHOT_OFFSET_3__(inlineSnapshotOrHint, hint) {
3884
3921
  validateAssertion(this);
@@ -3889,10 +3926,43 @@ const SnapshotPlugin = (chai, utils) => {
3889
3926
  received: getError(received, promise),
3890
3927
  isInline: true,
3891
3928
  ...normalizeInlineArguments(void 0, inlineSnapshotOrHint, hint)
3892
- }));
3929
+ }), chai.util.flag(this, "message"));
3893
3930
  }));
3894
3931
  utils.addMethod(chai.expect, "addSnapshotSerializer", addSerializer);
3895
3932
  };
3933
+ function toMatchDomainSnapshotImpl(opts) {
3934
+ const { assertion } = opts;
3935
+ validateAssertion(assertion);
3936
+ const assertionName = getAssertionName(assertion);
3937
+ const test = getTest(assertion);
3938
+ let { inlineSnapshot } = opts;
3939
+ if (inlineSnapshot) inlineSnapshot = stripSnapshotIndentation(inlineSnapshot);
3940
+ const pollFn = chai.util.flag(assertion, "_poll.fn");
3941
+ if (pollFn) return getSnapshotClient().pollMatchDomain({
3942
+ poll: pollFn,
3943
+ adapter: opts.adapter,
3944
+ message: opts.hint,
3945
+ isInline: opts.isInline,
3946
+ errorMessage: chai.util.flag(assertion, "message"),
3947
+ timeout: chai.util.flag(assertion, "_poll.timeout"),
3948
+ interval: chai.util.flag(assertion, "_poll.interval"),
3949
+ assertionName,
3950
+ inlineSnapshot,
3951
+ error: chai.util.flag(assertion, "error"),
3952
+ ...getTestNames(test)
3953
+ });
3954
+ return getSnapshotClient().matchDomain({
3955
+ received: opts.received,
3956
+ adapter: opts.adapter,
3957
+ message: opts.hint,
3958
+ isInline: opts.isInline,
3959
+ errorMessage: chai.util.flag(assertion, "message"),
3960
+ assertionName,
3961
+ inlineSnapshot,
3962
+ error: chai.util.flag(assertion, "error"),
3963
+ ...getTestNames(test)
3964
+ });
3965
+ }
3896
3966
  // toMatchSnapshot(propertiesOrHint?, hint?)
3897
3967
  function normalizeArguments(propertiesOrHint, hint) {
3898
3968
  if (typeof propertiesOrHint === "string") return { hint: propertiesOrHint };
@@ -3929,7 +3999,6 @@ function toMatchSnapshotImpl(options) {
3929
3999
  message: options.hint,
3930
4000
  isInline: options.isInline,
3931
4001
  inlineSnapshot: options.inlineSnapshot,
3932
- errorMessage: chai.util.flag(assertion, "message"),
3933
4002
  assertionName,
3934
4003
  error: chai.util.flag(assertion, "error"),
3935
4004
  ...getTestNames(test)
@@ -3945,7 +4014,6 @@ async function toMatchFileSnapshotImpl(options) {
3945
4014
  return getSnapshotClient().match({
3946
4015
  received: options.received,
3947
4016
  message: options.hint,
3948
- errorMessage: chai.util.flag(assertion, "message"),
3949
4017
  rawSnapshot: {
3950
4018
  file: rawSnapshotFile,
3951
4019
  content: rawSnapshotContent ?? void 0
@@ -3953,12 +4021,15 @@ async function toMatchFileSnapshotImpl(options) {
3953
4021
  ...testNames
3954
4022
  });
3955
4023
  }
3956
- function assertMatchResult(result) {
3957
- if (!result.pass) throw Object.assign(new Error(result.message()), {
3958
- actual: result.actual,
3959
- expected: result.expected,
3960
- diffOptions: { expand: getWorkerState().config.snapshotOptions.expand }
3961
- });
4024
+ function assertMatchResult(result, customMessage) {
4025
+ if (!result.pass) {
4026
+ const errorMessage = (customMessage ? `${customMessage}: ` : "") + result.message();
4027
+ throw Object.assign(new Error(errorMessage), {
4028
+ actual: result.actual,
4029
+ expected: result.expected,
4030
+ diffOptions: { expand: getWorkerState().config.snapshotOptions.expand }
4031
+ });
4032
+ }
3962
4033
  }
3963
4034
  /**
3964
4035
  * Composable snapshot matcher helpers for building custom snapshot matchers
@@ -3970,14 +4041,14 @@ function assertMatchResult(result) {
3970
4041
  const Snapshots = {
3971
4042
  toMatchSnapshot(received, propertiesOrHint, hint) {
3972
4043
  return toMatchSnapshotImpl({
3973
- assertion: this.__vitest_assertion__,
4044
+ assertion: this.assertion,
3974
4045
  received,
3975
4046
  ...normalizeArguments(propertiesOrHint, hint)
3976
4047
  });
3977
4048
  },
3978
4049
  toMatchInlineSnapshot(received, propertiesOrInlineSnapshot, inlineSnapshotOrHint, hint) {
3979
4050
  return toMatchSnapshotImpl({
3980
- assertion: this.__vitest_assertion__,
4051
+ assertion: this.assertion,
3981
4052
  received,
3982
4053
  isInline: true,
3983
4054
  ...normalizeInlineArguments(propertiesOrInlineSnapshot, inlineSnapshotOrHint, hint)
@@ -3985,11 +4056,27 @@ const Snapshots = {
3985
4056
  },
3986
4057
  toMatchFileSnapshot(received, filepath, hint) {
3987
4058
  return toMatchFileSnapshotImpl({
3988
- assertion: this.__vitest_assertion__,
4059
+ assertion: this.assertion,
3989
4060
  received,
3990
4061
  filepath,
3991
4062
  hint
3992
4063
  });
4064
+ },
4065
+ toMatchDomainSnapshot(domain, received) {
4066
+ return toMatchDomainSnapshotImpl({
4067
+ assertion: this.assertion,
4068
+ adapter: domain,
4069
+ received
4070
+ });
4071
+ },
4072
+ toMatchDomainInlineSnapshot(domain, received, inlineSnapshot) {
4073
+ return toMatchDomainSnapshotImpl({
4074
+ assertion: this.assertion,
4075
+ adapter: domain,
4076
+ received,
4077
+ isInline: true,
4078
+ inlineSnapshot
4079
+ });
3993
4080
  }
3994
4081
  };
3995
4082
 
@@ -0,0 +1,60 @@
1
+ interface AfterSuiteRunMeta {
2
+ coverage?: unknown;
3
+ testFiles: string[];
4
+ environment: string;
5
+ projectName?: string;
6
+ }
7
+ interface UserConsoleLog {
8
+ content: string;
9
+ origin?: string;
10
+ browser?: boolean;
11
+ type: "stdout" | "stderr";
12
+ taskId?: string;
13
+ time: number;
14
+ size: number;
15
+ }
16
+ interface ModuleGraphData {
17
+ graph: Record<string, string[]>;
18
+ externalized: string[];
19
+ inlined: string[];
20
+ }
21
+ interface ProvidedContext {}
22
+ interface ResolveFunctionResult {
23
+ id: string;
24
+ file: string;
25
+ url: string;
26
+ }
27
+ interface FetchCachedFileSystemResult {
28
+ cached: true;
29
+ tmp: string;
30
+ id: string;
31
+ file: string | null;
32
+ url: string;
33
+ invalidate: boolean;
34
+ }
35
+ type LabelColor = "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white";
36
+ interface AsyncLeak {
37
+ filename: string;
38
+ projectName: string;
39
+ stack: string;
40
+ type: string;
41
+ }
42
+
43
+ interface OTELCarrier {
44
+ traceparent?: string;
45
+ tracestate?: string;
46
+ }
47
+ interface TracesOptions {
48
+ enabled: boolean;
49
+ watchMode?: boolean;
50
+ sdkPath?: string;
51
+ tracerName?: string;
52
+ }
53
+ declare class Traces {
54
+ #private;
55
+ constructor(options: TracesOptions);
56
+ isEnabled(): boolean;
57
+ }
58
+
59
+ export { Traces as T };
60
+ export type { AsyncLeak as A, FetchCachedFileSystemResult as F, LabelColor as L, ModuleGraphData as M, OTELCarrier as O, ProvidedContext as P, ResolveFunctionResult as R, UserConsoleLog as U, AfterSuiteRunMeta as a };
@@ -138,7 +138,7 @@ function formatProjectName(project, suffix = " ") {
138
138
  }
139
139
  function withLabel(color, label, message) {
140
140
  const bgColor = `bg${color.charAt(0).toUpperCase()}${color.slice(1)}`;
141
- return `${c.bold(c[bgColor](` ${label} `))} ${message ? c[color](message) : ""}`;
141
+ return `${c.bold(c.black(c[bgColor](` ${label} `)))} ${message ? c[color](message) : ""}`;
142
142
  }
143
143
  function padSummaryTitle(str) {
144
144
  return c.dim(`${str.padStart(11)} `);
@@ -1,8 +1,8 @@
1
1
  import { FileSpecification, Task, CancelReason } from '@vitest/runner';
2
2
  import { EvaluatedModules } from 'vite/module-runner';
3
- import { S as SerializedConfig } from './config.d.ChUh6-ad.js';
3
+ import { S as SerializedConfig } from './config.d.A1h_Y6Jt.js';
4
4
  import { E as Environment } from './environment.d.CrsxCzP1.js';
5
- import { R as RuntimeRPC, a as RunnerRPC } from './rpc.d.BFMWpdph.js';
5
+ import { R as RuntimeRPC, a as RunnerRPC } from './rpc.d.B_8sPU0w.js';
6
6
 
7
7
  //#region src/messages.d.ts
8
8
  declare const TYPE_REQUEST: "q";
package/dist/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- import { c as createCLI } from './chunks/cac.Bb7YBzMA.js';
1
+ import { c as createCLI } from './chunks/cac.DJJmV0dT.js';
2
2
  import '@vitest/utils/helpers';
3
3
  import 'events';
4
4
  import 'pathe';
package/dist/config.d.ts CHANGED
@@ -1,19 +1,19 @@
1
1
  import { HookHandler, UserConfig, ConfigEnv } from 'vite';
2
2
  export { ConfigEnv, Plugin, UserConfig as ViteUserConfig, mergeConfig } from 'vite';
3
- import { I as InlineConfig, C as CoverageOptions, F as FieldsWithDefaultValues, U as UserWorkspaceConfig, b as UserProjectConfigFn, c as UserProjectConfigExport } from './chunks/reporters.d.yJ2fBir5.js';
4
- export { a as TestProjectConfiguration, d as TestProjectInlineConfiguration, e as TestUserConfig, W as WatcherTriggerPattern } from './chunks/reporters.d.yJ2fBir5.js';
5
- import { V as VitestPluginContext } from './chunks/plugin.d.BssAumYw.js';
6
- import { F as FakeTimerInstallOpts } from './chunks/config.d.ChUh6-ad.js';
3
+ import { I as InlineConfig, C as CoverageOptions, F as FieldsWithDefaultValues, U as UserWorkspaceConfig, b as UserProjectConfigFn, c as UserProjectConfigExport } from './chunks/reporters.d.CEnv6XRv.js';
4
+ export { a as TestProjectConfiguration, d as TestProjectInlineConfiguration, e as TestUserConfig, W as WatcherTriggerPattern } from './chunks/reporters.d.CEnv6XRv.js';
5
+ import { V as VitestPluginContext } from './chunks/plugin.d.BM2TCi12.js';
6
+ import { F as FakeTimerInstallOpts } from './chunks/config.d.A1h_Y6Jt.js';
7
7
  export { TestTagDefinition } from '@vitest/runner';
8
8
  import '@vitest/utils';
9
- import './chunks/rpc.d.BFMWpdph.js';
10
- import '@vitest/snapshot';
11
- import 'vite/module-runner';
12
- import './chunks/traces.d.402V_yFI.js';
9
+ import './chunks/traces.d.D2T_R8rx.js';
13
10
  import 'node:stream';
14
- import './chunks/browser.d.C0zGu1u9.js';
15
- import './chunks/worker.d.CckNUvI5.js';
11
+ import './chunks/browser.d.BcoexmFG.js';
12
+ import './chunks/worker.d.ZpHpO4yb.js';
13
+ import 'vite/module-runner';
16
14
  import './chunks/environment.d.CrsxCzP1.js';
15
+ import './chunks/rpc.d.B_8sPU0w.js';
16
+ import '@vitest/snapshot';
17
17
  import '@vitest/pretty-format';
18
18
  import '@vitest/utils/diff';
19
19
  import '@vitest/expect';
@@ -1,18 +1,18 @@
1
- import { V as Vitest, at as ResolvedCoverageOptions, aZ as CoverageMap, am as ReportContext, T as TestProject } from './chunks/reporters.d.yJ2fBir5.js';
1
+ import { V as Vitest, av as ResolvedCoverageOptions, a$ as CoverageMap, ao as ReportContext, T as TestProject } from './chunks/reporters.d.CEnv6XRv.js';
2
2
  import { TransformResult } from 'vite';
3
- import { A as AfterSuiteRunMeta } from './chunks/rpc.d.BFMWpdph.js';
3
+ import { a as AfterSuiteRunMeta } from './chunks/traces.d.D2T_R8rx.js';
4
4
  import '@vitest/runner';
5
5
  import '@vitest/utils';
6
6
  import 'node:stream';
7
- import './chunks/browser.d.C0zGu1u9.js';
8
- import './chunks/traces.d.402V_yFI.js';
9
- import './chunks/worker.d.CckNUvI5.js';
10
- import 'vite/module-runner';
11
- import './chunks/config.d.ChUh6-ad.js';
7
+ import './chunks/config.d.A1h_Y6Jt.js';
12
8
  import '@vitest/pretty-format';
13
9
  import '@vitest/snapshot';
14
10
  import '@vitest/utils/diff';
11
+ import './chunks/browser.d.BcoexmFG.js';
12
+ import './chunks/worker.d.ZpHpO4yb.js';
13
+ import 'vite/module-runner';
15
14
  import './chunks/environment.d.CrsxCzP1.js';
15
+ import './chunks/rpc.d.B_8sPU0w.js';
16
16
  import '@vitest/expect';
17
17
  import 'vitest/optional-types.js';
18
18
  import './chunks/benchmark.d.DAaHLpsq.js';
@@ -79,6 +79,7 @@ declare class BaseCoverageProvider {
79
79
  }>;
80
80
  resolveOptions(): ResolvedCoverageOptions;
81
81
  clean(clean?: boolean): Promise<void>;
82
+ private normalizeCoverageFileError;
82
83
  onAfterSuiteRun({ coverage, environment, projectName, testFiles }: AfterSuiteRunMeta): void;
83
84
  readCoverageFiles<CoverageType>({ onFileRead, onFinished, onDebug }: {
84
85
  /** Callback invoked with a single coverage result */