vitest 3.0.0-beta.2 → 3.0.0-beta.3

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 (34) hide show
  1. package/dist/browser.d.ts +2 -2
  2. package/dist/chunks/{RandomSequencer.gisBJ77r.js → RandomSequencer.C6x84bNN.js} +4 -3
  3. package/dist/chunks/{base.CUgXReRN.js → base.CQ2VEtuH.js} +1 -1
  4. package/dist/chunks/{cac.Xzv7eNWw.js → cac.e7qW4xLT.js} +19 -8
  5. package/dist/chunks/{cli-api.CETCDGgZ.js → cli-api.CWDlED-m.js} +244 -39
  6. package/dist/chunks/{creator.DcAcUhMD.js → creator.Ot9GlSGw.js} +16 -14
  7. package/dist/chunks/{index.DoV7W5gc.js → index.BBoOXW-l.js} +5 -0
  8. package/dist/chunks/{index.9ZEBV_TJ.js → index.CzkCSFCy.js} +37 -24
  9. package/dist/chunks/{reporters.DTtxC3KQ.d.ts → reporters.DCiyjXOg.d.ts} +131 -102
  10. package/dist/chunks/{resolveConfig.BA-_OKEx.js → resolveConfig.C1d7TK-U.js} +25 -3
  11. package/dist/chunks/{runBaseTests.D0dWpzZV.js → runBaseTests.qNWRkgHj.js} +1 -1
  12. package/dist/chunks/{utils.CMUTX-p8.js → utils.Coei4Wlj.js} +1 -1
  13. package/dist/chunks/{vite.CXaetSK3.d.ts → vite.CRSMFy31.d.ts} +1 -1
  14. package/dist/chunks/{worker.ClntunZp.d.ts → worker.R-PA7DpW.d.ts} +1 -1
  15. package/dist/chunks/{worker.o1PBoDdo.d.ts → worker.XbtCXEXv.d.ts} +1 -0
  16. package/dist/cli.js +1 -1
  17. package/dist/config.cjs +1 -0
  18. package/dist/config.d.ts +3 -3
  19. package/dist/config.js +1 -0
  20. package/dist/coverage.d.ts +1 -1
  21. package/dist/coverage.js +33 -8
  22. package/dist/execute.d.ts +1 -1
  23. package/dist/index.d.ts +5 -5
  24. package/dist/node.d.ts +5 -5
  25. package/dist/node.js +10 -10
  26. package/dist/reporters.d.ts +1 -1
  27. package/dist/reporters.js +3 -3
  28. package/dist/runners.js +2 -2
  29. package/dist/workers/forks.js +1 -1
  30. package/dist/workers/runVmTests.js +1 -1
  31. package/dist/workers/threads.js +1 -1
  32. package/dist/workers.d.ts +2 -2
  33. package/dist/workers.js +1 -1
  34. package/package.json +13 -13
@@ -1,5 +1,5 @@
1
1
  import * as _vitest_runner from '@vitest/runner';
2
- import { File, TaskResultPack, Task, TaskMeta, Suite, SequenceHooks, SequenceSetupFiles, CancelReason } from '@vitest/runner';
2
+ import { TaskMeta, Suite, File, TaskResultPack, Task, SequenceHooks, SequenceSetupFiles, CancelReason } from '@vitest/runner';
3
3
  import { b as Awaitable, U as UserConsoleLog, A as AfterSuiteRunMeta, c as Arrayable$1, f as EnvironmentOptions, P as ProvidedContext } from './environment.d8YfPkTm.js';
4
4
  import { TestError, ParsedStack, Arrayable, ErrorWithDiff, Awaitable as Awaitable$1 } from '@vitest/utils';
5
5
  import { Writable } from 'node:stream';
@@ -27,86 +27,6 @@ type SerializedTestSpecification = [
27
27
  }
28
28
  ];
29
29
 
30
- interface Reporter {
31
- onInit?: (ctx: Vitest) => void;
32
- onPathsCollected?: (paths?: string[]) => Awaitable<void>;
33
- onSpecsCollected?: (specs?: SerializedTestSpecification[]) => Awaitable<void>;
34
- onCollected?: (files?: File[]) => Awaitable<void>;
35
- onFinished?: (files: File[], errors: unknown[], coverage?: unknown) => Awaitable<void>;
36
- onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
37
- onTestRemoved?: (trigger?: string) => Awaitable<void>;
38
- onWatcherStart?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
39
- onWatcherRerun?: (files: string[], trigger?: string) => Awaitable<void>;
40
- onServerRestart?: (reason?: string) => Awaitable<void>;
41
- onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
42
- onProcessTimeout?: () => Awaitable<void>;
43
- }
44
-
45
- interface BaseOptions {
46
- isTTY?: boolean;
47
- }
48
- declare abstract class BaseReporter implements Reporter {
49
- start: number;
50
- end: number;
51
- watchFilters?: string[];
52
- failedUnwatchedFiles: Task[];
53
- isTTY: boolean;
54
- ctx: Vitest;
55
- renderSucceed: boolean;
56
- protected verbose: boolean;
57
- private _filesInWatchMode;
58
- private _timeStart;
59
- constructor(options?: BaseOptions);
60
- onInit(ctx: Vitest): void;
61
- log(...messages: any): void;
62
- error(...messages: any): void;
63
- relative(path: string): string;
64
- onFinished(files?: File[], errors?: unknown[]): void;
65
- onTaskUpdate(packs: TaskResultPack[]): void;
66
- protected printTask(task: Task): void;
67
- private getDurationPrefix;
68
- onWatcherStart(files?: File[], errors?: unknown[]): void;
69
- onWatcherRerun(files: string[], trigger?: string): void;
70
- onUserConsoleLog(log: UserConsoleLog): void;
71
- onTestRemoved(trigger?: string): void;
72
- shouldLog(log: UserConsoleLog): boolean;
73
- onServerRestart(reason?: string): void;
74
- reportSummary(files: File[], errors: unknown[]): void;
75
- reportTestSummary(files: File[], errors: unknown[]): void;
76
- private printErrorsSummary;
77
- reportBenchmarkSummary(files: File[]): void;
78
- private printTaskErrors;
79
- }
80
-
81
- interface BlobOptions {
82
- outputFile?: string;
83
- }
84
- declare class BlobReporter implements Reporter {
85
- ctx: Vitest;
86
- options: BlobOptions;
87
- constructor(options: BlobOptions);
88
- onInit(ctx: Vitest): void;
89
- onFinished(files: File[] | undefined, errors: unknown[] | undefined, coverage: unknown): Promise<void>;
90
- }
91
-
92
- interface DefaultReporterOptions extends BaseOptions {
93
- summary?: boolean;
94
- }
95
- declare class DefaultReporter extends BaseReporter {
96
- private options;
97
- private summary?;
98
- constructor(options?: DefaultReporterOptions);
99
- onInit(ctx: Vitest): void;
100
- onPathsCollected(paths?: string[]): void;
101
- onTaskUpdate(packs: TaskResultPack[]): void;
102
- onWatcherRerun(files: string[], trigger?: string): void;
103
- onFinished(files?: File[], errors?: unknown[]): void;
104
- }
105
-
106
- interface HTMLOptions {
107
- outputFile?: string;
108
- }
109
-
110
30
  declare class ReportedTaskImplementation {
111
31
  /**
112
32
  * The project assosiacted with the test or suite.
@@ -279,7 +199,7 @@ interface TaskOptions {
279
199
  shuffle: boolean | undefined;
280
200
  retry: number | undefined;
281
201
  repeats: number | undefined;
282
- mode: 'run' | 'only' | 'skip' | 'todo';
202
+ mode: 'run' | 'only' | 'skip' | 'todo' | 'queued';
283
203
  }
284
204
  type TestResult = TestResultPassed | TestResultFailed | TestResultSkipped;
285
205
  interface TestResultPassed {
@@ -375,6 +295,88 @@ interface ModuleDiagnostic {
375
295
  duration: number;
376
296
  }
377
297
 
298
+ interface Reporter {
299
+ onInit?: (ctx: Vitest) => void;
300
+ onPathsCollected?: (paths?: string[]) => Awaitable<void>;
301
+ onSpecsCollected?: (specs?: SerializedTestSpecification[]) => Awaitable<void>;
302
+ onTestModuleQueued?: (file: TestModule) => Awaitable<void>;
303
+ onCollected?: (files?: File[]) => Awaitable<void>;
304
+ onFinished?: (files: File[], errors: unknown[], coverage?: unknown) => Awaitable<void>;
305
+ onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
306
+ onTestRemoved?: (trigger?: string) => Awaitable<void>;
307
+ onWatcherStart?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
308
+ onWatcherRerun?: (files: string[], trigger?: string) => Awaitable<void>;
309
+ onServerRestart?: (reason?: string) => Awaitable<void>;
310
+ onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
311
+ onProcessTimeout?: () => Awaitable<void>;
312
+ }
313
+
314
+ interface BaseOptions {
315
+ isTTY?: boolean;
316
+ }
317
+ declare abstract class BaseReporter implements Reporter {
318
+ start: number;
319
+ end: number;
320
+ watchFilters?: string[];
321
+ failedUnwatchedFiles: Task[];
322
+ isTTY: boolean;
323
+ ctx: Vitest;
324
+ renderSucceed: boolean;
325
+ protected verbose: boolean;
326
+ private _filesInWatchMode;
327
+ private _timeStart;
328
+ constructor(options?: BaseOptions);
329
+ onInit(ctx: Vitest): void;
330
+ log(...messages: any): void;
331
+ error(...messages: any): void;
332
+ relative(path: string): string;
333
+ onFinished(files?: File[], errors?: unknown[]): void;
334
+ onTaskUpdate(packs: TaskResultPack[]): void;
335
+ protected printTask(task: Task): void;
336
+ private getDurationPrefix;
337
+ onWatcherStart(files?: File[], errors?: unknown[]): void;
338
+ onWatcherRerun(files: string[], trigger?: string): void;
339
+ onUserConsoleLog(log: UserConsoleLog): void;
340
+ onTestRemoved(trigger?: string): void;
341
+ shouldLog(log: UserConsoleLog): boolean;
342
+ onServerRestart(reason?: string): void;
343
+ reportSummary(files: File[], errors: unknown[]): void;
344
+ reportTestSummary(files: File[], errors: unknown[]): void;
345
+ private printErrorsSummary;
346
+ reportBenchmarkSummary(files: File[]): void;
347
+ private printTaskErrors;
348
+ }
349
+
350
+ interface BlobOptions {
351
+ outputFile?: string;
352
+ }
353
+ declare class BlobReporter implements Reporter {
354
+ ctx: Vitest;
355
+ options: BlobOptions;
356
+ constructor(options: BlobOptions);
357
+ onInit(ctx: Vitest): void;
358
+ onFinished(files: File[] | undefined, errors: unknown[] | undefined, coverage: unknown): Promise<void>;
359
+ }
360
+
361
+ interface DefaultReporterOptions extends BaseOptions {
362
+ summary?: boolean;
363
+ }
364
+ declare class DefaultReporter extends BaseReporter {
365
+ private options;
366
+ private summary?;
367
+ constructor(options?: DefaultReporterOptions);
368
+ onTestModuleQueued(file: TestModule): void;
369
+ onInit(ctx: Vitest): void;
370
+ onPathsCollected(paths?: string[]): void;
371
+ onTaskUpdate(packs: TaskResultPack[]): void;
372
+ onWatcherRerun(files: string[], trigger?: string): void;
373
+ onFinished(files?: File[], errors?: unknown[]): void;
374
+ }
375
+
376
+ interface HTMLOptions {
377
+ outputFile?: string;
378
+ }
379
+
378
380
  declare class BasicReporter extends BaseReporter {
379
381
  constructor();
380
382
  onInit(ctx: Vitest): void;
@@ -2195,8 +2197,9 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'
2195
2197
  maxWorkers: number;
2196
2198
  minWorkers: number;
2197
2199
  }
2198
- type NonProjectOptions = 'shard' | 'watch' | 'run' | 'cache' | 'update' | 'reporters' | 'outputFile' | 'teardownTimeout' | 'silent' | 'forceRerunTriggers' | 'testNamePattern' | 'ui' | 'open' | 'uiBase' | 'snapshotFormat' | 'resolveSnapshotPath' | 'passWithNoTests' | 'onConsoleLog' | 'onStackTrace' | 'dangerouslyIgnoreUnhandledErrors' | 'slowTestThreshold' | 'inspect' | 'inspectBrk' | 'coverage' | 'maxWorkers' | 'minWorkers' | 'fileParallelism';
2199
- type ProjectConfig = Omit<UserConfig, NonProjectOptions | 'sequencer' | 'deps' | 'poolOptions'> & {
2200
+ type NonProjectOptions = 'shard' | 'watch' | 'run' | 'cache' | 'update' | 'reporters' | 'outputFile' | 'teardownTimeout' | 'silent' | 'forceRerunTriggers' | 'testNamePattern' | 'ui' | 'open' | 'uiBase' | 'snapshotFormat' | 'resolveSnapshotPath' | 'passWithNoTests' | 'onConsoleLog' | 'onStackTrace' | 'dangerouslyIgnoreUnhandledErrors' | 'slowTestThreshold' | 'inspect' | 'inspectBrk' | 'coverage' | 'maxWorkers' | 'minWorkers' | 'fileParallelism' | 'workspace';
2201
+ type ProjectConfig = Omit<InlineConfig, NonProjectOptions | 'sequencer' | 'deps' | 'poolOptions'> & {
2202
+ mode?: string;
2200
2203
  sequencer?: Omit<SequenceOptions, 'sequencer' | 'seed'>;
2201
2204
  deps?: Omit<DepsOptions, 'moduleDirectories'>;
2202
2205
  poolOptions?: {
@@ -2241,9 +2244,9 @@ interface BrowserProvider {
2241
2244
  getSupportedBrowsers: () => readonly string[];
2242
2245
  beforeCommand?: (command: string, args: unknown[]) => Awaitable$1<void>;
2243
2246
  afterCommand?: (command: string, args: unknown[]) => Awaitable$1<void>;
2244
- getCommandsContext: (contextId: string) => Record<string, unknown>;
2245
- openPage: (contextId: string, url: string, beforeNavigate?: () => Promise<void>) => Promise<void>;
2246
- getCDPSession?: (contextId: string) => Promise<CDPSession>;
2247
+ getCommandsContext: (sessionId: string) => Record<string, unknown>;
2248
+ openPage: (sessionId: string, url: string, beforeNavigate?: () => Promise<void>) => Promise<void>;
2249
+ getCDPSession?: (sessionId: string) => Promise<CDPSession>;
2247
2250
  close: () => Awaitable$1<void>;
2248
2251
  initialize(ctx: TestProject, options: BrowserProviderInitializationOptions): Awaitable$1<void>;
2249
2252
  }
@@ -2253,6 +2256,13 @@ interface BrowserProviderModule {
2253
2256
  interface BrowserProviderOptions {
2254
2257
  }
2255
2258
  type BrowserBuiltinProvider = 'webdriverio' | 'playwright' | 'preview';
2259
+ type UnsupportedProperties = 'browser' | 'typecheck' | 'alias' | 'sequence' | 'root' | 'pool' | 'poolOptions' | 'runner' | 'api' | 'deps' | 'testTransformMode' | 'poolMatchGlobs' | 'environmentMatchGlobs' | 'environment' | 'environmentOptions' | 'server' | 'benchmark';
2260
+ interface BrowserInstanceOption extends BrowserProviderOptions, Omit<ProjectConfig, UnsupportedProperties>, Pick<BrowserConfigOptions, 'headless' | 'locators' | 'viewport' | 'testerHtmlPath' | 'screenshotDirectory' | 'screenshotFailures'> {
2261
+ /**
2262
+ * Name of the browser
2263
+ */
2264
+ browser: string;
2265
+ }
2256
2266
  interface BrowserConfigOptions {
2257
2267
  /**
2258
2268
  * if running tests in the browser should be the default
@@ -2262,8 +2272,13 @@ interface BrowserConfigOptions {
2262
2272
  enabled?: boolean;
2263
2273
  /**
2264
2274
  * Name of the browser
2275
+ * @deprecated use `configs` instead. if both are defined, this will filter `configs` by name.
2265
2276
  */
2266
- name: string;
2277
+ name?: string;
2278
+ /**
2279
+ * Configurations for different browser setups
2280
+ */
2281
+ instances?: BrowserInstanceOption[];
2267
2282
  /**
2268
2283
  * Browser provider
2269
2284
  *
@@ -2279,6 +2294,7 @@ interface BrowserConfigOptions {
2279
2294
  *
2280
2295
  * @example
2281
2296
  * { playwright: { launch: { devtools: true } }
2297
+ * @deprecated use `configs` instead
2282
2298
  */
2283
2299
  providerOptions?: BrowserProviderOptions;
2284
2300
  /**
@@ -2368,16 +2384,25 @@ interface BrowserConfigOptions {
2368
2384
  * @see {@link https://vitest.dev/guide/browser/commands}
2369
2385
  */
2370
2386
  commands?: Record<string, BrowserCommand<any>>;
2387
+ /**
2388
+ * Timeout for connecting to the browser
2389
+ * @default 30000
2390
+ */
2391
+ connectTimeout?: number;
2371
2392
  }
2372
2393
  interface BrowserCommandContext {
2373
2394
  testPath: string | undefined;
2374
2395
  provider: BrowserProvider;
2375
2396
  project: TestProject;
2397
+ /** @deprecated use `sessionId` instead */
2376
2398
  contextId: string;
2399
+ sessionId: string;
2377
2400
  }
2378
- interface BrowserServerStateContext {
2401
+ interface BrowserServerStateSession {
2379
2402
  files: string[];
2380
2403
  method: 'run' | 'collect';
2404
+ project: TestProject;
2405
+ connected: () => void;
2381
2406
  resolve: () => void;
2382
2407
  reject: (v: unknown) => void;
2383
2408
  }
@@ -2388,15 +2413,16 @@ interface BrowserOrchestrator {
2388
2413
  }
2389
2414
  interface BrowserServerState {
2390
2415
  orchestrators: Map<string, BrowserOrchestrator>;
2391
- getContext: (contextId: string) => BrowserServerStateContext | undefined;
2392
- createAsyncContext: (method: 'collect' | 'run', contextId: string, files: string[]) => Promise<void>;
2393
2416
  }
2394
- interface BrowserServer {
2417
+ interface ParentProjectBrowser {
2418
+ spawn: (project: TestProject) => ProjectBrowser;
2419
+ }
2420
+ interface ProjectBrowser {
2395
2421
  vite: ViteDevServer;
2396
2422
  state: BrowserServerState;
2397
2423
  provider: BrowserProvider;
2398
2424
  close: () => Promise<void>;
2399
- initBrowserProvider: () => Promise<void>;
2425
+ initBrowserProvider: (project: TestProject) => Promise<void>;
2400
2426
  parseStacktrace: (stack: string) => ParsedStack[];
2401
2427
  parseErrorStacktrace: (error: ErrorWithDiff, options?: StackTraceParserOptions) => ParsedStack[];
2402
2428
  }
@@ -2432,6 +2458,8 @@ interface BrowserScript {
2432
2458
  type?: string;
2433
2459
  }
2434
2460
  interface ResolvedBrowserOptions extends BrowserConfigOptions {
2461
+ name: string;
2462
+ providerOptions?: BrowserProviderOptions;
2435
2463
  enabled: boolean;
2436
2464
  headless: boolean;
2437
2465
  isolate: boolean;
@@ -2451,7 +2479,6 @@ interface ResolvedBrowserOptions extends BrowserConfigOptions {
2451
2479
  declare class TestProject {
2452
2480
  /** @deprecated */
2453
2481
  path: string | number;
2454
- /** @deprecated */
2455
2482
  options?: InitializeProjectOptions | undefined;
2456
2483
  /**
2457
2484
  * The global Vitest instance.
@@ -2465,7 +2492,7 @@ declare class TestProject {
2465
2492
  /**
2466
2493
  * Browser instance if the browser is enabled. This is initialized when the tests run for the first time.
2467
2494
  */
2468
- browser?: BrowserServer;
2495
+ browser?: ProjectBrowser;
2469
2496
  /** @deprecated use `vitest` instead */
2470
2497
  ctx: Vitest;
2471
2498
  /**
@@ -2478,13 +2505,10 @@ declare class TestProject {
2478
2505
  private typecheckFilesList;
2479
2506
  private _globalSetups?;
2480
2507
  private _provided;
2481
- private _config?;
2482
2508
  private _vite?;
2483
2509
  constructor(
2484
2510
  /** @deprecated */
2485
- path: string | number, vitest: Vitest,
2486
- /** @deprecated */
2487
- options?: InitializeProjectOptions | undefined);
2511
+ path: string | number, vitest: Vitest, options?: InitializeProjectOptions | undefined);
2488
2512
  /**
2489
2513
  * Provide a value to the test context. This value will be available to all tests with `inject`.
2490
2514
  */
@@ -2686,7 +2710,7 @@ declare class StateManager {
2686
2710
  taskFileMap: WeakMap<Task, File>;
2687
2711
  errorsSet: Set<unknown>;
2688
2712
  processTimeoutCauses: Set<string>;
2689
- reportedTasksMap: WeakMap<Task, TestCase | TestSuite | TestModule>;
2713
+ reportedTasksMap: WeakMap<Task, TestModule | TestCase | TestSuite>;
2690
2714
  catchError(err: unknown, type: string): void;
2691
2715
  clearErrors(): void;
2692
2716
  getUnhandledErrors(): unknown[];
@@ -2704,7 +2728,7 @@ declare class StateManager {
2704
2728
  collectFiles(project: TestProject, files?: File[]): void;
2705
2729
  clearFiles(project: TestProject, paths?: string[]): void;
2706
2730
  updateId(task: Task, project: TestProject): void;
2707
- getReportedEntity(task: Task): TestCase | TestSuite | TestModule | undefined;
2731
+ getReportedEntity(task: Task): TestModule | TestCase | TestSuite | undefined;
2708
2732
  updateTasks(packs: TaskResultPack[]): void;
2709
2733
  updateUserLog(log: UserConsoleLog): void;
2710
2734
  getCountOfFailedTests(): number;
@@ -2894,6 +2918,11 @@ declare class Vitest {
2894
2918
  */
2895
2919
  cancelCurrentRun(reason: CancelReason): Promise<void>;
2896
2920
  private initializeGlobalSetup;
2921
+ /**
2922
+ * Update snapshots in specified files. If no files are provided, it will update files with failed tests and obsolete snapshots.
2923
+ * @param files The list of files on the file system
2924
+ */
2925
+ updateSnapshot(files?: string[]): Promise<TestRunResult>;
2897
2926
  /**
2898
2927
  * Enable the mode that allows updating snapshots when running tests.
2899
2928
  * This method doesn't run any tests.
@@ -2976,4 +3005,4 @@ declare class Vitest {
2976
3005
  type OnServerRestartHandler = (reason?: string) => Promise<void> | void;
2977
3006
  type OnTestsRerunHandler = (testFiles: TestSpecification[]) => Promise<void> | void;
2978
3007
 
2979
- export { type JUnitOptions as $, type ApiConfig as A, type BaseCoverageOptions as B, CoverageMap as C, type DepsOptimizationOptions as D, TestProject as E, type TestSequencer as F, TestSpecification as G, TestModule as H, type InlineConfig as I, type OnTestsRerunHandler as J, VitestPackageInstaller as K, Logger as L, type ModuleDiagnostic as M, type ProcessPool as N, type OnServerRestartHandler as O, type Pool as P, type WorkspaceSpec as Q, type ResolvedCoverageOptions as R, type SerializedTestSpecification as S, type TestProjectConfiguration as T, type UserWorkspaceConfig as U, Vitest as V, type WorkspaceProjectConfiguration as W, getFilePoolName as X, type SerializedTestProject as Y, type HTMLOptions as Z, type JsonOptions$1 as _, type ReportContext as a, type TaskOptions as a0, TestCase as a1, TestCollection as a2, type TestDiagnostic as a3, type TestResult as a4, type TestResultFailed as a5, type TestResultPassed as a6, type TestResultSkipped as a7, TestSuite as a8, type TestSequencerConstructor as a9, VerboseReporter as aA, BaseReporter as aB, TestFile as aC, type FileDiagnostic as aD, ReportersMap as aE, type BuiltinReporters as aF, type BuiltinReporterOptions as aG, type JsonAssertionResult as aH, type JsonTestResult as aI, type JsonTestResults as aJ, BenchmarkReportsMap as aK, type BenchmarkBuiltinReporters as aL, type BrowserBuiltinProvider as aa, type BrowserCommand as ab, type BrowserCommandContext as ac, type BrowserOrchestrator as ad, type BrowserProvider as ae, type BrowserProviderInitializationOptions as af, type BrowserProviderModule as ag, type BrowserProviderOptions as ah, type BrowserServer as ai, type BrowserServerState as aj, type BrowserServerStateContext as ak, type CDPSession as al, type ResolvedBrowserOptions as am, type ResolvedProjectConfig as an, type ResolveSnapshotPathHandler as ao, type ResolveSnapshotPathHandlerContext as ap, type TestRunResult as aq, BasicReporter as ar, DefaultReporter as as, DotReporter as at, GithubActionsReporter as au, HangingProcessReporter as av, JsonReporter as aw, JUnitReporter as ax, TapFlatReporter as ay, TapReporter as az, type CoverageProvider as b, type CoverageProviderModule as c, type CoverageV8Options as d, type UserProjectConfigFn as e, type UserProjectConfigExport as f, type CoverageReporter as g, type CoverageProviderName as h, type CoverageOptions as i, type CoverageIstanbulOptions as j, type CustomProviderOptions as k, type Reporter as l, type BrowserScript as m, type BrowserConfigOptions as n, type BuiltinEnvironment as o, type VitestEnvironment as p, type PoolOptions as q, type CSSModuleScopeStrategy as r, type VitestRunMode as s, type TransformModePatterns as t, type TypecheckConfig as u, type UserConfig as v, type ResolvedConfig as w, type ProjectConfig as x, type BenchmarkUserOptions as y, type VitestOptions as z };
3008
+ export { type JUnitOptions as $, type ApiConfig as A, type BaseCoverageOptions as B, CoverageMap as C, type DepsOptimizationOptions as D, TestProject as E, type TestSequencer as F, TestSpecification as G, TestModule as H, type InlineConfig as I, type OnTestsRerunHandler as J, VitestPackageInstaller as K, Logger as L, type ModuleDiagnostic as M, type ProcessPool as N, type OnServerRestartHandler as O, type Pool as P, type WorkspaceSpec as Q, type ResolvedCoverageOptions as R, type SerializedTestSpecification as S, type TestProjectConfiguration as T, type UserWorkspaceConfig as U, Vitest as V, type WorkspaceProjectConfiguration as W, getFilePoolName as X, type SerializedTestProject as Y, type HTMLOptions as Z, type JsonOptions$1 as _, type ReportContext as a, type TaskOptions as a0, TestCase as a1, TestCollection as a2, type TestDiagnostic as a3, type TestResult as a4, type TestResultFailed as a5, type TestResultPassed as a6, type TestResultSkipped as a7, TestSuite as a8, type TestSequencerConstructor as a9, TapFlatReporter as aA, TapReporter as aB, VerboseReporter as aC, BaseReporter as aD, TestFile as aE, type FileDiagnostic as aF, ReportersMap as aG, type BuiltinReporters as aH, type BuiltinReporterOptions as aI, type JsonAssertionResult as aJ, type JsonTestResult as aK, type JsonTestResults as aL, BenchmarkReportsMap as aM, type BenchmarkBuiltinReporters as aN, type BrowserBuiltinProvider as aa, type BrowserCommand as ab, type BrowserCommandContext as ac, type BrowserInstanceOption as ad, type BrowserOrchestrator as ae, type BrowserProvider as af, type BrowserProviderInitializationOptions as ag, type BrowserProviderModule as ah, type BrowserProviderOptions as ai, type BrowserServerState as aj, type BrowserServerStateSession as ak, type CDPSession as al, type ParentProjectBrowser as am, type ProjectBrowser as an, type ResolvedBrowserOptions as ao, type ResolvedProjectConfig as ap, type ResolveSnapshotPathHandler as aq, type ResolveSnapshotPathHandlerContext as ar, type TestRunResult as as, BasicReporter as at, DefaultReporter as au, DotReporter as av, GithubActionsReporter as aw, HangingProcessReporter as ax, JsonReporter as ay, JUnitReporter as az, type CoverageProvider as b, type CoverageProviderModule as c, type CoverageV8Options as d, type UserProjectConfigFn as e, type UserProjectConfigExport as f, type CoverageReporter as g, type CoverageProviderName as h, type CoverageOptions as i, type CoverageIstanbulOptions as j, type CustomProviderOptions as k, type Reporter as l, type BrowserScript as m, type BrowserConfigOptions as n, type BuiltinEnvironment as o, type VitestEnvironment as p, type PoolOptions as q, type CSSModuleScopeStrategy as r, type VitestRunMode as s, type TransformModePatterns as t, type TypecheckConfig as u, type UserConfig as v, type ResolvedConfig as w, type ProjectConfig as x, type BenchmarkUserOptions as y, type VitestOptions as z };
@@ -13,7 +13,7 @@ import c from 'tinyrainbow';
13
13
  import { e as extraInlineDeps, d as defaultPort, a as defaultBrowserPort, b as defaultInspectPort } from './constants.fzPh7AOq.js';
14
14
  import * as nodeos from 'node:os';
15
15
  import nodeos__default from 'node:os';
16
- import { h as hash, w as wrapSerializableConfig, T as Typechecker, i as isWindows, R as RandomSequencer, B as BaseSequencer } from './RandomSequencer.gisBJ77r.js';
16
+ import { h as hash, w as wrapSerializableConfig, T as Typechecker, i as isWindows, R as RandomSequencer, B as BaseSequencer } from './RandomSequencer.C6x84bNN.js';
17
17
  import { isCI, provider } from 'std-env';
18
18
  import { g as getDefaultExportFromCjs } from './_commonjsHelpers.BFTU3MAI.js';
19
19
  import require$$0 from 'util';
@@ -6662,6 +6662,11 @@ function createMethodsRPC(project, options = {}) {
6662
6662
  ctx.state.collectPaths(paths);
6663
6663
  return ctx.report("onPathsCollected", paths);
6664
6664
  },
6665
+ onQueued(file) {
6666
+ ctx.state.collectFiles(project, [file]);
6667
+ const testModule = ctx.state.getReportedEntity(file);
6668
+ return ctx.report("onTestModuleQueued", testModule);
6669
+ },
6665
6670
  onCollected(files) {
6666
6671
  ctx.state.collectFiles(project, files);
6667
6672
  return ctx.report("onCollected", files);
@@ -7868,8 +7873,24 @@ function resolveConfig(mode, options, viteConfig, logger) {
7868
7873
  );
7869
7874
  }
7870
7875
  }
7871
- if (resolved.browser.enabled && !(resolved.browser.provider === "playwright" && resolved.browser.name === "chromium")) {
7872
- const browserConfig = { browser: { provider: resolved.browser.provider, name: resolved.browser.name } };
7876
+ const browser = resolved.browser;
7877
+ if (browser.enabled) {
7878
+ if (!browser.name && !browser.instances) {
7879
+ throw new Error(`Vitest Browser Mode requires "browser.name" (deprecated) or "browser.instances" options, none were set.`);
7880
+ }
7881
+ const configs = browser.instances;
7882
+ if (browser.name && browser.instances) {
7883
+ browser.instances = browser.instances.filter((instance) => instance.browser === browser.name);
7884
+ }
7885
+ if (browser.instances && !browser.instances.length) {
7886
+ throw new Error([
7887
+ `"browser.instances" was set in the config, but the array is empty. Define at least one browser config.`,
7888
+ browser.name && configs?.length ? ` The "browser.name" was set to "${browser.name}" which filtered all configs (${configs.map((c2) => c2.browser).join(", ")}). Did you mean to use another name?` : ""
7889
+ ].join(""));
7890
+ }
7891
+ }
7892
+ if (browser.enabled && !(browser.provider === "playwright" && browser.name === "chromium")) {
7893
+ const browserConfig = { browser: { provider: browser.provider, name: browser.name } };
7873
7894
  if (resolved.coverage.enabled && resolved.coverage.provider === "v8") {
7874
7895
  throw new Error(
7875
7896
  `@vitest/coverage-v8 does not work with
@@ -8140,6 +8161,7 @@ ${JSON.stringify({ browser: { provider: "playwright", name: "chromium" } }, null
8140
8161
  ...resolved.benchmark
8141
8162
  };
8142
8163
  resolved.coverage.enabled = false;
8164
+ resolved.typecheck.enabled = false;
8143
8165
  resolved.include = resolved.benchmark.include;
8144
8166
  resolved.exclude = resolved.benchmark.exclude;
8145
8167
  resolved.includeSource = resolved.benchmark.includeSource;
@@ -1,6 +1,6 @@
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.DoV7W5gc.js';
3
+ import { a as resolveSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './index.BBoOXW-l.js';
4
4
  import { s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './coverage.BWeNbfBa.js';
5
5
  import { a as globalExpect, v as vi } from './vi.S4Fq8wSo.js';
6
6
  import { c as closeInspector } from './inspector.DKLceBVD.js';
@@ -126,7 +126,7 @@ function getStateSymbol(task) {
126
126
  if (!task.result) {
127
127
  return pending;
128
128
  }
129
- if (task.result.state === "run") {
129
+ if (task.result.state === "run" || task.result.state === "queued") {
130
130
  if (task.type === "suite") {
131
131
  return pointer;
132
132
  }
@@ -1,4 +1,4 @@
1
- import { I as InlineConfig } from './reporters.DTtxC3KQ.js';
1
+ import { I as InlineConfig } from './reporters.DCiyjXOg.js';
2
2
 
3
3
  type VitestInlineConfig = InlineConfig;
4
4
  declare module 'vite' {
@@ -1,5 +1,5 @@
1
1
  import { MessagePort } from 'node:worker_threads';
2
- import { C as ContextRPC } from './worker.o1PBoDdo.js';
2
+ import { C as ContextRPC } from './worker.XbtCXEXv.js';
3
3
 
4
4
  interface WorkerContext extends ContextRPC {
5
5
  port: MessagePort;
@@ -104,6 +104,7 @@ interface RuntimeRPC {
104
104
  onPathsCollected: (paths: string[]) => void;
105
105
  onUserConsoleLog: (log: UserConsoleLog) => void;
106
106
  onUnhandledError: (err: unknown, type: string) => void;
107
+ onQueued: (file: File) => void;
107
108
  onCollected: (files: File[]) => Promise<void>;
108
109
  onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void;
109
110
  onTaskUpdate: (pack: TaskResultPack[]) => Promise<void>;
package/dist/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- import { c as createCLI } from './chunks/cac.Xzv7eNWw.js';
1
+ import { c as createCLI } from './chunks/cac.e7qW4xLT.js';
2
2
  import '@vitest/utils';
3
3
  import 'events';
4
4
  import 'pathe';
package/dist/config.cjs CHANGED
@@ -15,6 +15,7 @@ const extraInlineDeps = [
15
15
  const isNode = typeof process < "u" && typeof process.stdout < "u" && !process.versions?.deno && !globalThis.window;
16
16
  const isDeno = typeof process < "u" && typeof process.stdout < "u" && process.versions?.deno !== void 0;
17
17
  (isNode || isDeno) && process.platform === "win32";
18
+ (isNode || isDeno) && process.stdout?.isTTY && !stdEnv.isCI;
18
19
 
19
20
  const defaultInclude = ["**/*.{test,spec}.?(c|m)[jt]s?(x)"];
20
21
  const defaultExclude = [
package/dist/config.d.ts CHANGED
@@ -1,8 +1,8 @@
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, d as CoverageV8Options, U as UserWorkspaceConfig, e as UserProjectConfigFn, f as UserProjectConfigExport, T as TestProjectConfiguration } from './chunks/reporters.DTtxC3KQ.js';
4
- export { W as WorkspaceProjectConfiguration } from './chunks/reporters.DTtxC3KQ.js';
5
- import './chunks/vite.CXaetSK3.js';
3
+ import { R as ResolvedCoverageOptions, d as CoverageV8Options, U as UserWorkspaceConfig, e as UserProjectConfigFn, f as UserProjectConfigExport, T as TestProjectConfiguration } from './chunks/reporters.DCiyjXOg.js';
4
+ export { W as WorkspaceProjectConfiguration } from './chunks/reporters.DCiyjXOg.js';
5
+ import './chunks/vite.CRSMFy31.js';
6
6
  import '@vitest/runner';
7
7
  import './chunks/environment.d8YfPkTm.js';
8
8
  import '@vitest/utils';
package/dist/config.js CHANGED
@@ -13,6 +13,7 @@ const extraInlineDeps = [
13
13
  const isNode = typeof process < "u" && typeof process.stdout < "u" && !process.versions?.deno && !globalThis.window;
14
14
  const isDeno = typeof process < "u" && typeof process.stdout < "u" && process.versions?.deno !== void 0;
15
15
  (isNode || isDeno) && process.platform === "win32";
16
+ (isNode || isDeno) && process.stdout?.isTTY && !isCI;
16
17
 
17
18
  const defaultInclude = ["**/*.{test,spec}.?(c|m)[jt]s?(x)"];
18
19
  const defaultExclude = [
@@ -1,5 +1,5 @@
1
1
  import * as vite from 'vite';
2
- import { R as ResolvedCoverageOptions, V as Vitest, C as CoverageMap, a as ReportContext } from './chunks/reporters.DTtxC3KQ.js';
2
+ import { R as ResolvedCoverageOptions, V as Vitest, C as CoverageMap, a as ReportContext } from './chunks/reporters.DCiyjXOg.js';
3
3
  import { A as AfterSuiteRunMeta } from './chunks/environment.d8YfPkTm.js';
4
4
  import '@vitest/runner';
5
5
  import '@vitest/utils';
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.BA-_OKEx.js';
2
+ import { c as coverageConfigDefaults, r as resolveCoverageReporters, m as mm } from './chunks/resolveConfig.C1d7TK-U.js';
3
3
  import { resolve, relative } from 'pathe';
4
4
  import c from 'tinyrainbow';
5
5
  import '@vitest/utils';
@@ -13,7 +13,7 @@ import 'node:v8';
13
13
  import 'node:util';
14
14
  import './chunks/constants.fzPh7AOq.js';
15
15
  import 'node:os';
16
- import './chunks/RandomSequencer.gisBJ77r.js';
16
+ import './chunks/RandomSequencer.C6x84bNN.js';
17
17
  import 'std-env';
18
18
  import 'node:perf_hooks';
19
19
  import '@vitest/runner/utils';
@@ -271,7 +271,10 @@ Update your dependencies and make sure the versions match.`
271
271
  for (const { summary, file } of summaries) {
272
272
  for (const thresholdKey of THRESHOLD_KEYS) {
273
273
  const threshold = thresholds[thresholdKey];
274
- if (threshold !== void 0) {
274
+ if (threshold === void 0) {
275
+ continue;
276
+ }
277
+ if (threshold >= 0) {
275
278
  const coverage = summary.data[thresholdKey].pct;
276
279
  if (coverage < threshold) {
277
280
  process.exitCode = 1;
@@ -281,6 +284,17 @@ Update your dependencies and make sure the versions match.`
281
284
  }
282
285
  this.ctx.logger.error(errorMessage);
283
286
  }
287
+ } else {
288
+ const uncovered = summary.data[thresholdKey].total - summary.data[thresholdKey].covered;
289
+ const absoluteThreshold = threshold * -1;
290
+ if (uncovered > absoluteThreshold) {
291
+ process.exitCode = 1;
292
+ let errorMessage = `ERROR: Uncovered ${thresholdKey} (${uncovered}) exceed ${name === GLOBAL_THRESHOLDS_KEY ? name : `"${name}"`} threshold (${absoluteThreshold})`;
293
+ if (this.options.thresholds?.perFile && file) {
294
+ errorMessage += ` for ${relative("./", file).replace(/\\/g, "/")}`;
295
+ }
296
+ this.ctx.logger.error(errorMessage);
297
+ }
284
298
  }
285
299
  }
286
300
  }
@@ -300,11 +314,22 @@ Update your dependencies and make sure the versions match.`
300
314
  const thresholdsToUpdate = [];
301
315
  for (const key of THRESHOLD_KEYS) {
302
316
  const threshold = thresholds[key] ?? 100;
303
- const actual = Math.min(
304
- ...summaries.map((summary) => summary[key].pct)
305
- );
306
- if (actual > threshold) {
307
- thresholdsToUpdate.push([key, actual]);
317
+ if (threshold >= 0) {
318
+ const actual = Math.min(
319
+ ...summaries.map((summary) => summary[key].pct)
320
+ );
321
+ if (actual > threshold) {
322
+ thresholdsToUpdate.push([key, actual]);
323
+ }
324
+ } else {
325
+ const absoluteThreshold = threshold * -1;
326
+ const actual = Math.max(
327
+ ...summaries.map((summary) => summary[key].total - summary[key].covered)
328
+ );
329
+ if (actual < absoluteThreshold) {
330
+ const updatedThreshold = actual === 0 ? 100 : actual * -1;
331
+ thresholdsToUpdate.push([key, updatedThreshold]);
332
+ }
308
333
  }
309
334
  }
310
335
  if (thresholdsToUpdate.length === 0) {
package/dist/execute.d.ts CHANGED
@@ -1,6 +1,6 @@
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.o1PBoDdo.js';
3
+ import { R as RuntimeRPC, W as WorkerGlobalState } from './chunks/worker.XbtCXEXv.js';
4
4
  import vm from 'node:vm';
5
5
  import * as _vitest_mocker from '@vitest/mocker';
6
6
  import { MockedModuleType } from '@vitest/mocker';
package/dist/index.d.ts CHANGED
@@ -1,13 +1,13 @@
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 { S as SerializedTestSpecification, b as CoverageProvider$1, a as ReportContext$1, c as CoverageProviderModule$1, g as CoverageReporter$1, h as CoverageProviderName, i as CoverageOptions$1, R as ResolvedCoverageOptions$1, B as BaseCoverageOptions$1, j as CoverageIstanbulOptions$1, d as CoverageV8Options$1, k as CustomProviderOptions$1, l as Reporter$1, V as Vitest$1, m as BrowserScript$1, n as BrowserConfigOptions$1, o as BuiltinEnvironment$1, p as VitestEnvironment$1, P as Pool$1, q as PoolOptions$1, r as CSSModuleScopeStrategy$1, A as ApiConfig$1, s as VitestRunMode$1, D as DepsOptimizationOptions$1, t as TransformModePatterns$1, I as InlineConfig$1, u as TypecheckConfig$1, v as UserConfig$1, w as ResolvedConfig$1, x as ProjectConfig$1, U as UserWorkspaceConfig$1, y as BenchmarkUserOptions$1 } from './chunks/reporters.DTtxC3KQ.js';
4
- import { W as WorkerContext$1 } from './chunks/worker.ClntunZp.js';
3
+ import { S as SerializedTestSpecification, b as CoverageProvider$1, a as ReportContext$1, c as CoverageProviderModule$1, g as CoverageReporter$1, h as CoverageProviderName, i as CoverageOptions$1, R as ResolvedCoverageOptions$1, B as BaseCoverageOptions$1, j as CoverageIstanbulOptions$1, d as CoverageV8Options$1, k as CustomProviderOptions$1, l as Reporter$1, V as Vitest$1, m as BrowserScript$1, n as BrowserConfigOptions$1, o as BuiltinEnvironment$1, p as VitestEnvironment$1, P as Pool$1, q as PoolOptions$1, r as CSSModuleScopeStrategy$1, A as ApiConfig$1, s as VitestRunMode$1, D as DepsOptimizationOptions$1, t as TransformModePatterns$1, I as InlineConfig$1, u as TypecheckConfig$1, v as UserConfig$1, w as ResolvedConfig$1, x as ProjectConfig$1, U as UserWorkspaceConfig$1, y as BenchmarkUserOptions$1 } from './chunks/reporters.DCiyjXOg.js';
4
+ import { W as WorkerContext$1 } from './chunks/worker.R-PA7DpW.js';
5
5
  import { R as RawErrsMap$1, T as TscErrorInfo$1, C as CollectLineNumbers$1, a as CollectLines$1, b as RootAndTarget$1, c as Context$1 } from './chunks/types.BOjykUpq.js';
6
6
  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, 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.d8YfPkTm.js';
7
7
  export { A as AfterSuiteRunMeta, g as ModuleCache } from './chunks/environment.d8YfPkTm.js';
8
- import { a as BirpcReturn, b as WorkerRPC$1 } from './chunks/worker.o1PBoDdo.js';
9
- export { C as ContextRPC, d as ContextTestEnvironment, e as ResolveIdFunction, c as RunnerRPC, R as RuntimeRPC, W as WorkerGlobalState } from './chunks/worker.o1PBoDdo.js';
10
- import './chunks/vite.CXaetSK3.js';
8
+ import { a as BirpcReturn, b as WorkerRPC$1 } from './chunks/worker.XbtCXEXv.js';
9
+ export { C as ContextRPC, d as ContextTestEnvironment, e as ResolveIdFunction, c as RunnerRPC, R as RuntimeRPC, W as WorkerGlobalState } from './chunks/worker.XbtCXEXv.js';
10
+ import './chunks/vite.CRSMFy31.js';
11
11
  import { PromisifyAssertion, Tester, ExpectStatic } from '@vitest/expect';
12
12
  export { Assertion, AsymmetricMatchersContaining, ExpectPollOptions, ExpectStatic, JestAssertion } from '@vitest/expect';
13
13
  import { Plugin } from '@vitest/pretty-format';