vitest 4.1.0 → 4.1.2

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 (58) hide show
  1. package/dist/browser.d.ts +1 -1
  2. package/dist/browser.js +3 -3
  3. package/dist/chunks/{base.DM0-RqVb.js → base.BPik1OqN.js} +8 -8
  4. package/dist/chunks/{benchmark.D0SlKNbZ.js → benchmark.CX_oY03V.js} +1 -1
  5. package/dist/chunks/{browser.d.X3SXoOCV.d.ts → browser.d.BMOr_Kmk.d.ts} +1 -1
  6. package/dist/chunks/{cac.CWGDZnXT.js → cac.DRKYQDPl.js} +22 -10
  7. package/dist/chunks/{cli-api.DuT9iuvY.js → cli-api.Bxr1Nn49.js} +154 -40
  8. package/dist/chunks/{config.d.EJLVE3es.d.ts → config.d.Cz9kPrQs.d.ts} +1 -0
  9. package/dist/chunks/{coverage.D_JHT54q.js → coverage.CTzCuANN.js} +4 -1
  10. package/dist/chunks/{coverage.Bri33R1t.js → coverage.kqM80boz.js} +26 -11
  11. package/dist/chunks/{defaults.CdU2lD-q.js → defaults.9aQKnqFk.js} +13 -5
  12. package/dist/chunks/{globals.BXNGLnTL.js → globals.CVqIbOyt.js} +3 -3
  13. package/dist/chunks/{index.DXMFO5MJ.js → index.0GYC6HAu.js} +627 -586
  14. package/dist/chunks/{index.EY6TCHpo.js → index.DC7d2Pf8.js} +2 -2
  15. package/dist/chunks/{index.DlDSLQD3.js → index.DOa3dzoN.js} +2 -2
  16. package/dist/chunks/{index.DGNSnENe.js → index.nZ2xqFgD.js} +2 -2
  17. package/dist/chunks/{init-forks.DeArv0jT.js → init-forks.UV3ZQGQH.js} +1 -1
  18. package/dist/chunks/{init-threads.-2OUl4Nn.js → init-threads.D3eCsY76.js} +1 -1
  19. package/dist/chunks/{init.DICorXCo.js → init.D98-gwRW.js} +5 -3
  20. package/dist/chunks/{nativeModuleMocker.DndvSdL6.js → nativeModuleMocker.BRN2oBJd.js} +2 -2
  21. package/dist/chunks/{plugin.d.BuW-flqo.d.ts → plugin.d.BWbK_Jpw.d.ts} +1 -1
  22. package/dist/chunks/{reporters.d.DVUYHHhe.d.ts → reporters.d.B0uk8id2.d.ts} +54 -33
  23. package/dist/chunks/{setup-common.B41N_kPE.js → setup-common.2wZXQUjS.js} +2 -2
  24. package/dist/chunks/{startVitestModuleRunner.C3ZR-4J3.js → startVitestModuleRunner.bRl2_oI_.js} +19 -5
  25. package/dist/chunks/{test.CTcmp4Su.js → test.p_J6dB8a.js} +3 -2
  26. package/dist/chunks/{traces.CCmnQaNT.js → traces.DT5aQ62U.js} +1 -1
  27. package/dist/chunks/utils.DK8FXp4T.js +189 -0
  28. package/dist/chunks/{vm.Dh2rTtmP.js → vm.BvVhnZPV.js} +2 -2
  29. package/dist/chunks/{worker.d.B84sVRy0.d.ts → worker.d.BT5j8dyR.d.ts} +1 -1
  30. package/dist/cli.js +2 -20
  31. package/dist/config.cjs +13 -5
  32. package/dist/config.d.ts +8 -8
  33. package/dist/config.js +1 -1
  34. package/dist/coverage.d.ts +7 -7
  35. package/dist/coverage.js +3 -3
  36. package/dist/environments.js +1 -1
  37. package/dist/index.d.ts +7 -6
  38. package/dist/index.js +3 -3
  39. package/dist/module-evaluator.js +2 -2
  40. package/dist/node.d.ts +7 -7
  41. package/dist/node.js +11 -11
  42. package/dist/reporters.d.ts +4 -4
  43. package/dist/reporters.js +6 -6
  44. package/dist/runners.d.ts +3 -2
  45. package/dist/runners.js +2 -2
  46. package/dist/runtime.js +3 -3
  47. package/dist/suite.js +1 -1
  48. package/dist/worker.d.ts +2 -2
  49. package/dist/worker.js +12 -11
  50. package/dist/workers/forks.js +13 -12
  51. package/dist/workers/runVmTests.js +6 -6
  52. package/dist/workers/threads.js +13 -12
  53. package/dist/workers/vmForks.js +7 -7
  54. package/dist/workers/vmThreads.js +7 -7
  55. package/optional-runtime-types.d.ts +6 -0
  56. package/package.json +19 -16
  57. package/dist/chunks/git.Bm2pzPAa.js +0 -71
  58. package/dist/chunks/index.CEzQDJGb.js +0 -231
@@ -254,11 +254,11 @@ function populateGlobal(global, win, options = {}) {
254
254
  const { bindFunctions = false } = options;
255
255
  const keys = getWindowKeys(global, win, options.additionalKeys);
256
256
  const originals = /* @__PURE__ */ new Map();
257
- const overridenKeys = new Set([...KEYS, ...options.additionalKeys || []]);
257
+ const overriddenKeys = new Set([...KEYS, ...options.additionalKeys || []]);
258
258
  const overrideObject = /* @__PURE__ */ new Map();
259
259
  for (const key of keys) {
260
260
  const boundFunction = bindFunctions && typeof win[key] === "function" && !isClassLikeName(key) && win[key].bind(win);
261
- if (overridenKeys.has(key) && key in global) originals.set(key, global[key]);
261
+ if (overriddenKeys.has(key) && key in global) originals.set(key, global[key]);
262
262
  Object.defineProperty(global, key, {
263
263
  get() {
264
264
  if (overrideObject.has(key)) return overrideObject.get(key);
@@ -1,5 +1,5 @@
1
- import { v as vi, N as NodeBenchmarkRunner, T as TestRunner, a as assert, c as createExpect, g as globalExpect, i as inject, s as should, b as vitest } from './test.CTcmp4Su.js';
2
- import { b as bench } from './benchmark.D0SlKNbZ.js';
1
+ import { v as vi, N as NodeBenchmarkRunner, T as TestRunner, a as assert, c as createExpect, g as globalExpect, i as inject, s as should, b as vitest } from './test.p_J6dB8a.js';
2
+ import { b as bench } from './benchmark.CX_oY03V.js';
3
3
  import { V as VitestEvaluatedModules } from './evaluatedModules.Dg1zASAC.js';
4
4
  import { expectTypeOf } from 'expect-type';
5
5
  import { afterAll, afterEach, aroundAll, aroundEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, recordArtifact, suite, test } from '@vitest/runner';
@@ -1,9 +1,9 @@
1
1
  import { chai } from '@vitest/expect';
2
2
  import { createHook } from 'node:async_hooks';
3
- import { l as loadDiffConfig, a as loadSnapshotSerializers, t as takeCoverageInsideWorker } from './setup-common.B41N_kPE.js';
3
+ import { l as loadDiffConfig, a as loadSnapshotSerializers, t as takeCoverageInsideWorker } from './setup-common.2wZXQUjS.js';
4
4
  import { r as rpc } from './rpc.MzXet3jl.js';
5
5
  import { g as getWorkerState } from './utils.BX5Fg8C4.js';
6
- import { T as TestRunner, N as NodeBenchmarkRunner } from './test.CTcmp4Su.js';
6
+ import { T as TestRunner, N as NodeBenchmarkRunner } from './test.p_J6dB8a.js';
7
7
 
8
8
  function setupChaiConfig(config) {
9
9
  Object.assign(chai.config, config);
@@ -1,4 +1,4 @@
1
- import { i as init } from './init.DICorXCo.js';
1
+ import { i as init } from './init.D98-gwRW.js';
2
2
 
3
3
  if (!process.send) throw new Error("Expected worker to be run in node:child_process");
4
4
  // Store globals in case tests overwrite them
@@ -1,5 +1,5 @@
1
1
  import { isMainThread, parentPort } from 'node:worker_threads';
2
- import { i as init } from './init.DICorXCo.js';
2
+ import { i as init } from './init.D98-gwRW.js';
3
3
 
4
4
  if (isMainThread || !parentPort) throw new Error("Expected worker to be run in node:worker_threads");
5
5
  function workerInit(options) {
@@ -3,11 +3,12 @@ import { isBuiltin } from 'node:module';
3
3
  import { pathToFileURL } from 'node:url';
4
4
  import { resolve } from 'pathe';
5
5
  import { ModuleRunner, EvaluatedModules } from 'vite/module-runner';
6
- import { b as VitestTransport } from './startVitestModuleRunner.C3ZR-4J3.js';
7
- import { e as environments } from './index.EY6TCHpo.js';
6
+ import { b as VitestTransport } from './startVitestModuleRunner.bRl2_oI_.js';
7
+ import { e as environments } from './index.DC7d2Pf8.js';
8
8
  import { serializeValue } from '@vitest/utils/serialize';
9
9
  import { serializeError } from '@vitest/utils/error';
10
- import { T as Traces } from './traces.CCmnQaNT.js';
10
+ import { disableDefaultColors } from 'tinyrainbow';
11
+ import { T as Traces } from './traces.DT5aQ62U.js';
11
12
  import { o as onCancel, a as rpcDone, c as createRuntimeRpc } from './rpc.MzXet3jl.js';
12
13
  import { createStackString, parseStacktrace } from '@vitest/utils/source-map';
13
14
  import { s as setupInspect } from './inspector.CvyFGlXm.js';
@@ -215,6 +216,7 @@ function init(worker) {
215
216
  process.env.VITEST_POOL_ID = String(message.poolId);
216
217
  process.env.VITEST_WORKER_ID = String(message.workerId);
217
218
  reportMemory = message.options.reportMemory;
219
+ if (message.context.config.isAgent) disableDefaultColors();
218
220
  traces ??= await new Traces({
219
221
  enabled: message.traces.enabled,
220
222
  sdkPath: message.traces.sdkPath
@@ -5,7 +5,7 @@ import { cleanUrl, createDefer } from '@vitest/utils/helpers';
5
5
  import { p as parse } from './acorn.B2iPLyUM.js';
6
6
  import { isAbsolute } from 'pathe';
7
7
  import { t as toBuiltin } from './modules.BJuCwlRJ.js';
8
- import { B as BareModuleMocker, n as normalizeModuleId } from './startVitestModuleRunner.C3ZR-4J3.js';
8
+ import { B as BareModuleMocker, n as normalizeModuleId } from './startVitestModuleRunner.bRl2_oI_.js';
9
9
  import 'node:fs';
10
10
  import './utils.BX5Fg8C4.js';
11
11
  import '@vitest/utils/timers';
@@ -14,7 +14,7 @@ import 'node:path';
14
14
  import '../module-evaluator.js';
15
15
  import 'node:vm';
16
16
  import 'vite/module-runner';
17
- import './traces.CCmnQaNT.js';
17
+ import './traces.DT5aQ62U.js';
18
18
  import '@vitest/mocker';
19
19
  import '@vitest/mocker/redirect';
20
20
 
@@ -1,5 +1,5 @@
1
1
  import { DevEnvironment } from 'vite';
2
- import { V as Vitest, T as TestProject, a as TestProjectConfiguration } from './reporters.d.DVUYHHhe.js';
2
+ import { V as Vitest, T as TestProject, a as TestProjectConfiguration } from './reporters.d.B0uk8id2.js';
3
3
 
4
4
  /**
5
5
  * Generate a unique cache identifier.
@@ -3,14 +3,14 @@ import { TestError, SerializedError, Arrayable, ParsedStack, Awaitable } from '@
3
3
  import { A as AfterSuiteRunMeta, U as UserConsoleLog, b as AsyncLeak, P as ProvidedContext, L as LabelColor } from './rpc.d.BFMWpdph.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.X3SXoOCV.js';
7
- import { B as BrowserTraceViewMode, S as SerializedConfig, F as FakeTimerInstallOpts } from './config.d.EJLVE3es.js';
6
+ import { S as SerializedTestSpecification, c as SourceModuleDiagnostic, B as BrowserTesterOptions } from './browser.d.BMOr_Kmk.js';
7
+ import { B as BrowserTraceViewMode, S as SerializedConfig, F as FakeTimerInstallOpts } from './config.d.Cz9kPrQs.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.B84sVRy0.js';
13
+ import { c as ContextTestEnvironment, d as WorkerExecuteContext, e as WorkerTestEnvironment } from './worker.d.BT5j8dyR.js';
14
14
  import { O as OTELCarrier } from './traces.d.402V_yFI.js';
15
15
  import { B as BenchmarkResult } from './benchmark.d.DAaHLpsq.js';
16
16
  import { MockedModule } from '@vitest/mocker';
@@ -693,28 +693,19 @@ interface CoverageProviderModule extends RuntimeCoverageProviderModule {
693
693
  }
694
694
  type CoverageReporter = keyof ReportOptions | (string & {});
695
695
  type CoverageReporterWithOptions<ReporterName extends CoverageReporter = CoverageReporter> = ReporterName extends keyof ReportOptions ? ReportOptions[ReporterName] extends never ? [ReporterName, object] : [ReporterName, Partial<ReportOptions[ReporterName]>] : [ReporterName, Record<string, unknown>];
696
- type CoverageProviderName = "v8" | "istanbul" | "custom" | undefined;
697
- type CoverageOptions<T extends CoverageProviderName = CoverageProviderName> = T extends "istanbul" ? {
698
- provider: T;
699
- } & CoverageIstanbulOptions : T extends "v8" ? {
700
- /**
701
- * Provider to use for coverage collection.
702
- *
703
- * @default 'v8'
704
- */
705
- provider: T;
706
- } & CoverageV8Options : T extends "custom" ? {
707
- provider: T;
708
- } & CustomProviderOptions : {
709
- provider?: T;
710
- } & CoverageV8Options;
711
696
  /** Fields that have default values. Internally these will always be defined. */
712
- type FieldsWithDefaultValues = "enabled" | "clean" | "cleanOnRerun" | "reportsDirectory" | "exclude" | "reportOnFailure" | "allowExternal" | "processingConcurrency";
713
- type ResolvedCoverageOptions<T extends CoverageProviderName = CoverageProviderName> = CoverageOptions<T> & Required<Pick<CoverageOptions<T>, FieldsWithDefaultValues>> & {
697
+ type FieldsWithDefaultValues = "provider" | "enabled" | "clean" | "cleanOnRerun" | "reportsDirectory" | "exclude" | "reportOnFailure" | "allowExternal" | "processingConcurrency" | "reporter" | "excludeAfterRemap" | "ignoreClassMethods" | "skipFull" | "watermarks";
698
+ type ResolvedCoverageOptions = CoverageOptions & Required<Pick<CoverageOptions, FieldsWithDefaultValues>> & {
714
699
  reporter: CoverageReporterWithOptions[];
715
700
  htmlDir?: string;
716
701
  };
717
- interface BaseCoverageOptions {
702
+ interface CoverageOptions {
703
+ /**
704
+ * Coverage provider to use.
705
+ *
706
+ * @default 'v8'
707
+ */
708
+ provider?: "v8" | "istanbul" | "custom";
718
709
  /**
719
710
  * Enables coverage collection. Can be overridden using `--coverage` CLI option.
720
711
  *
@@ -844,16 +835,12 @@ interface BaseCoverageOptions {
844
835
  /**
845
836
  * Collect coverage only for files changed since a specified commit or branch.
846
837
  * Inherits the default value from `test.changed`.
847
- *
848
- * @default false
849
838
  */
850
839
  changed?: boolean | string;
851
- }
852
- interface CoverageIstanbulOptions extends BaseCoverageOptions {}
853
- interface CoverageV8Options extends BaseCoverageOptions {}
854
- interface CustomProviderOptions extends Pick<BaseCoverageOptions, FieldsWithDefaultValues | "changed"> {
855
- /** Name of the module or path to a file to load the custom provider from */
856
- customProviderModule: string;
840
+ /**
841
+ * Name of the module or path to a file to load the custom provider from
842
+ */
843
+ customProviderModule?: string;
857
844
  }
858
845
  interface Thresholds {
859
846
  /** Set global thresholds to `100` */
@@ -876,12 +863,28 @@ interface Thresholds {
876
863
  /** Thresholds for lines */
877
864
  lines?: number;
878
865
  }
866
+ /** @deprecated Use `CoverageOptions` instead */
867
+ interface CoverageV8Options extends CoverageOptions {}
868
+ /** @deprecated Use `CoverageOptions` instead */
869
+ interface CoverageIstanbulOptions extends CoverageOptions {}
870
+ /** @deprecated Use `CoverageOptions` instead */
871
+ interface BaseCoverageOptions extends CoverageOptions {}
872
+ /** @deprecated Use `CoverageOptions` instead */
873
+ interface CustomProviderOptions extends CoverageOptions {}
879
874
 
880
875
  interface TestRunResult {
881
876
  testModules: TestModule[];
882
877
  unhandledErrors: unknown[];
883
878
  }
884
879
 
880
+ interface VCSProviderOptions {
881
+ root: string;
882
+ changedSince?: string | boolean;
883
+ }
884
+ interface VCSProvider {
885
+ findChangedFiles(options: VCSProviderOptions): Promise<string[]>;
886
+ }
887
+
885
888
  declare class TypeCheckError extends Error {
886
889
  message: string;
887
890
  stacks: ParsedStack[];
@@ -1202,6 +1205,13 @@ declare class Vitest {
1202
1205
  * Vitest behaviour.
1203
1206
  */
1204
1207
  readonly watcher: VitestWatcher;
1208
+ /**
1209
+ * The version control system provider used to detect changed files.
1210
+ * This is used with the `--changed` flag to determine which test files to run.
1211
+ * By default, Vitest uses Git. You can provide a custom implementation via
1212
+ * `experimental.vcsProvider` in your config.
1213
+ */
1214
+ vcs: VCSProvider;
1205
1215
  private isFirstRun;
1206
1216
  private restartsCount;
1207
1217
  private readonly specifications;
@@ -1311,10 +1321,14 @@ declare class Vitest {
1311
1321
  */
1312
1322
  start(filters?: string[]): Promise<TestRunResult>;
1313
1323
  /**
1324
+ * @deprecated use `standalone()` instead
1325
+ */
1326
+ init(): Promise<void>;
1327
+ /**
1314
1328
  * Initialize reporters and the coverage provider. This method doesn't run any tests.
1315
1329
  * If the `--watch` flag is provided, Vitest will still run changed tests even if this method was not called.
1316
1330
  */
1317
- init(): Promise<void>;
1331
+ standalone(): Promise<void>;
1318
1332
  /**
1319
1333
  * If there is a test run happening, returns a promise that will
1320
1334
  * resolve when the test run is finished.
@@ -1870,7 +1884,6 @@ declare class TestProject {
1870
1884
  * Temporary directory for the project. This is unique for each project. Vitest stores transformed content here.
1871
1885
  */
1872
1886
  readonly tmpDir: string;
1873
- /** @inetrnal */ testFilesList: string[] | null;
1874
1887
  private runner;
1875
1888
  private closingPromise;
1876
1889
  private typecheckFilesList;
@@ -3259,6 +3272,14 @@ interface InlineConfig {
3259
3272
  * This option only affects `loader.load` method, Vitest always defines a `loader.resolve` to populate the module graph.
3260
3273
  */
3261
3274
  nodeLoader?: boolean;
3275
+ /**
3276
+ * Custom provider for detecting changed files. Used with the `--changed` flag
3277
+ * to determine which files have been modified.
3278
+ *
3279
+ * By default, Vitest uses Git to detect changed files. You can provide a custom
3280
+ * implementation of the `VCSProvider` interface to use a different version control system.
3281
+ */
3282
+ vcsProvider?: VCSProvider | string;
3262
3283
  };
3263
3284
  /**
3264
3285
  * Define tags available in your test files.
@@ -3516,5 +3537,5 @@ type TestProjectInlineConfiguration = (UserWorkspaceConfig & {
3516
3537
  });
3517
3538
  type TestProjectConfiguration = string | TestProjectInlineConfiguration | Promise<UserWorkspaceConfig> | UserProjectConfigFn;
3518
3539
 
3519
- export { DefaultReporter as $, Logger as L, TestProject as T, Vitest as V, DotReporter as a1, GithubActionsReporter as a3, HangingProcessReporter as a5, JUnitReporter as a7, TestModule as aB, TestSuite as aM, VerboseBenchmarkReporter as aR, VerboseReporter as aS, VitestPackageInstaller as aU, experimental_getRunnerTask as aX, CoverageMap as aY, JsonReporter as aa, ReportersMap as ap, TapFlatReporter as av, TapReporter as aw, TestCase as ay, TestCollection as az, TestSpecification as i, AgentReporter as m, BaseReporter as n, BenchmarkReporter as p, BenchmarkReportsMap as q };
3520
- export type { ApiConfig as A, BaseCoverageOptions as B, CoverageV8Options as C, BrowserProviderOption as D, BrowserScript as E, BrowserServerFactory 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, ResolvedCoverageOptions as R, CoverageOptions as S, UserWorkspaceConfig as U, WatcherTriggerPattern as W, CoverageProvider as X, CoverageProviderModule as Y, CoverageReporter 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 aA, TestModuleState as aC, TestResult as aD, TestResultFailed as aE, TestResultPassed as aF, TestResultSkipped as aG, TestRunEndReason as aH, TestRunResult as aI, TestSequencerConstructor as aJ, TestSpecificationOptions as aK, TestState as aL, TestSuiteState as aN, ToMatchScreenshotComparators as aO, ToMatchScreenshotOptions as aP, TypecheckConfig as aQ, VitestEnvironment as aT, WorkerResponse as aV, _BrowserNames as aW, 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, ResolvedProjectConfig as at, SerializedTestProject as au, TaskOptions as ax, UserProjectConfigFn as b, UserProjectConfigExport as c, TestProjectInlineConfiguration as d, UserConfig as e, ResolvedConfig as f, VitestRunMode as g, VitestOptions as h, PoolOptions as j, WorkerRequest as k, TestSequencer as l, BenchmarkBuiltinReporters as o, BenchmarkUserOptions as r, BrowserBuiltinProvider as s, BrowserCommand as t, BrowserCommandContext as u, BrowserConfigOptions as v, BrowserInstanceOption as w, BrowserModuleMocker as x, BrowserOrchestrator as y, BrowserProvider as z };
3540
+ 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 };
3541
+ 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 };
@@ -1,4 +1,4 @@
1
- import { r as resolveCoverageProviderModule } from './coverage.D_JHT54q.js';
1
+ import { r as resolveCoverageProviderModule } from './coverage.CTzCuANN.js';
2
2
  import { addSerializer } from '@vitest/snapshot';
3
3
  import { setSafeTimers } from '@vitest/utils/timers';
4
4
  import { g as getWorkerState } from './utils.BX5Fg8C4.js';
@@ -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.BXNGLnTL.js')).registerApiGlobally();
29
+ if (config.globals) (await import('./globals.CVqIbOyt.js')).registerApiGlobally();
30
30
  }
31
31
  function setupDefines(config) {
32
32
  for (const key in config.defines) globalThis[key] = config.defines[key];
@@ -11,7 +11,7 @@ import vm from 'node:vm';
11
11
  import { MockerRegistry, mockObject, RedirectedModule, AutomockedModule } from '@vitest/mocker';
12
12
  import { findMockRedirect } from '@vitest/mocker/redirect';
13
13
  import * as viteModuleRunner from 'vite/module-runner';
14
- import { T as Traces } from './traces.CCmnQaNT.js';
14
+ import { T as Traces } from './traces.DT5aQ62U.js';
15
15
 
16
16
  class BareModuleMocker {
17
17
  static pendingIds = [];
@@ -102,11 +102,16 @@ class BareModuleMocker {
102
102
  }
103
103
  async resolveMocks() {
104
104
  if (!BareModuleMocker.pendingIds.length) return;
105
- await Promise.all(BareModuleMocker.pendingIds.map(async (mock) => {
105
+ const resolveMock = async (mock) => {
106
106
  const { id, url, external } = await this.resolveId(mock.id, mock.importer);
107
107
  if (mock.action === "unmock") this.unmockPath(id);
108
108
  if (mock.action === "mock") this.mockPath(mock.id, id, url, external, mock.type, mock.factory);
109
- }));
109
+ };
110
+ // group consecutive mocks of the same action type together,
111
+ // resolve in parallel inside each group, but run groups sequentially
112
+ // to preserve mock/unmock ordering
113
+ const groups = groupByConsecutiveAction(BareModuleMocker.pendingIds);
114
+ for (const group of groups) await Promise.all(group.map(resolveMock));
110
115
  BareModuleMocker.pendingIds = [];
111
116
  }
112
117
  // public method to avoid circular dependency
@@ -212,6 +217,15 @@ const windowsSlashRE = /\\/g;
212
217
  function slash(p) {
213
218
  return p.replace(windowsSlashRE, "/");
214
219
  }
220
+ function groupByConsecutiveAction(mocks) {
221
+ const groups = [];
222
+ for (const mock of mocks) {
223
+ const last = groups.at(-1);
224
+ if (last?.[0].action === mock.action) last.push(mock);
225
+ else groups.push([mock]);
226
+ }
227
+ return groups;
228
+ }
215
229
  const multipleSlashRe = /^\/+/;
216
230
  // module-runner incorrectly replaces file:///path with `///path`
217
231
  function fixLeadingSlashes(id) {
@@ -503,7 +517,7 @@ class VitestModuleRunner extends viteModuleRunner.ModuleRunner {
503
517
  * Vite checks that the module has exports emulating the Node.js behaviour,
504
518
  * but Vitest is more relaxed.
505
519
  *
506
- * We should keep the Vite behavour when there is a `strict` flag.
520
+ * We should keep the Vite behavior when there is a `strict` flag.
507
521
  * @internal
508
522
  */
509
523
  processImport(exports$1) {
@@ -687,7 +701,7 @@ function startVitestModuleRunner(options) {
687
701
  };
688
702
  // if module is invalidated, the worker will be recreated,
689
703
  // so cached is always true in a single worker
690
- if (options?.cached) return { cache: true };
704
+ if (!isImportActual && options?.cached) return { cache: true };
691
705
  const otelCarrier = traces?.getContextCarrier();
692
706
  const result = await rpc().fetch(id, importer, environment(), options, otelCarrier);
693
707
  if ("cached" in result) return {
@@ -1,10 +1,10 @@
1
1
  import { getCurrentTest, updateTask, createTaskCollector, getCurrentSuite, getHooks, getFn } from '@vitest/runner';
2
2
  import { assertTypes, createSimpleStackTrace, createDefer } from '@vitest/utils/helpers';
3
3
  import { getSafeTimers, delay } from '@vitest/utils/timers';
4
- import { a as getBenchOptions, g as getBenchFn } from './benchmark.D0SlKNbZ.js';
4
+ import { a as getBenchOptions, g as getBenchFn } from './benchmark.CX_oY03V.js';
5
5
  import { g as getWorkerState, i as isChildProcess, w as waitForImportsToResolve, r as resetModules } from './utils.BX5Fg8C4.js';
6
6
  import { chai, wrapAssertion, recordAsyncExpect, createAssertionMessage, equals, iterableEquality, subsetEquality, JestExtend, JestChaiExpect, ChaiStyleAssertions, JestAsymmetricMatchers, GLOBAL_EXPECT, ASYMMETRIC_MATCHERS_OBJECT, getState, setState, addCustomEqualityTesters, customMatchers } from '@vitest/expect';
7
- import { getNames, getTests, getTestName, createChainable } from '@vitest/runner/utils';
7
+ import { getNames, getTests, getTestName, createChainable, matchesTags } from '@vitest/runner/utils';
8
8
  import { processError } from '@vitest/utils/error';
9
9
  import { normalize } from 'pathe';
10
10
  import { stripSnapshotIndentation, addSerializer, SnapshotClient } from '@vitest/snapshot';
@@ -4255,6 +4255,7 @@ class TestRunner {
4255
4255
  static getTestFn = getFn;
4256
4256
  static setSuiteHooks = getHooks;
4257
4257
  static setTestFn = getFn;
4258
+ static matchesTags = matchesTags;
4258
4259
  /**
4259
4260
  * @deprecated
4260
4261
  */
@@ -130,7 +130,7 @@ class Traces {
130
130
  }
131
131
  throw error;
132
132
  } finally {
133
- // end sync callbcak
133
+ // end sync callback
134
134
  if (!(result instanceof Promise)) span.end();
135
135
  }
136
136
  }
@@ -0,0 +1,189 @@
1
+ import { stripVTControlCharacters } from 'node:util';
2
+ import { slash } from '@vitest/utils/helpers';
3
+ import { isAbsolute, relative, dirname, basename } from 'pathe';
4
+ import c from 'tinyrainbow';
5
+
6
+ const F_RIGHT = "→";
7
+ const F_DOWN = "↓";
8
+ const F_DOWN_RIGHT = "↳";
9
+ const F_POINTER = "❯";
10
+ const F_DOT = "·";
11
+ const F_CHECK = "✓";
12
+ const F_CROSS = "×";
13
+ const F_LONG_DASH = "⎯";
14
+ const F_TODO = "□";
15
+ const F_TREE_NODE_MIDDLE = "├──";
16
+ const F_TREE_NODE_END = "└──";
17
+
18
+ const pointer = c.yellow(F_POINTER);
19
+ const skipped = c.dim(c.gray(F_DOWN));
20
+ const todo = c.dim(c.gray(F_TODO));
21
+ const benchmarkPass = c.green(F_DOT);
22
+ const testPass = c.green(F_CHECK);
23
+ const taskFail = c.red(F_CROSS);
24
+ const suiteFail = c.red(F_POINTER);
25
+ const pending = c.gray("·");
26
+ const separator = c.dim(" > ");
27
+ const labelDefaultColors = [
28
+ c.bgYellow,
29
+ c.bgCyan,
30
+ c.bgGreen,
31
+ c.bgMagenta
32
+ ];
33
+ function getCols(delta = 0) {
34
+ let length = process.stdout?.columns;
35
+ if (!length || Number.isNaN(length)) length = 30;
36
+ return Math.max(length + delta, 0);
37
+ }
38
+ function errorBanner(message) {
39
+ return divider(c.bold(c.bgRed(` ${message} `)), null, null, c.red);
40
+ }
41
+ function divider(text, left, right, color) {
42
+ const cols = getCols();
43
+ const c = color || ((text) => text);
44
+ if (text) {
45
+ const textLength = stripVTControlCharacters(text).length;
46
+ if (left == null && right != null) left = cols - textLength - right;
47
+ else {
48
+ left = left ?? Math.floor((cols - textLength) / 2);
49
+ right = cols - textLength - left;
50
+ }
51
+ left = Math.max(0, left);
52
+ right = Math.max(0, right);
53
+ return `${c(F_LONG_DASH.repeat(left))}${text}${c(F_LONG_DASH.repeat(right))}`;
54
+ }
55
+ return F_LONG_DASH.repeat(cols);
56
+ }
57
+ function formatTestPath(root, path) {
58
+ if (isAbsolute(path)) path = relative(root, path);
59
+ const dir = dirname(path);
60
+ const ext = path.match(/(\.(spec|test)\.[cm]?[tj]sx?)$/)?.[0] || "";
61
+ const base = basename(path, ext);
62
+ return slash(c.dim(`${dir}/`) + c.bold(base)) + c.dim(ext);
63
+ }
64
+ function renderSnapshotSummary(rootDir, snapshots) {
65
+ const summary = [];
66
+ if (snapshots.added) summary.push(c.bold(c.green(`${snapshots.added} written`)));
67
+ if (snapshots.unmatched) summary.push(c.bold(c.red(`${snapshots.unmatched} failed`)));
68
+ if (snapshots.updated) summary.push(c.bold(c.green(`${snapshots.updated} updated `)));
69
+ if (snapshots.filesRemoved) if (snapshots.didUpdate) summary.push(c.bold(c.green(`${snapshots.filesRemoved} files removed `)));
70
+ else summary.push(c.bold(c.yellow(`${snapshots.filesRemoved} files obsolete `)));
71
+ if (snapshots.filesRemovedList && snapshots.filesRemovedList.length) {
72
+ const [head, ...tail] = snapshots.filesRemovedList;
73
+ summary.push(`${c.gray(F_DOWN_RIGHT)} ${formatTestPath(rootDir, head)}`);
74
+ tail.forEach((key) => {
75
+ summary.push(` ${c.gray(F_DOT)} ${formatTestPath(rootDir, key)}`);
76
+ });
77
+ }
78
+ if (snapshots.unchecked) {
79
+ if (snapshots.didUpdate) summary.push(c.bold(c.green(`${snapshots.unchecked} removed`)));
80
+ else summary.push(c.bold(c.yellow(`${snapshots.unchecked} obsolete`)));
81
+ snapshots.uncheckedKeysByFile.forEach((uncheckedFile) => {
82
+ summary.push(`${c.gray(F_DOWN_RIGHT)} ${formatTestPath(rootDir, uncheckedFile.filePath)}`);
83
+ uncheckedFile.keys.forEach((key) => summary.push(` ${c.gray(F_DOT)} ${key}`));
84
+ });
85
+ }
86
+ return summary;
87
+ }
88
+ function countTestErrors(tasks) {
89
+ return tasks.reduce((c, i) => c + (i.result?.errors?.length || 0), 0);
90
+ }
91
+ function getStateString(tasks, name = "tests", showTotal = true) {
92
+ if (tasks.length === 0) return c.dim(`no ${name}`);
93
+ const passed = tasks.reduce((acc, i) => {
94
+ // Exclude expected failures from passed count
95
+ if (i.result?.state === "pass" && i.type === "test" && i.fails) return acc;
96
+ return i.result?.state === "pass" ? acc + 1 : acc;
97
+ }, 0);
98
+ const failed = tasks.reduce((acc, i) => i.result?.state === "fail" ? acc + 1 : acc, 0);
99
+ const skipped = tasks.reduce((acc, i) => i.mode === "skip" ? acc + 1 : acc, 0);
100
+ const todo = tasks.reduce((acc, i) => i.mode === "todo" ? acc + 1 : acc, 0);
101
+ const expectedFail = tasks.reduce((acc, i) => {
102
+ // Count tests that are marked as .fails and passed (which means they failed as expected)
103
+ if (i.result?.state === "pass" && i.type === "test" && i.fails) return acc + 1;
104
+ return acc;
105
+ }, 0);
106
+ return [
107
+ failed ? c.bold(c.red(`${failed} failed`)) : null,
108
+ passed ? c.bold(c.green(`${passed} passed`)) : null,
109
+ expectedFail ? c.cyan(`${expectedFail} expected fail`) : null,
110
+ skipped ? c.yellow(`${skipped} skipped`) : null,
111
+ todo ? c.gray(`${todo} todo`) : null
112
+ ].filter(Boolean).join(c.dim(" | ")) + (showTotal ? c.gray(` (${tasks.length})`) : "");
113
+ }
114
+ function getStateSymbol(task) {
115
+ if (task.mode === "todo") return todo;
116
+ if (task.mode === "skip") return skipped;
117
+ if (!task.result) return pending;
118
+ if (task.result.state === "run" || task.result.state === "queued") {
119
+ if (task.type === "suite") return pointer;
120
+ }
121
+ if (task.result.state === "pass") return task.meta?.benchmark ? benchmarkPass : testPass;
122
+ if (task.result.state === "fail") return task.type === "suite" ? suiteFail : taskFail;
123
+ return " ";
124
+ }
125
+ function formatTimeString(date) {
126
+ return date.toTimeString().split(" ")[0];
127
+ }
128
+ function formatTime(time) {
129
+ if (time > 1e3) return `${(time / 1e3).toFixed(2)}s`;
130
+ return `${Math.round(time)}ms`;
131
+ }
132
+ function formatProjectName(project, suffix = " ") {
133
+ if (!project?.name) return "";
134
+ if (!c.isColorSupported) return `|${project.name}|${suffix}`;
135
+ let background = project.color && c[`bg${capitalize(project.color)}`];
136
+ if (!background) background = labelDefaultColors[project.name.split("").reduce((acc, v, idx) => acc + v.charCodeAt(0) + idx, 0) % labelDefaultColors.length];
137
+ return c.black(background(` ${project.name} `)) + suffix;
138
+ }
139
+ function withLabel(color, label, message) {
140
+ const bgColor = `bg${color.charAt(0).toUpperCase()}${color.slice(1)}`;
141
+ return `${c.bold(c[bgColor](` ${label} `))} ${message ? c[color](message) : ""}`;
142
+ }
143
+ function padSummaryTitle(str) {
144
+ return c.dim(`${str.padStart(11)} `);
145
+ }
146
+ function truncateString(text, maxLength) {
147
+ const plainText = stripVTControlCharacters(text);
148
+ if (plainText.length <= maxLength) return text;
149
+ return `${plainText.slice(0, maxLength - 1)}…`;
150
+ }
151
+ function capitalize(text) {
152
+ return `${text[0].toUpperCase()}${text.slice(1)}`;
153
+ }
154
+ /**
155
+ * Returns the singular or plural form of a word based on the count.
156
+ */
157
+ function noun(count, singular, plural) {
158
+ if (count === 1) return singular;
159
+ return plural;
160
+ }
161
+
162
+ var utils = /*#__PURE__*/Object.freeze({
163
+ __proto__: null,
164
+ benchmarkPass: benchmarkPass,
165
+ countTestErrors: countTestErrors,
166
+ divider: divider,
167
+ errorBanner: errorBanner,
168
+ formatProjectName: formatProjectName,
169
+ formatTestPath: formatTestPath,
170
+ formatTime: formatTime,
171
+ formatTimeString: formatTimeString,
172
+ getStateString: getStateString,
173
+ getStateSymbol: getStateSymbol,
174
+ noun: noun,
175
+ padSummaryTitle: padSummaryTitle,
176
+ pending: pending,
177
+ pointer: pointer,
178
+ renderSnapshotSummary: renderSnapshotSummary,
179
+ separator: separator,
180
+ skipped: skipped,
181
+ suiteFail: suiteFail,
182
+ taskFail: taskFail,
183
+ testPass: testPass,
184
+ todo: todo,
185
+ truncateString: truncateString,
186
+ withLabel: withLabel
187
+ });
188
+
189
+ export { F_POINTER as F, taskFail as a, F_CHECK as b, F_DOWN_RIGHT as c, divider as d, errorBanner as e, formatTimeString as f, formatProjectName as g, getStateSymbol as h, getStateString as i, formatTime as j, countTestErrors as k, F_TREE_NODE_END as l, F_TREE_NODE_MIDDLE as m, noun as n, F_RIGHT as o, padSummaryTitle as p, renderSnapshotSummary as r, separator as s, truncateString as t, utils as u, withLabel as w };
@@ -1,7 +1,7 @@
1
1
  import { fileURLToPath, pathToFileURL } from 'node:url';
2
2
  import vm, { isContext, runInContext } from 'node:vm';
3
3
  import { dirname, basename, extname, normalize, resolve } from 'pathe';
4
- import { l as loadEnvironment, a as listenForErrors, e as emitModuleRunner } from './init.DICorXCo.js';
4
+ import { l as loadEnvironment, a as listenForErrors, e as emitModuleRunner } from './init.D98-gwRW.js';
5
5
  import { distDir } from '../path.js';
6
6
  import { createCustomConsole } from './console.3WNpx0tS.js';
7
7
  import fs from 'node:fs';
@@ -11,7 +11,7 @@ import { findNearestPackageData } from '@vitest/utils/resolver';
11
11
  import { dirname as dirname$1 } from 'node:path';
12
12
  import { CSS_LANGS_RE, KNOWN_ASSET_RE } from '@vitest/utils/constants';
13
13
  import { getDefaultRequestStubs } from '../module-evaluator.js';
14
- import { s as startVitestModuleRunner, V as VITEST_VM_CONTEXT_SYMBOL, c as createNodeImportMeta } from './startVitestModuleRunner.C3ZR-4J3.js';
14
+ import { s as startVitestModuleRunner, V as VITEST_VM_CONTEXT_SYMBOL, c as createNodeImportMeta } from './startVitestModuleRunner.bRl2_oI_.js';
15
15
  import { p as provideWorkerState } from './utils.BX5Fg8C4.js';
16
16
 
17
17
  function interopCommonJsModule(interopDefault, mod) {
@@ -1,6 +1,6 @@
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.EJLVE3es.js';
3
+ import { S as SerializedConfig } from './config.d.Cz9kPrQs.js';
4
4
  import { E as Environment } from './environment.d.CrsxCzP1.js';
5
5
  import { R as RuntimeRPC, a as RunnerRPC } from './rpc.d.BFMWpdph.js';
6
6
 
package/dist/cli.js CHANGED
@@ -1,29 +1,11 @@
1
- import { c as createCLI } from './chunks/cac.CWGDZnXT.js';
1
+ import { c as createCLI } from './chunks/cac.DRKYQDPl.js';
2
2
  import '@vitest/utils/helpers';
3
3
  import 'events';
4
4
  import 'pathe';
5
5
  import 'tinyrainbow';
6
- import './chunks/constants.CPYnjOGj.js';
7
- import './chunks/index.DXMFO5MJ.js';
8
- import 'node:fs';
9
- import 'node:perf_hooks';
10
- import '@vitest/runner/utils';
11
- import '@vitest/utils/source-map';
12
6
  import './chunks/env.D4Lgay0q.js';
13
7
  import 'std-env';
14
- import 'node:console';
15
- import 'node:stream';
16
- import 'node:util';
17
- import '@vitest/utils/display';
18
- import 'node:os';
19
- import 'tinyexec';
20
- import './path.js';
21
- import 'node:path';
22
- import 'node:url';
23
- import 'vite';
24
- import '@vitest/utils/offset';
25
- import 'node:fs/promises';
26
- import 'node:module';
8
+ import './chunks/constants.CPYnjOGj.js';
27
9
  import 'node:assert';
28
10
 
29
11
  createCLI().parse();