vitest 0.18.0 → 0.19.1

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 (36) hide show
  1. package/LICENSE.md +6 -6
  2. package/dist/browser.d.ts +1850 -0
  3. package/dist/browser.mjs +20 -0
  4. package/dist/{chunk-api-setup.63babd7c.mjs → chunk-api-setup.0cf2c96a.mjs} +37 -11
  5. package/dist/{chunk-constants.8eb2ed35.mjs → chunk-constants.38b43a44.mjs} +3 -3
  6. package/dist/{chunk-env-node.26c72624.mjs → chunk-defaults.ed196a9a.mjs} +458 -455
  7. package/dist/{chunk-install-pkg.2dcb2c04.mjs → chunk-install-pkg.6c6dc0c2.mjs} +11 -10
  8. package/dist/chunk-integrations-globals.1018e651.mjs +24 -0
  9. package/dist/chunk-node-git.9058b82a.mjs +1139 -0
  10. package/dist/chunk-runtime-chain.f2e00f4c.mjs +2039 -0
  11. package/dist/{vendor-entry.78de67ab.mjs → chunk-runtime-error.606e0393.mjs} +167 -183
  12. package/dist/{chunk-runtime-chain.eb764dff.mjs → chunk-runtime-hooks.d4cadf47.mjs} +33 -2012
  13. package/dist/{chunk-runtime-mocker.79ccc3de.mjs → chunk-runtime-mocker.dfdfd57b.mjs} +70 -22
  14. package/dist/{chunk-runtime-rpc.cc6a06a2.mjs → chunk-runtime-rpc.45d8ee19.mjs} +1 -1
  15. package/dist/{chunk-utils-global.1b22c4fd.mjs → chunk-utils-global.2aa95025.mjs} +11 -6
  16. package/dist/{chunk-utils-source-map.957e7756.mjs → chunk-utils-source-map.8b066ce2.mjs} +2 -2
  17. package/dist/{chunk-vite-node-externalize.0791f2ed.mjs → chunk-vite-node-externalize.e9af6472.mjs} +105 -1174
  18. package/dist/chunk-vite-node-utils.ad73f2ab.mjs +1433 -0
  19. package/dist/cli.mjs +9 -11
  20. package/dist/config.cjs +4 -1
  21. package/dist/config.d.ts +1 -0
  22. package/dist/config.mjs +4 -1
  23. package/dist/entry.mjs +54 -10
  24. package/dist/index.d.ts +56 -27
  25. package/dist/index.mjs +12 -9
  26. package/dist/node.d.ts +37 -18
  27. package/dist/node.mjs +10 -12
  28. package/dist/spy.mjs +102 -2
  29. package/dist/suite.mjs +13 -0
  30. package/dist/vendor-index.61438b77.mjs +335 -0
  31. package/dist/{vendor-index.4bf9c627.mjs → vendor-index.62ce5c33.mjs} +11 -343
  32. package/dist/worker.mjs +6 -6
  33. package/package.json +20 -12
  34. package/dist/chunk-integrations-globals.61e4d6ae.mjs +0 -26
  35. package/dist/chunk-integrations-spy.674b628e.mjs +0 -102
  36. package/dist/chunk-vite-node-utils.af8ead96.mjs +0 -9195
@@ -0,0 +1,1850 @@
1
+ import { ViteDevServer, TransformResult, CommonServerOptions, AliasOptions } from 'vite';
2
+ import { Stats } from 'fs';
3
+ import { MessagePort } from 'worker_threads';
4
+ import { SpyImpl } from 'tinyspy';
5
+ import * as chai from 'chai';
6
+ export { chai };
7
+ export { assert, should } from 'chai';
8
+
9
+ /**
10
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
11
+ *
12
+ * This source code is licensed under the MIT license found in the
13
+ * LICENSE file in the root directory of this source tree.
14
+ */
15
+ declare type Colors = {
16
+ comment: {
17
+ close: string;
18
+ open: string;
19
+ };
20
+ content: {
21
+ close: string;
22
+ open: string;
23
+ };
24
+ prop: {
25
+ close: string;
26
+ open: string;
27
+ };
28
+ tag: {
29
+ close: string;
30
+ open: string;
31
+ };
32
+ value: {
33
+ close: string;
34
+ open: string;
35
+ };
36
+ };
37
+ declare type Indent = (arg0: string) => string;
38
+ declare type Refs = Array<unknown>;
39
+ declare type Print = (arg0: unknown) => string;
40
+ declare type ThemeReceived = {
41
+ comment?: string;
42
+ content?: string;
43
+ prop?: string;
44
+ tag?: string;
45
+ value?: string;
46
+ };
47
+ declare type CompareKeys = ((a: string, b: string) => number) | undefined;
48
+ interface PrettyFormatOptions {
49
+ callToJSON?: boolean;
50
+ compareKeys?: CompareKeys;
51
+ escapeRegex?: boolean;
52
+ escapeString?: boolean;
53
+ highlight?: boolean;
54
+ indent?: number;
55
+ maxDepth?: number;
56
+ min?: boolean;
57
+ plugins?: Plugins;
58
+ printBasicPrototype?: boolean;
59
+ printFunctionName?: boolean;
60
+ theme?: ThemeReceived;
61
+ }
62
+ declare type OptionsReceived = PrettyFormatOptions;
63
+ declare type Config = {
64
+ callToJSON: boolean;
65
+ compareKeys: CompareKeys;
66
+ colors: Colors;
67
+ escapeRegex: boolean;
68
+ escapeString: boolean;
69
+ indent: string;
70
+ maxDepth: number;
71
+ min: boolean;
72
+ plugins: Plugins;
73
+ printBasicPrototype: boolean;
74
+ printFunctionName: boolean;
75
+ spacingInner: string;
76
+ spacingOuter: string;
77
+ };
78
+ declare type Printer = (val: unknown, config: Config, indentation: string, depth: number, refs: Refs, hasCalledToJSON?: boolean) => string;
79
+ declare type Test$1 = (arg0: any) => boolean;
80
+ declare type NewPlugin = {
81
+ serialize: (val: any, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer) => string;
82
+ test: Test$1;
83
+ };
84
+ declare type PluginOptions = {
85
+ edgeSpacing: string;
86
+ min: boolean;
87
+ spacing: string;
88
+ };
89
+ declare type OldPlugin = {
90
+ print: (val: unknown, print: Print, indent: Indent, options: PluginOptions, colors: Colors) => string;
91
+ test: Test$1;
92
+ };
93
+ declare type Plugin = NewPlugin | OldPlugin;
94
+ declare type Plugins = Array<Plugin>;
95
+
96
+ // Type definitions for @sinonjs/fake-timers 8.1
97
+ // Project: https://github.com/sinonjs/fake-timers
98
+ // Definitions by: Wim Looman <https://github.com/Nemo157>
99
+ // Rogier Schouten <https://github.com/rogierschouten>
100
+ // Yishai Zehavi <https://github.com/zyishai>
101
+ // Remco Haszing <https://github.com/remcohaszing>
102
+ // Jaden Simon <https://github.com/JadenSimon>
103
+ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
104
+ // TypeScript Version: 2.3
105
+
106
+ /**
107
+ * Names of clock methods that may be faked by install.
108
+ */
109
+ type FakeMethod =
110
+ | 'setTimeout'
111
+ | 'clearTimeout'
112
+ | 'setImmediate'
113
+ | 'clearImmediate'
114
+ | 'setInterval'
115
+ | 'clearInterval'
116
+ | 'Date'
117
+ | 'nextTick'
118
+ | 'hrtime'
119
+ | 'requestAnimationFrame'
120
+ | 'cancelAnimationFrame'
121
+ | 'requestIdleCallback'
122
+ | 'cancelIdleCallback'
123
+ | 'performance'
124
+ | 'queueMicrotask';
125
+
126
+ interface FakeTimerInstallOpts {
127
+ /**
128
+ * Installs fake timers with the specified unix epoch (default: 0)
129
+ */
130
+ now?: number | Date | undefined;
131
+
132
+ /**
133
+ * An array with names of global methods and APIs to fake. By default, `@sinonjs/fake-timers` does not replace `nextTick()` and `queueMicrotask()`.
134
+ * For instance, `FakeTimers.install({ toFake: ['setTimeout', 'nextTick'] })` will fake only `setTimeout()` and `nextTick()`
135
+ */
136
+ toFake?: FakeMethod[] | undefined;
137
+
138
+ /**
139
+ * The maximum number of timers that will be run when calling runAll() (default: 1000)
140
+ */
141
+ loopLimit?: number | undefined;
142
+
143
+ /**
144
+ * Tells @sinonjs/fake-timers to increment mocked time automatically based on the real system time shift (e.g. the mocked time will be incremented by
145
+ * 20ms for every 20ms change in the real system time) (default: false)
146
+ */
147
+ shouldAdvanceTime?: boolean | undefined;
148
+
149
+ /**
150
+ * Relevant only when using with shouldAdvanceTime: true. increment mocked time by advanceTimeDelta ms every advanceTimeDelta ms change
151
+ * in the real system time (default: 20)
152
+ */
153
+ advanceTimeDelta?: number | undefined;
154
+
155
+ /**
156
+ * Tells FakeTimers to clear 'native' (i.e. not fake) timers by delegating to their respective handlers. These are not cleared by
157
+ * default, leading to potentially unexpected behavior if timers existed prior to installing FakeTimers. (default: false)
158
+ */
159
+ shouldClearNativeTimers?: boolean | undefined;
160
+ }
161
+
162
+ interface UpdatePayload {
163
+ type: 'update'
164
+ updates: Update[]
165
+ }
166
+
167
+ interface Update {
168
+ type: 'js-update' | 'css-update'
169
+ path: string
170
+ acceptedPath: string
171
+ timestamp: number
172
+ }
173
+
174
+ interface PrunePayload {
175
+ type: 'prune'
176
+ paths: string[]
177
+ }
178
+
179
+ interface FullReloadPayload {
180
+ type: 'full-reload'
181
+ path?: string
182
+ }
183
+
184
+ interface ErrorPayload {
185
+ type: 'error'
186
+ err: {
187
+ [name: string]: any
188
+ message: string
189
+ stack: string
190
+ id?: string
191
+ frame?: string
192
+ plugin?: string
193
+ pluginCode?: string
194
+ loc?: {
195
+ file?: string
196
+ line: number
197
+ column: number
198
+ }
199
+ }
200
+ }
201
+
202
+ interface CustomEventMap {
203
+ 'vite:beforeUpdate': UpdatePayload
204
+ 'vite:beforePrune': PrunePayload
205
+ 'vite:beforeFullReload': FullReloadPayload
206
+ 'vite:error': ErrorPayload
207
+ }
208
+
209
+ type InferCustomEventPayload<T extends string> =
210
+ T extends keyof CustomEventMap ? CustomEventMap[T] : any
211
+
212
+ interface ViteHotContext {
213
+ readonly data: any
214
+
215
+ accept(): void
216
+ accept(cb: (mod: any) => void): void
217
+ accept(dep: string, cb: (mod: any) => void): void
218
+ accept(deps: readonly string[], cb: (mods: any[]) => void): void
219
+
220
+ /**
221
+ * @deprecated
222
+ */
223
+ acceptDeps(): never
224
+
225
+ dispose(cb: (data: any) => void): void
226
+ decline(): void
227
+ invalidate(): void
228
+
229
+ on<T extends string>(
230
+ event: T,
231
+ cb: (payload: InferCustomEventPayload<T>) => void
232
+ ): void
233
+ send<T extends string>(event: T, data?: InferCustomEventPayload<T>): void
234
+ }
235
+ declare class ModuleCacheMap extends Map<string, ModuleCache$1> {
236
+ normalizePath(fsPath: string): string;
237
+ set(fsPath: string, mod: Partial<ModuleCache$1>): this;
238
+ get(fsPath: string): ModuleCache$1 | undefined;
239
+ delete(fsPath: string): boolean;
240
+ }
241
+ declare class ViteNodeRunner {
242
+ options: ViteNodeRunnerOptions;
243
+ root: string;
244
+ debug: boolean;
245
+ /**
246
+ * Holds the cache of modules
247
+ * Keys of the map are filepaths, or plain package names
248
+ */
249
+ moduleCache: ModuleCacheMap;
250
+ constructor(options: ViteNodeRunnerOptions);
251
+ executeFile(file: string): Promise<any>;
252
+ executeId(id: string): Promise<any>;
253
+ /** @internal */
254
+ cachedRequest(rawId: string, callstack: string[]): Promise<any>;
255
+ /** @internal */
256
+ directRequest(id: string, fsPath: string, _callstack: string[]): Promise<any>;
257
+ prepareContext(context: Record<string, any>): Record<string, any>;
258
+ shouldResolveId(dep: string): boolean;
259
+ /**
260
+ * Define if a module should be interop-ed
261
+ * This function mostly for the ability to override by subclass
262
+ */
263
+ shouldInterop(path: string, mod: any): boolean;
264
+ /**
265
+ * Import a module and interop it
266
+ */
267
+ interopedImport(path: string): Promise<any>;
268
+ hasNestedDefault(target: any): any;
269
+ private debugLog;
270
+ }
271
+ interface DepsHandlingOptions {
272
+ external?: (string | RegExp)[];
273
+ inline?: (string | RegExp)[] | true;
274
+ /**
275
+ * Try to guess the CJS version of a package when it's invalid ESM
276
+ * @default false
277
+ */
278
+ fallbackCJS?: boolean;
279
+ }
280
+ interface StartOfSourceMap {
281
+ file?: string;
282
+ sourceRoot?: string;
283
+ }
284
+ interface RawSourceMap extends StartOfSourceMap {
285
+ version: string;
286
+ sources: string[];
287
+ names: string[];
288
+ sourcesContent?: string[];
289
+ mappings: string;
290
+ }
291
+ interface FetchResult {
292
+ code?: string;
293
+ externalize?: string;
294
+ map?: RawSourceMap;
295
+ }
296
+ declare type HotContext = Omit<ViteHotContext, 'acceptDeps' | 'decline'>;
297
+ declare type FetchFunction = (id: string) => Promise<FetchResult>;
298
+ declare type ResolveIdFunction$1 = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
299
+ declare type CreateHotContextFunction = (runner: ViteNodeRunner, url: string) => HotContext;
300
+ interface ModuleCache$1 {
301
+ promise?: Promise<any>;
302
+ exports?: any;
303
+ code?: string;
304
+ }
305
+ interface ViteNodeRunnerOptions {
306
+ root: string;
307
+ fetchModule: FetchFunction;
308
+ resolveId?: ResolveIdFunction$1;
309
+ createHotContext?: CreateHotContextFunction;
310
+ base?: string;
311
+ moduleCache?: ModuleCacheMap;
312
+ interopDefault?: boolean;
313
+ requestStubs?: Record<string, any>;
314
+ debug?: boolean;
315
+ }
316
+ interface ViteNodeResolveId {
317
+ external?: boolean | 'absolute' | 'relative';
318
+ id: string;
319
+ meta?: Record<string, any> | null;
320
+ moduleSideEffects?: boolean | 'no-treeshake' | null;
321
+ syntheticNamedExports?: boolean | string | null;
322
+ }
323
+ interface ViteNodeServerOptions {
324
+ /**
325
+ * Inject inline sourcemap to modules
326
+ * @default 'inline'
327
+ */
328
+ sourcemap?: 'inline' | boolean;
329
+ /**
330
+ * Deps handling
331
+ */
332
+ deps?: DepsHandlingOptions;
333
+ /**
334
+ * Transform method for modules
335
+ */
336
+ transformMode?: {
337
+ ssr?: RegExp[];
338
+ web?: RegExp[];
339
+ };
340
+ }
341
+
342
+ declare class ViteNodeServer {
343
+ server: ViteDevServer;
344
+ options: ViteNodeServerOptions;
345
+ private fetchPromiseMap;
346
+ private transformPromiseMap;
347
+ fetchCache: Map<string, {
348
+ timestamp: number;
349
+ result: FetchResult;
350
+ }>;
351
+ constructor(server: ViteDevServer, options?: ViteNodeServerOptions);
352
+ shouldExternalize(id: string): Promise<string | false>;
353
+ resolveId(id: string, importer?: string): Promise<ViteNodeResolveId | null>;
354
+ fetchModule(id: string): Promise<FetchResult>;
355
+ transformRequest(id: string): Promise<TransformResult | null | undefined>;
356
+ getTransformMode(id: string): "web" | "ssr";
357
+ private _fetchModule;
358
+ private _transformRequest;
359
+ }
360
+
361
+ declare class SnapshotManager {
362
+ options: SnapshotStateOptions;
363
+ summary: SnapshotSummary;
364
+ extension: string;
365
+ constructor(options: SnapshotStateOptions);
366
+ clear(): void;
367
+ add(result: SnapshotResult): void;
368
+ resolvePath(testPath: string): string;
369
+ }
370
+
371
+ declare type RunWithFiles = (files: string[], invalidates?: string[]) => Promise<void>;
372
+ interface WorkerPool {
373
+ runTests: RunWithFiles;
374
+ close: () => Promise<void>;
375
+ }
376
+
377
+ declare class StateManager {
378
+ filesMap: Map<string, File>;
379
+ pathsSet: Set<string>;
380
+ idMap: Map<string, Task>;
381
+ taskFileMap: WeakMap<Task, File>;
382
+ errorsSet: Set<unknown>;
383
+ catchError(err: unknown, type: string): void;
384
+ clearErrors(): void;
385
+ getUnhandledErrors(): unknown[];
386
+ getPaths(): string[];
387
+ getFiles(keys?: string[]): File[];
388
+ getFilepaths(): string[];
389
+ getFailedFilepaths(): string[];
390
+ collectPaths(paths?: string[]): void;
391
+ collectFiles(files?: File[]): void;
392
+ clearFiles(paths?: string[]): void;
393
+ updateId(task: Task): void;
394
+ updateTasks(packs: TaskResultPack[]): void;
395
+ updateUserLog(log: UserConsoleLog): void;
396
+ }
397
+
398
+ declare class Logger {
399
+ ctx: Vitest;
400
+ console: Console;
401
+ outputStream: NodeJS.WriteStream & {
402
+ fd: 1;
403
+ };
404
+ errorStream: NodeJS.WriteStream & {
405
+ fd: 2;
406
+ };
407
+ logUpdate: ((...text: string[]) => void) & {
408
+ clear(): void;
409
+ done(): void;
410
+ };
411
+ private _clearScreenPending;
412
+ constructor(ctx: Vitest, console?: Console);
413
+ log(...args: any[]): void;
414
+ error(...args: any[]): void;
415
+ warn(...args: any[]): void;
416
+ clearScreen(message: string, force?: boolean): void;
417
+ private _clearScreen;
418
+ printError(err: unknown, fullStack?: boolean, type?: string): Promise<void>;
419
+ printNoTestFound(filters?: string[]): void;
420
+ printBanner(): void;
421
+ printUnhandledErrors(errors: unknown[]): Promise<void>;
422
+ }
423
+
424
+ interface SuiteResultCache {
425
+ failed: boolean;
426
+ duration: number;
427
+ }
428
+ declare class ResultsCache {
429
+ private cache;
430
+ private cachePath;
431
+ private version;
432
+ private root;
433
+ getCachePath(): string | null;
434
+ setConfig(root: string, config: ResolvedConfig['cache']): void;
435
+ getResults(fsPath: string): SuiteResultCache | undefined;
436
+ readFromCache(): Promise<void>;
437
+ updateResults(files: File[]): void;
438
+ removeFromCache(filepath: string): void;
439
+ writeToCache(): Promise<void>;
440
+ }
441
+
442
+ interface CliOptions extends UserConfig {
443
+ /**
444
+ * Override the watch mode
445
+ */
446
+ run?: boolean;
447
+ }
448
+
449
+ declare type FileStatsCache = Pick<Stats, 'size'>;
450
+ declare class FilesStatsCache {
451
+ cache: Map<string, FileStatsCache>;
452
+ getStats(fsPath: string): FileStatsCache | undefined;
453
+ updateStats(fsPath: string): Promise<void>;
454
+ removeStats(fsPath: string): void;
455
+ }
456
+
457
+ declare class VitestCache {
458
+ results: ResultsCache;
459
+ stats: FilesStatsCache;
460
+ getFileTestResults(id: string): SuiteResultCache | undefined;
461
+ getFileStats(id: string): {
462
+ size: number;
463
+ } | undefined;
464
+ static resolveCacheDir(root: string, dir: string | undefined): string;
465
+ static clearCache(options: CliOptions): Promise<{
466
+ dir: string;
467
+ cleared: boolean;
468
+ }>;
469
+ }
470
+
471
+ declare class Vitest {
472
+ config: ResolvedConfig;
473
+ configOverride: Partial<ResolvedConfig> | undefined;
474
+ server: ViteDevServer;
475
+ state: StateManager;
476
+ snapshot: SnapshotManager;
477
+ cache: VitestCache;
478
+ reporters: Reporter[];
479
+ logger: Logger;
480
+ pool: WorkerPool | undefined;
481
+ vitenode: ViteNodeServer;
482
+ invalidates: Set<string>;
483
+ changedTests: Set<string>;
484
+ runningPromise?: Promise<void>;
485
+ closingPromise?: Promise<void>;
486
+ isFirstRun: boolean;
487
+ restartsCount: number;
488
+ runner: ViteNodeRunner;
489
+ constructor();
490
+ private _onRestartListeners;
491
+ setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
492
+ getSerializableConfig(): ResolvedConfig;
493
+ start(filters?: string[]): Promise<void>;
494
+ private getTestDependencies;
495
+ filterTestsBySource(tests: string[]): Promise<string[]>;
496
+ runFiles(paths: string[]): Promise<void>;
497
+ rerunFiles(files?: string[], trigger?: string): Promise<void>;
498
+ changeNamePattern(pattern: string, files?: string[], trigger?: string): Promise<void>;
499
+ rerunFailed(): Promise<void>;
500
+ updateSnapshot(files?: string[]): Promise<void>;
501
+ private _rerunTimer;
502
+ private scheduleRerun;
503
+ private unregisterWatcher;
504
+ private registerWatcher;
505
+ /**
506
+ * @returns A value indicating whether rerun is needed (changedTests was mutated)
507
+ */
508
+ private handleFileChanged;
509
+ close(): Promise<void>;
510
+ exit(force?: boolean): Promise<void>;
511
+ report<T extends keyof Reporter>(name: T, ...args: ArgumentsType$1<Reporter[T]>): Promise<void>;
512
+ globTestFiles(filters?: string[]): Promise<string[]>;
513
+ isTargetFile(id: string, source?: string): Promise<boolean>;
514
+ isInSourceTestFile(code: string): boolean;
515
+ onServerRestarted(fn: () => void): void;
516
+ }
517
+
518
+ declare type MockMap = Map<string, Record<string, string | null | (() => unknown)>>;
519
+
520
+ interface TestSequencer {
521
+ /**
522
+ * Slicing tests into shards. Will be run before `sort`.
523
+ * Only run, if `shard` is defined.
524
+ */
525
+ shard(files: string[]): Awaitable<string[]>;
526
+ sort(files: string[]): Awaitable<string[]>;
527
+ }
528
+ interface TestSequencerConstructor {
529
+ new (ctx: Vitest): TestSequencer;
530
+ }
531
+
532
+ declare abstract class BaseReporter implements Reporter {
533
+ start: number;
534
+ end: number;
535
+ watchFilters?: string[];
536
+ isTTY: false;
537
+ ctx: Vitest;
538
+ private _filesInWatchMode;
539
+ private _lastRunTimeout;
540
+ private _lastRunTimer;
541
+ private _lastRunCount;
542
+ constructor();
543
+ onInit(ctx: Vitest): void;
544
+ relative(path: string): string;
545
+ onFinished(files?: File[], errors?: unknown[]): Promise<void>;
546
+ onTaskUpdate(packs: TaskResultPack[]): void;
547
+ onWatcherStart(): Promise<void>;
548
+ private resetLastRunLog;
549
+ onWatcherRerun(files: string[], trigger?: string): Promise<void>;
550
+ onUserConsoleLog(log: UserConsoleLog): void;
551
+ shouldLog(log: UserConsoleLog): boolean;
552
+ onServerRestart(): void;
553
+ reportSummary(files: File[]): Promise<void>;
554
+ private printTaskErrors;
555
+ registerUnhandledRejection(): void;
556
+ }
557
+
558
+ interface ListRendererOptions {
559
+ renderSucceed?: boolean;
560
+ logger: Logger;
561
+ showHeap: boolean;
562
+ }
563
+ declare const createListRenderer: (_tasks: Task[], options: ListRendererOptions) => {
564
+ start(): any;
565
+ update(_tasks: Task[]): any;
566
+ stop(): Promise<any>;
567
+ clear(): void;
568
+ };
569
+
570
+ declare class DefaultReporter extends BaseReporter {
571
+ renderer?: ReturnType<typeof createListRenderer>;
572
+ rendererOptions: ListRendererOptions;
573
+ onTestRemoved(trigger?: string): Promise<void>;
574
+ onCollected(): void;
575
+ onFinished(files?: File[], errors?: unknown[]): Promise<void>;
576
+ onWatcherStart(): Promise<void>;
577
+ stopListRender(): Promise<void>;
578
+ onWatcherRerun(files: string[], trigger?: string): Promise<void>;
579
+ onUserConsoleLog(log: UserConsoleLog): void;
580
+ }
581
+
582
+ declare class DotReporter extends BaseReporter {
583
+ renderer?: ReturnType<typeof createListRenderer>;
584
+ onCollected(): void;
585
+ onFinished(files?: File[], errors?: unknown[]): Promise<void>;
586
+ onWatcherStart(): Promise<void>;
587
+ stopListRender(): Promise<void>;
588
+ onWatcherRerun(files: string[], trigger?: string): Promise<void>;
589
+ onUserConsoleLog(log: UserConsoleLog): void;
590
+ }
591
+
592
+ interface Callsite {
593
+ line: number;
594
+ column: number;
595
+ }
596
+ declare class JsonReporter implements Reporter {
597
+ start: number;
598
+ ctx: Vitest;
599
+ onInit(ctx: Vitest): void;
600
+ protected logTasks(files: File[]): Promise<void>;
601
+ onFinished(files?: File[]): Promise<void>;
602
+ /**
603
+ * Writes the report to an output file if specified in the config,
604
+ * or logs it to the console otherwise.
605
+ * @param report
606
+ */
607
+ writeReport(report: string): Promise<void>;
608
+ protected getFailureLocation(test: Test): Callsite | undefined;
609
+ }
610
+
611
+ declare class VerboseReporter extends DefaultReporter {
612
+ constructor();
613
+ onTaskUpdate(packs: TaskResultPack[]): void;
614
+ }
615
+
616
+ declare class TapReporter implements Reporter {
617
+ protected ctx: Vitest;
618
+ private logger;
619
+ onInit(ctx: Vitest): void;
620
+ static getComment(task: Task): string;
621
+ private logErrorDetails;
622
+ protected logTasks(tasks: Task[]): void;
623
+ onFinished(files?: File[]): Promise<void>;
624
+ }
625
+
626
+ declare class JUnitReporter implements Reporter {
627
+ private ctx;
628
+ private reportFile?;
629
+ private baseLog;
630
+ private logger;
631
+ onInit(ctx: Vitest): Promise<void>;
632
+ writeElement(name: string, attrs: Record<string, any>, children: () => Promise<void>): Promise<void>;
633
+ writeErrorDetails(error: ErrorWithDiff): Promise<void>;
634
+ writeLogs(task: Task, type: 'err' | 'out'): Promise<void>;
635
+ writeTasks(tasks: Task[], filename: string): Promise<void>;
636
+ onFinished(files?: File[]): Promise<void>;
637
+ }
638
+
639
+ declare class TapFlatReporter extends TapReporter {
640
+ onInit(ctx: Vitest): void;
641
+ onFinished(files?: File[]): Promise<void>;
642
+ }
643
+
644
+ declare const ReportersMap: {
645
+ default: typeof DefaultReporter;
646
+ verbose: typeof VerboseReporter;
647
+ dot: typeof DotReporter;
648
+ json: typeof JsonReporter;
649
+ tap: typeof TapReporter;
650
+ 'tap-flat': typeof TapFlatReporter;
651
+ junit: typeof JUnitReporter;
652
+ };
653
+ declare type BuiltinReporters = keyof typeof ReportersMap;
654
+
655
+ declare type Awaitable<T> = T | PromiseLike<T>;
656
+ declare type Nullable<T> = T | null | undefined;
657
+ declare type Arrayable<T> = T | Array<T>;
658
+ declare type ArgumentsType$1<T> = T extends (...args: infer U) => any ? U : never;
659
+ declare type MergeInsertions<T> = T extends object ? {
660
+ [K in keyof T]: MergeInsertions<T[K]>;
661
+ } : T;
662
+ declare type DeepMerge<F, S> = MergeInsertions<{
663
+ [K in keyof F | keyof S]: K extends keyof S & keyof F ? DeepMerge<F[K], S[K]> : K extends keyof S ? S[K] : K extends keyof F ? F[K] : never;
664
+ }>;
665
+ declare type MutableArray<T extends readonly any[]> = {
666
+ -readonly [k in keyof T]: T[k];
667
+ };
668
+ interface Constructable$1 {
669
+ new (...args: any[]): any;
670
+ }
671
+ interface ModuleCache {
672
+ promise?: Promise<any>;
673
+ exports?: any;
674
+ code?: string;
675
+ }
676
+ interface EnvironmentReturn {
677
+ teardown: (global: any) => Awaitable<void>;
678
+ }
679
+ interface Environment {
680
+ name: string;
681
+ setup(global: any, options: Record<string, any>): Awaitable<EnvironmentReturn>;
682
+ }
683
+ interface UserConsoleLog {
684
+ content: string;
685
+ type: 'stdout' | 'stderr';
686
+ taskId?: string;
687
+ time: number;
688
+ size: number;
689
+ }
690
+ interface Position {
691
+ source?: string;
692
+ line: number;
693
+ column: number;
694
+ }
695
+ interface ParsedStack {
696
+ method: string;
697
+ file: string;
698
+ line: number;
699
+ column: number;
700
+ sourcePos?: Position;
701
+ }
702
+ interface ErrorWithDiff extends Error {
703
+ name: string;
704
+ nameStr?: string;
705
+ stack?: string;
706
+ stackStr?: string;
707
+ stacks?: ParsedStack[];
708
+ showDiff?: boolean;
709
+ actual?: any;
710
+ expected?: any;
711
+ operator?: string;
712
+ type?: string;
713
+ }
714
+ interface ModuleGraphData {
715
+ graph: Record<string, string[]>;
716
+ externalized: string[];
717
+ inlined: string[];
718
+ }
719
+
720
+ declare type CoverageReporter = 'clover' | 'cobertura' | 'html-spa' | 'html' | 'json-summary' | 'json' | 'lcov' | 'lcovonly' | 'none' | 'teamcity' | 'text-lcov' | 'text-summary' | 'text';
721
+ interface C8Options {
722
+ /**
723
+ * Enable coverage, pass `--coverage` to enable
724
+ *
725
+ * @default false
726
+ */
727
+ enabled?: boolean;
728
+ /**
729
+ * Directory to write coverage report to
730
+ */
731
+ reportsDirectory?: string;
732
+ /**
733
+ * Clean coverage before running tests
734
+ *
735
+ * @default true
736
+ */
737
+ clean?: boolean;
738
+ /**
739
+ * Clean coverage report on watch rerun
740
+ *
741
+ * @default false
742
+ */
743
+ cleanOnRerun?: boolean;
744
+ /**
745
+ * Allow files from outside of your cwd.
746
+ *
747
+ * @default false
748
+ */
749
+ allowExternal?: any;
750
+ /**
751
+ * Reporters
752
+ *
753
+ * @default 'text'
754
+ */
755
+ reporter?: Arrayable<CoverageReporter>;
756
+ /**
757
+ * Exclude coverage under /node_modules/
758
+ *
759
+ * @default true
760
+ */
761
+ excludeNodeModules?: boolean;
762
+ exclude?: string[];
763
+ include?: string[];
764
+ skipFull?: boolean;
765
+ extension?: string | string[];
766
+ all?: boolean;
767
+ src?: string[];
768
+ 100?: boolean;
769
+ lines?: number;
770
+ functions?: number;
771
+ branches?: number;
772
+ statements?: number;
773
+ }
774
+ interface ResolvedC8Options extends Required<C8Options> {
775
+ tempDirectory: string;
776
+ }
777
+
778
+ interface JSDOMOptions {
779
+ /**
780
+ * The html content for the test.
781
+ *
782
+ * @default '<!DOCTYPE html>'
783
+ */
784
+ html?: string | Buffer | ArrayBufferLike;
785
+ /**
786
+ * referrer just affects the value read from document.referrer.
787
+ * It defaults to no referrer (which reflects as the empty string).
788
+ */
789
+ referrer?: string;
790
+ /**
791
+ * userAgent affects the value read from navigator.userAgent, as well as the User-Agent header sent while fetching subresources.
792
+ *
793
+ * @default `Mozilla/5.0 (${process.platform}) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/${jsdomVersion}`
794
+ */
795
+ userAgent?: string;
796
+ /**
797
+ * url sets the value returned by window.location, document.URL, and document.documentURI,
798
+ * and affects things like resolution of relative URLs within the document
799
+ * and the same-origin restrictions and referrer used while fetching subresources.
800
+ *
801
+ * @default 'http://localhost:3000'.
802
+ */
803
+ url?: string;
804
+ /**
805
+ * contentType affects the value read from document.contentType, and how the document is parsed: as HTML or as XML.
806
+ * Values that are not "text/html" or an XML mime type will throw.
807
+ *
808
+ * @default 'text/html'.
809
+ */
810
+ contentType?: string;
811
+ /**
812
+ * The maximum size in code units for the separate storage areas used by localStorage and sessionStorage.
813
+ * Attempts to store data larger than this limit will cause a DOMException to be thrown. By default, it is set
814
+ * to 5,000,000 code units per origin, as inspired by the HTML specification.
815
+ *
816
+ * @default 5_000_000
817
+ */
818
+ storageQuota?: number;
819
+ /**
820
+ * Enable console?
821
+ *
822
+ * @default false
823
+ */
824
+ console?: boolean;
825
+ /**
826
+ * jsdom does not have the capability to render visual content, and will act like a headless browser by default.
827
+ * It provides hints to web pages through APIs such as document.hidden that their content is not visible.
828
+ *
829
+ * When the `pretendToBeVisual` option is set to `true`, jsdom will pretend that it is rendering and displaying
830
+ * content.
831
+ *
832
+ * @default true
833
+ */
834
+ pretendToBeVisual?: boolean;
835
+ /**
836
+ * `includeNodeLocations` preserves the location info produced by the HTML parser,
837
+ * allowing you to retrieve it with the nodeLocation() method (described below).
838
+ *
839
+ * It defaults to false to give the best performance,
840
+ * and cannot be used with an XML content type since our XML parser does not support location info.
841
+ *
842
+ * @default false
843
+ */
844
+ includeNodeLocations?: boolean | undefined;
845
+ /**
846
+ * @default 'dangerously'
847
+ */
848
+ runScripts?: 'dangerously' | 'outside-only';
849
+ /**
850
+ * Enable CookieJar
851
+ *
852
+ * @default false
853
+ */
854
+ cookieJar?: boolean;
855
+ resources?: 'usable' | any;
856
+ }
857
+
858
+ declare type ChainableFunction<T extends string, Args extends any[], R = any> = {
859
+ (...args: Args): R;
860
+ } & {
861
+ [x in T]: ChainableFunction<T, Args, R>;
862
+ };
863
+
864
+ declare type RunMode = 'run' | 'skip' | 'only' | 'todo';
865
+ declare type TaskState = RunMode | 'pass' | 'fail';
866
+ interface TaskBase {
867
+ id: string;
868
+ name: string;
869
+ mode: RunMode;
870
+ concurrent?: boolean;
871
+ shuffle?: boolean;
872
+ suite?: Suite;
873
+ file?: File;
874
+ result?: TaskResult;
875
+ logs?: UserConsoleLog[];
876
+ }
877
+ interface TaskResult {
878
+ state: TaskState;
879
+ duration?: number;
880
+ startTime?: number;
881
+ heap?: number;
882
+ error?: ErrorWithDiff;
883
+ htmlError?: string;
884
+ hooks?: Partial<Record<keyof SuiteHooks, TaskState>>;
885
+ }
886
+ declare type TaskResultPack = [id: string, result: TaskResult | undefined];
887
+ interface Suite extends TaskBase {
888
+ type: 'suite';
889
+ tasks: Task[];
890
+ filepath?: string;
891
+ }
892
+ interface File extends Suite {
893
+ filepath: string;
894
+ collectDuration?: number;
895
+ }
896
+ interface Test<ExtraContext = {}> extends TaskBase {
897
+ type: 'test';
898
+ suite: Suite;
899
+ result?: TaskResult;
900
+ fails?: boolean;
901
+ context: TestContext & ExtraContext;
902
+ }
903
+ declare type Task = Test | Suite | File;
904
+ declare type DoneCallback = (error?: any) => void;
905
+ declare type TestFunction<ExtraContext = {}> = (context: TestContext & ExtraContext) => Awaitable<any> | void;
906
+ declare type ExtractEachCallbackArgs<T extends ReadonlyArray<any>> = {
907
+ 1: [T[0]];
908
+ 2: [T[0], T[1]];
909
+ 3: [T[0], T[1], T[2]];
910
+ 4: [T[0], T[1], T[2], T[3]];
911
+ 5: [T[0], T[1], T[2], T[3], T[4]];
912
+ 6: [T[0], T[1], T[2], T[3], T[4], T[5]];
913
+ 7: [T[0], T[1], T[2], T[3], T[4], T[5], T[6]];
914
+ 8: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7]];
915
+ 9: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7], T[8]];
916
+ 10: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7], T[8], T[9]];
917
+ fallback: Array<T extends ReadonlyArray<infer U> ? U : any>;
918
+ }[T extends Readonly<[any]> ? 1 : T extends Readonly<[any, any]> ? 2 : T extends Readonly<[any, any, any]> ? 3 : T extends Readonly<[any, any, any, any]> ? 4 : T extends Readonly<[any, any, any, any, any]> ? 5 : T extends Readonly<[any, any, any, any, any, any]> ? 6 : T extends Readonly<[any, any, any, any, any, any, any]> ? 7 : T extends Readonly<[any, any, any, any, any, any, any, any]> ? 8 : T extends Readonly<[any, any, any, any, any, any, any, any, any]> ? 9 : T extends Readonly<[any, any, any, any, any, any, any, any, any, any]> ? 10 : 'fallback'];
919
+ interface EachFunction {
920
+ <T extends any[] | [any]>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T) => Awaitable<void>) => void;
921
+ <T extends ReadonlyArray<any>>(cases: ReadonlyArray<T>): (name: string, fn: (...args: ExtractEachCallbackArgs<T>) => Awaitable<void>) => void;
922
+ <T>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T[]) => Awaitable<void>) => void;
923
+ }
924
+ declare type ChainableTestAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo' | 'fails', [
925
+ name: string,
926
+ fn?: TestFunction<ExtraContext>,
927
+ timeout?: number
928
+ ], void>;
929
+ declare type TestAPI<ExtraContext = {}> = ChainableTestAPI<ExtraContext> & {
930
+ each: EachFunction;
931
+ skipIf(condition: any): ChainableTestAPI<ExtraContext>;
932
+ runIf(condition: any): ChainableTestAPI<ExtraContext>;
933
+ };
934
+ declare type ChainableSuiteAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo' | 'shuffle', [
935
+ name: string,
936
+ factory?: SuiteFactory
937
+ ], SuiteCollector<ExtraContext>>;
938
+ declare type SuiteAPI<ExtraContext = {}> = ChainableSuiteAPI & {
939
+ each: EachFunction;
940
+ skipIf(condition: any): ChainableSuiteAPI<ExtraContext>;
941
+ runIf(condition: any): ChainableSuiteAPI<ExtraContext>;
942
+ };
943
+ declare type HookListener<T extends any[], Return = void> = (...args: T) => Awaitable<Return>;
944
+ declare type HookCleanupCallback = (() => Awaitable<unknown>) | void;
945
+ interface SuiteHooks {
946
+ beforeAll: HookListener<[Suite | File], HookCleanupCallback>[];
947
+ afterAll: HookListener<[Suite | File]>[];
948
+ beforeEach: HookListener<[TestContext, Suite], HookCleanupCallback>[];
949
+ afterEach: HookListener<[TestContext, Suite]>[];
950
+ }
951
+ interface SuiteCollector<ExtraContext = {}> {
952
+ readonly name: string;
953
+ readonly mode: RunMode;
954
+ type: 'collector';
955
+ test: TestAPI<ExtraContext>;
956
+ tasks: (Suite | Test | SuiteCollector<ExtraContext>)[];
957
+ collect: (file?: File) => Promise<Suite>;
958
+ clear: () => void;
959
+ on: <T extends keyof SuiteHooks>(name: T, ...fn: SuiteHooks[T]) => void;
960
+ }
961
+ declare type SuiteFactory = (test: (name: string, fn: TestFunction) => void) => Awaitable<void>;
962
+ interface RuntimeContext {
963
+ tasks: (SuiteCollector | Test)[];
964
+ currentSuite: SuiteCollector | null;
965
+ }
966
+ interface TestContext {
967
+ /**
968
+ * @deprecated Use promise instead
969
+ */
970
+ (error?: any): void;
971
+ /**
972
+ * Metadata of the current test
973
+ */
974
+ meta: Readonly<Test>;
975
+ /**
976
+ * A expect instance bound to the test
977
+ */
978
+ expect: Vi.ExpectStatic;
979
+ }
980
+
981
+ interface Reporter {
982
+ onInit?(ctx: Vitest): void;
983
+ onPathsCollected?: (paths?: string[]) => Awaitable<void>;
984
+ onCollected?: (files?: File[]) => Awaitable<void>;
985
+ onFinished?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
986
+ onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
987
+ onTestRemoved?: (trigger?: string) => Awaitable<void>;
988
+ onWatcherStart?: () => Awaitable<void>;
989
+ onWatcherRerun?: (files: string[], trigger?: string) => Awaitable<void>;
990
+ onServerRestart?: () => Awaitable<void>;
991
+ onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
992
+ }
993
+
994
+ declare type SnapshotData = Record<string, string>;
995
+ declare type SnapshotUpdateState = 'all' | 'new' | 'none';
996
+ interface SnapshotStateOptions {
997
+ updateSnapshot: SnapshotUpdateState;
998
+ expand?: boolean;
999
+ snapshotFormat?: OptionsReceived;
1000
+ resolveSnapshotPath?: (path: string, extension: string) => string;
1001
+ }
1002
+ interface SnapshotMatchOptions {
1003
+ testName: string;
1004
+ received: unknown;
1005
+ key?: string;
1006
+ inlineSnapshot?: string;
1007
+ isInline: boolean;
1008
+ error?: Error;
1009
+ }
1010
+ interface SnapshotResult {
1011
+ filepath: string;
1012
+ added: number;
1013
+ fileDeleted: boolean;
1014
+ matched: number;
1015
+ unchecked: number;
1016
+ uncheckedKeys: Array<string>;
1017
+ unmatched: number;
1018
+ updated: number;
1019
+ }
1020
+ interface UncheckedSnapshot {
1021
+ filePath: string;
1022
+ keys: Array<string>;
1023
+ }
1024
+ interface SnapshotSummary {
1025
+ added: number;
1026
+ didUpdate: boolean;
1027
+ failure: boolean;
1028
+ filesAdded: number;
1029
+ filesRemoved: number;
1030
+ filesRemovedList: Array<string>;
1031
+ filesUnmatched: number;
1032
+ filesUpdated: number;
1033
+ matched: number;
1034
+ total: number;
1035
+ unchecked: number;
1036
+ uncheckedKeysByFile: Array<UncheckedSnapshot>;
1037
+ unmatched: number;
1038
+ updated: number;
1039
+ }
1040
+
1041
+ declare type BuiltinEnvironment = 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime';
1042
+ declare type ApiConfig = Pick<CommonServerOptions, 'port' | 'strictPort' | 'host'>;
1043
+
1044
+ interface EnvironmentOptions {
1045
+ /**
1046
+ * jsdom options.
1047
+ */
1048
+ jsdom?: JSDOMOptions;
1049
+ }
1050
+ interface InlineConfig {
1051
+ /**
1052
+ * Include globs for test files
1053
+ *
1054
+ * @default ['**\/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}']
1055
+ */
1056
+ include?: string[];
1057
+ /**
1058
+ * Exclude globs for test files
1059
+ * @default ['node_modules', 'dist', '.idea', '.git', '.cache']
1060
+ */
1061
+ exclude?: string[];
1062
+ /**
1063
+ * Include globs for in-source test files
1064
+ *
1065
+ * @default []
1066
+ */
1067
+ includeSource?: string[];
1068
+ /**
1069
+ * Handling for dependencies inlining or externalizing
1070
+ */
1071
+ deps?: {
1072
+ /**
1073
+ * Externalize means that Vite will bypass the package to native Node.
1074
+ *
1075
+ * Externalized dependencies will not be applied Vite's transformers and resolvers.
1076
+ * And does not support HMR on reload.
1077
+ *
1078
+ * Typically, packages under `node_modules` are externalized.
1079
+ */
1080
+ external?: (string | RegExp)[];
1081
+ /**
1082
+ * Vite will process inlined modules.
1083
+ *
1084
+ * This could be helpful to handle packages that ship `.js` in ESM format (that Node can't handle).
1085
+ *
1086
+ * If `true`, every dependency will be inlined
1087
+ */
1088
+ inline?: (string | RegExp)[] | true;
1089
+ /**
1090
+ * Interpret CJS module's default as named exports
1091
+ *
1092
+ * @default true
1093
+ */
1094
+ interopDefault?: boolean;
1095
+ /**
1096
+ * When a dependency is a valid ESM package, try to guess the cjs version based on the path.
1097
+ * This will significantly improve the performance in huge repo, but might potentially
1098
+ * cause some misalignment if a package have different logic in ESM and CJS mode.
1099
+ *
1100
+ * @default false
1101
+ */
1102
+ fallbackCJS?: boolean;
1103
+ };
1104
+ /**
1105
+ * Base directory to scan for the test files
1106
+ *
1107
+ * @default `config.root`
1108
+ */
1109
+ dir?: string;
1110
+ /**
1111
+ * Register apis globally
1112
+ *
1113
+ * @default false
1114
+ */
1115
+ globals?: boolean;
1116
+ /**
1117
+ * Running environment
1118
+ *
1119
+ * Supports 'node', 'jsdom', 'happy-dom', 'edge-runtime'
1120
+ *
1121
+ * @default 'node'
1122
+ */
1123
+ environment?: BuiltinEnvironment;
1124
+ /**
1125
+ * Environment options.
1126
+ */
1127
+ environmentOptions?: EnvironmentOptions;
1128
+ /**
1129
+ * Update snapshot
1130
+ *
1131
+ * @default false
1132
+ */
1133
+ update?: boolean;
1134
+ /**
1135
+ * Watch mode
1136
+ *
1137
+ * @default true
1138
+ */
1139
+ watch?: boolean;
1140
+ /**
1141
+ * Project root
1142
+ *
1143
+ * @default process.cwd()
1144
+ */
1145
+ root?: string;
1146
+ /**
1147
+ * Custom reporter for output. Can contain one or more built-in report names, reporter instances,
1148
+ * and/or paths to custom reporters
1149
+ */
1150
+ reporters?: Arrayable<BuiltinReporters | Reporter | Omit<string, BuiltinReporters>>;
1151
+ /**
1152
+ * diff output length
1153
+ */
1154
+ outputTruncateLength?: number;
1155
+ /**
1156
+ * number of diff output lines
1157
+ */
1158
+ outputDiffLines?: number;
1159
+ /**
1160
+ * Write test results to a file when the --reporter=json` or `--reporter=junit` option is also specified.
1161
+ * Also definable individually per reporter by using an object instead.
1162
+ */
1163
+ outputFile?: string | (Partial<Record<BuiltinReporters, string>> & Record<string, string>);
1164
+ /**
1165
+ * Enable multi-threading
1166
+ *
1167
+ * @default true
1168
+ */
1169
+ threads?: boolean;
1170
+ /**
1171
+ * Maximum number of threads
1172
+ *
1173
+ * @default available CPUs
1174
+ */
1175
+ maxThreads?: number;
1176
+ /**
1177
+ * Minimum number of threads
1178
+ *
1179
+ * @default available CPUs
1180
+ */
1181
+ minThreads?: number;
1182
+ /**
1183
+ * Default timeout of a test in milliseconds
1184
+ *
1185
+ * @default 5000
1186
+ */
1187
+ testTimeout?: number;
1188
+ /**
1189
+ * Default timeout of a hook in milliseconds
1190
+ *
1191
+ * @default 10000
1192
+ */
1193
+ hookTimeout?: number;
1194
+ /**
1195
+ * Default timeout to wait for close when Vitest shuts down, in milliseconds
1196
+ *
1197
+ * @default 1000
1198
+ */
1199
+ teardownTimeout?: number;
1200
+ /**
1201
+ * Silent mode
1202
+ *
1203
+ * @default false
1204
+ */
1205
+ silent?: boolean;
1206
+ /**
1207
+ * Path to setup files
1208
+ */
1209
+ setupFiles?: string | string[];
1210
+ /**
1211
+ * Path to global setup files
1212
+ */
1213
+ globalSetup?: string | string[];
1214
+ /**
1215
+ * Glob pattern of file paths to be ignore from triggering watch rerun
1216
+ */
1217
+ watchExclude?: string[];
1218
+ /**
1219
+ * Glob patter of file paths that will trigger the whole suite rerun
1220
+ *
1221
+ * Useful if you are testing calling CLI commands
1222
+ *
1223
+ * @default []
1224
+ */
1225
+ forceRerunTriggers?: string[];
1226
+ /**
1227
+ * Isolate environment for each test file
1228
+ *
1229
+ * @default true
1230
+ */
1231
+ isolate?: boolean;
1232
+ /**
1233
+ * Coverage options
1234
+ */
1235
+ coverage?: C8Options;
1236
+ /**
1237
+ * run test names with the specified pattern
1238
+ */
1239
+ testNamePattern?: string | RegExp;
1240
+ /**
1241
+ * Will call `.mockClear()` on all spies before each test
1242
+ * @default false
1243
+ */
1244
+ clearMocks?: boolean;
1245
+ /**
1246
+ * Will call `.mockReset()` on all spies before each test
1247
+ * @default false
1248
+ */
1249
+ mockReset?: boolean;
1250
+ /**
1251
+ * Will call `.mockRestore()` on all spies before each test
1252
+ * @default false
1253
+ */
1254
+ restoreMocks?: boolean;
1255
+ /**
1256
+ * Serve API options.
1257
+ *
1258
+ * When set to true, the default port is 51204.
1259
+ *
1260
+ * @default false
1261
+ */
1262
+ api?: boolean | number | ApiConfig;
1263
+ /**
1264
+ * Enable Vitest UI
1265
+ * @internal WIP
1266
+ */
1267
+ ui?: boolean;
1268
+ /**
1269
+ * Use in browser environment
1270
+ * @experimental
1271
+ */
1272
+ browser?: boolean;
1273
+ /**
1274
+ * Open UI automatically.
1275
+ *
1276
+ * @default true
1277
+ */
1278
+ open?: boolean;
1279
+ /**
1280
+ * Base url for the UI
1281
+ *
1282
+ * @default '/__vitest__/'
1283
+ */
1284
+ uiBase?: string;
1285
+ /**
1286
+ * Determine the transform method of modules
1287
+ */
1288
+ transformMode?: {
1289
+ /**
1290
+ * Use SSR transform pipeline for the specified files.
1291
+ * Vite plugins will receive `ssr: true` flag when processing those files.
1292
+ *
1293
+ * @default [/\.([cm]?[jt]sx?|json)$/]
1294
+ */
1295
+ ssr?: RegExp[];
1296
+ /**
1297
+ * First do a normal transform pipeline (targeting browser),
1298
+ * then then do a SSR rewrite to run the code in Node.
1299
+ * Vite plugins will receive `ssr: false` flag when processing those files.
1300
+ *
1301
+ * @default other than `ssr`
1302
+ */
1303
+ web?: RegExp[];
1304
+ };
1305
+ /**
1306
+ * Format options for snapshot testing.
1307
+ */
1308
+ snapshotFormat?: PrettyFormatOptions;
1309
+ /**
1310
+ * Resolve custom snapshot path
1311
+ */
1312
+ resolveSnapshotPath?: (path: string, extension: string) => string;
1313
+ /**
1314
+ * Pass with no tests
1315
+ */
1316
+ passWithNoTests?: boolean;
1317
+ /**
1318
+ * Allow tests and suites that are marked as only
1319
+ */
1320
+ allowOnly?: boolean;
1321
+ /**
1322
+ * Show heap usage after each test. Usefull for debugging memory leaks.
1323
+ */
1324
+ logHeapUsage?: boolean;
1325
+ /**
1326
+ * Custom environment variables assigned to `process.env` before running tests.
1327
+ */
1328
+ env?: Record<string, string>;
1329
+ /**
1330
+ * Options for @sinon/fake-timers
1331
+ */
1332
+ fakeTimers?: FakeTimerInstallOpts;
1333
+ /**
1334
+ * Custom handler for console.log in tests.
1335
+ *
1336
+ * Return `false` to ignore the log.
1337
+ */
1338
+ onConsoleLog?: (log: string, type: 'stdout' | 'stderr') => false | void;
1339
+ /**
1340
+ * Indicates if CSS files should be processed.
1341
+ *
1342
+ * When excluded, the CSS files will be replaced with empty strings to bypass the subsequent processing.
1343
+ *
1344
+ * @default { include: [/\.module\./] }
1345
+ */
1346
+ css?: boolean | {
1347
+ include?: RegExp | RegExp[];
1348
+ exclude?: RegExp | RegExp[];
1349
+ };
1350
+ /**
1351
+ * A number of tests that are allowed to run at the same time marked with `test.concurrent`.
1352
+ * @default 5
1353
+ */
1354
+ maxConcurrency?: number;
1355
+ /**
1356
+ * Options for configuring cache policy.
1357
+ * @default { dir: 'node_modules/.vitest' }
1358
+ */
1359
+ cache?: false | {
1360
+ dir?: string;
1361
+ };
1362
+ /**
1363
+ * Options for configuring the order of running tests.
1364
+ */
1365
+ sequence?: {
1366
+ /**
1367
+ * Class that handles sorting and sharding algorithm.
1368
+ * If you only need to change sorting, you can extend
1369
+ * your custom sequencer from `BaseSequencer` from `vitest/node`.
1370
+ * @default BaseSequencer
1371
+ */
1372
+ sequencer?: TestSequencerConstructor;
1373
+ /**
1374
+ * Should tests run in random order.
1375
+ * @default false
1376
+ */
1377
+ shuffle?: boolean;
1378
+ /**
1379
+ * Seed for the random number generator.
1380
+ * @default Date.now()
1381
+ */
1382
+ seed?: number;
1383
+ };
1384
+ /**
1385
+ * Specifies an `Object`, or an `Array` of `Object`,
1386
+ * which defines aliases used to replace values in `import` or `require` statements.
1387
+ * Will be merged with the default aliases inside `resolve.alias`.
1388
+ */
1389
+ alias?: AliasOptions;
1390
+ }
1391
+ interface UserConfig extends InlineConfig {
1392
+ /**
1393
+ * Path to the config file.
1394
+ *
1395
+ * Default resolving to one of:
1396
+ * - `vitest.config.js`
1397
+ * - `vitest.config.ts`
1398
+ * - `vite.config.js`
1399
+ * - `vite.config.ts`
1400
+ */
1401
+ config?: string | undefined;
1402
+ /**
1403
+ * Use happy-dom
1404
+ */
1405
+ dom?: boolean;
1406
+ /**
1407
+ * Run tests that cover a list of source files
1408
+ */
1409
+ related?: string[] | string;
1410
+ /**
1411
+ * Overrides Vite mode
1412
+ * @default 'test'
1413
+ */
1414
+ mode?: string;
1415
+ /**
1416
+ * Runs tests that are affected by the changes in the repository, or between specified branch or commit hash
1417
+ * Requires initialized git repository
1418
+ * @default false
1419
+ */
1420
+ changed?: boolean | string;
1421
+ /**
1422
+ * Test suite shard to execute in a format of <index>/<count>.
1423
+ * Will divide tests into a `count` numbers, and run only the `indexed` part.
1424
+ * Cannot be used with enabled watch.
1425
+ * @example --shard=2/3
1426
+ */
1427
+ shard?: string;
1428
+ }
1429
+ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'shard' | 'cache' | 'sequence'> {
1430
+ base?: string;
1431
+ config?: string;
1432
+ filters?: string[];
1433
+ testNamePattern?: RegExp;
1434
+ related?: string[];
1435
+ coverage: ResolvedC8Options;
1436
+ snapshotOptions: SnapshotStateOptions;
1437
+ reporters: (Reporter | BuiltinReporters)[];
1438
+ defines: Record<string, any>;
1439
+ api?: ApiConfig;
1440
+ shard?: {
1441
+ index: number;
1442
+ count: number;
1443
+ };
1444
+ cache: {
1445
+ dir: string;
1446
+ } | false;
1447
+ sequence: {
1448
+ sequencer: TestSequencerConstructor;
1449
+ shuffle?: boolean;
1450
+ seed?: number;
1451
+ };
1452
+ }
1453
+
1454
+ declare type VitestInlineConfig = InlineConfig;
1455
+ declare module 'vite' {
1456
+ interface UserConfig {
1457
+ /**
1458
+ * Options for Vitest
1459
+ */
1460
+ test?: VitestInlineConfig;
1461
+ }
1462
+ }
1463
+
1464
+ declare type Formatter = (input: string | number | null | undefined) => string;
1465
+
1466
+ interface MatcherHintOptions {
1467
+ comment?: string;
1468
+ expectedColor?: Formatter;
1469
+ isDirectExpectCall?: boolean;
1470
+ isNot?: boolean;
1471
+ promise?: string;
1472
+ receivedColor?: Formatter;
1473
+ secondArgument?: string;
1474
+ secondArgumentColor?: Formatter;
1475
+ }
1476
+ interface DiffOptions {
1477
+ aAnnotation?: string;
1478
+ aColor?: Formatter;
1479
+ aIndicator?: string;
1480
+ bAnnotation?: string;
1481
+ bColor?: Formatter;
1482
+ bIndicator?: string;
1483
+ changeColor?: Formatter;
1484
+ changeLineTrailingSpaceColor?: Formatter;
1485
+ commonColor?: Formatter;
1486
+ commonIndicator?: string;
1487
+ commonLineTrailingSpaceColor?: Formatter;
1488
+ contextLines?: number;
1489
+ emptyFirstOrLastLinePlaceholder?: string;
1490
+ expand?: boolean;
1491
+ includeChangeCounts?: boolean;
1492
+ omitAnnotationLines?: boolean;
1493
+ patchColor?: Formatter;
1494
+ compareKeys?: any;
1495
+ }
1496
+
1497
+ declare const EXPECTED_COLOR: Formatter;
1498
+ declare const RECEIVED_COLOR: Formatter;
1499
+ declare const INVERTED_COLOR: Formatter;
1500
+ declare const BOLD_WEIGHT: Formatter;
1501
+ declare const DIM_COLOR: Formatter;
1502
+ declare function matcherHint(matcherName: string, received?: string, expected?: string, options?: MatcherHintOptions): string;
1503
+ declare function stringify(object: unknown, maxDepth?: number, options?: PrettyFormatOptions): string;
1504
+ declare const printReceived: (object: unknown) => string;
1505
+ declare const printExpected: (value: unknown) => string;
1506
+ declare function diff(a: any, b: any, options?: DiffOptions): string;
1507
+
1508
+ declare const jestMatcherUtils_EXPECTED_COLOR: typeof EXPECTED_COLOR;
1509
+ declare const jestMatcherUtils_RECEIVED_COLOR: typeof RECEIVED_COLOR;
1510
+ declare const jestMatcherUtils_INVERTED_COLOR: typeof INVERTED_COLOR;
1511
+ declare const jestMatcherUtils_BOLD_WEIGHT: typeof BOLD_WEIGHT;
1512
+ declare const jestMatcherUtils_DIM_COLOR: typeof DIM_COLOR;
1513
+ declare const jestMatcherUtils_matcherHint: typeof matcherHint;
1514
+ declare const jestMatcherUtils_stringify: typeof stringify;
1515
+ declare const jestMatcherUtils_printReceived: typeof printReceived;
1516
+ declare const jestMatcherUtils_printExpected: typeof printExpected;
1517
+ declare const jestMatcherUtils_diff: typeof diff;
1518
+ declare namespace jestMatcherUtils {
1519
+ export {
1520
+ jestMatcherUtils_EXPECTED_COLOR as EXPECTED_COLOR,
1521
+ jestMatcherUtils_RECEIVED_COLOR as RECEIVED_COLOR,
1522
+ jestMatcherUtils_INVERTED_COLOR as INVERTED_COLOR,
1523
+ jestMatcherUtils_BOLD_WEIGHT as BOLD_WEIGHT,
1524
+ jestMatcherUtils_DIM_COLOR as DIM_COLOR,
1525
+ jestMatcherUtils_matcherHint as matcherHint,
1526
+ jestMatcherUtils_stringify as stringify,
1527
+ jestMatcherUtils_printReceived as printReceived,
1528
+ jestMatcherUtils_printExpected as printExpected,
1529
+ jestMatcherUtils_diff as diff,
1530
+ };
1531
+ }
1532
+
1533
+ /**
1534
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
1535
+ *
1536
+ * This source code is licensed under the MIT license found in the
1537
+ * LICENSE file in the root directory of this source tree.
1538
+ */
1539
+
1540
+ interface SnapshotReturnOptions {
1541
+ actual: string;
1542
+ count: number;
1543
+ expected?: string;
1544
+ key: string;
1545
+ pass: boolean;
1546
+ }
1547
+ interface SaveStatus {
1548
+ deleted: boolean;
1549
+ saved: boolean;
1550
+ }
1551
+ declare class SnapshotState {
1552
+ testFilePath: string;
1553
+ snapshotPath: string;
1554
+ private _counters;
1555
+ private _dirty;
1556
+ private _updateSnapshot;
1557
+ private _snapshotData;
1558
+ private _initialData;
1559
+ private _inlineSnapshots;
1560
+ private _uncheckedKeys;
1561
+ private _snapshotFormat;
1562
+ added: number;
1563
+ expand: boolean;
1564
+ matched: number;
1565
+ unmatched: number;
1566
+ updated: number;
1567
+ constructor(testFilePath: string, snapshotPath: string, options: SnapshotStateOptions);
1568
+ markSnapshotsAsCheckedForTest(testName: string): void;
1569
+ private _inferInlineSnapshotStack;
1570
+ private _addSnapshot;
1571
+ clear(): void;
1572
+ save(): Promise<SaveStatus>;
1573
+ getUncheckedCount(): number;
1574
+ getUncheckedKeys(): Array<string>;
1575
+ removeUncheckedKeys(): void;
1576
+ match({ testName, received, key, inlineSnapshot, isInline, error, }: SnapshotMatchOptions): SnapshotReturnOptions;
1577
+ pack(): Promise<SnapshotResult>;
1578
+ }
1579
+
1580
+ declare type Tester = (a: any, b: any) => boolean | undefined;
1581
+ interface MatcherState {
1582
+ assertionCalls: number;
1583
+ currentTestName?: string;
1584
+ dontThrow?: () => void;
1585
+ error?: Error;
1586
+ equals: (a: unknown, b: unknown, customTesters?: Array<Tester>, strictCheck?: boolean) => boolean;
1587
+ expand?: boolean;
1588
+ expectedAssertionsNumber?: number | null;
1589
+ expectedAssertionsNumberErrorGen?: (() => Error) | null;
1590
+ isExpectingAssertions?: boolean;
1591
+ isExpectingAssertionsError?: Error | null;
1592
+ isNot: boolean;
1593
+ promise: string;
1594
+ snapshotState: SnapshotState;
1595
+ suppressedErrors: Array<Error>;
1596
+ testPath?: string;
1597
+ utils: typeof jestMatcherUtils & {
1598
+ iterableEquality: Tester;
1599
+ subsetEquality: Tester;
1600
+ };
1601
+ }
1602
+ interface SyncExpectationResult {
1603
+ pass: boolean;
1604
+ message: () => string;
1605
+ actual?: any;
1606
+ expected?: any;
1607
+ }
1608
+ declare type AsyncExpectationResult = Promise<SyncExpectationResult>;
1609
+ declare type ExpectationResult = SyncExpectationResult | AsyncExpectationResult;
1610
+ interface RawMatcherFn<T extends MatcherState = MatcherState> {
1611
+ (this: T, received: any, expected: any, options?: any): ExpectationResult;
1612
+ }
1613
+ declare type MatchersObject<T extends MatcherState = MatcherState> = Record<string, RawMatcherFn<T>>;
1614
+
1615
+ declare type Promisify<O> = {
1616
+ [K in keyof O]: O[K] extends (...args: infer A) => infer R ? O extends R ? Promisify<O[K]> : (...args: A) => Promise<R> : O[K];
1617
+ };
1618
+ declare global {
1619
+ namespace jest {
1620
+ interface Matchers<R, T = {}> {
1621
+ }
1622
+ }
1623
+ namespace Vi {
1624
+ interface ExpectStatic extends Chai.ExpectStatic, AsymmetricMatchersContaining {
1625
+ <T>(actual: T, message?: string): Vi.Assertion<T>;
1626
+ extend(expects: MatchersObject): void;
1627
+ assertions(expected: number): void;
1628
+ hasAssertions(): void;
1629
+ anything(): any;
1630
+ any(constructor: unknown): any;
1631
+ addSnapshotSerializer(plugin: Plugin): void;
1632
+ getState(): MatcherState;
1633
+ setState(state: Partial<MatcherState>): void;
1634
+ not: AsymmetricMatchersContaining;
1635
+ }
1636
+ interface AsymmetricMatchersContaining {
1637
+ stringContaining(expected: string): any;
1638
+ objectContaining(expected: any): any;
1639
+ arrayContaining<T = unknown>(expected: Array<T>): any;
1640
+ stringMatching(expected: string | RegExp): any;
1641
+ }
1642
+ interface JestAssertion<T = any> extends jest.Matchers<void, T> {
1643
+ toMatchSnapshot<U extends {
1644
+ [P in keyof T]: any;
1645
+ }>(snapshot: Partial<U>, message?: string): void;
1646
+ toMatchSnapshot(message?: string): void;
1647
+ matchSnapshot<U extends {
1648
+ [P in keyof T]: any;
1649
+ }>(snapshot: Partial<U>, message?: string): void;
1650
+ matchSnapshot(message?: string): void;
1651
+ toMatchInlineSnapshot<U extends {
1652
+ [P in keyof T]: any;
1653
+ }>(properties: Partial<U>, snapshot?: string, message?: string): void;
1654
+ toMatchInlineSnapshot(snapshot?: string, message?: string): void;
1655
+ toThrowErrorMatchingSnapshot(message?: string): void;
1656
+ toThrowErrorMatchingInlineSnapshot(snapshot?: string, message?: string): void;
1657
+ toEqual<E>(expected: E): void;
1658
+ toStrictEqual<E>(expected: E): void;
1659
+ toBe<E>(expected: E): void;
1660
+ toMatch(expected: string | RegExp): void;
1661
+ toMatchObject<E extends {} | any[]>(expected: E): void;
1662
+ toContain<E>(item: E): void;
1663
+ toContainEqual<E>(item: E): void;
1664
+ toBeTruthy(): void;
1665
+ toBeFalsy(): void;
1666
+ toBeGreaterThan(num: number | bigint): void;
1667
+ toBeGreaterThanOrEqual(num: number | bigint): void;
1668
+ toBeLessThan(num: number | bigint): void;
1669
+ toBeLessThanOrEqual(num: number | bigint): void;
1670
+ toBeNaN(): void;
1671
+ toBeUndefined(): void;
1672
+ toBeNull(): void;
1673
+ toBeDefined(): void;
1674
+ toBeTypeOf(expected: 'bigint' | 'boolean' | 'function' | 'number' | 'object' | 'string' | 'symbol' | 'undefined'): void;
1675
+ toBeInstanceOf<E>(expected: E): void;
1676
+ toBeCalledTimes(times: number): void;
1677
+ toHaveLength(length: number): void;
1678
+ toHaveProperty<E>(property: string | string[], value?: E): void;
1679
+ toBeCloseTo(number: number, numDigits?: number): void;
1680
+ toHaveBeenCalledTimes(times: number): void;
1681
+ toHaveBeenCalledOnce(): void;
1682
+ toHaveBeenCalled(): void;
1683
+ toBeCalled(): void;
1684
+ toHaveBeenCalledWith<E extends any[]>(...args: E): void;
1685
+ toBeCalledWith<E extends any[]>(...args: E): void;
1686
+ toHaveBeenNthCalledWith<E extends any[]>(n: number, ...args: E): void;
1687
+ nthCalledWith<E extends any[]>(nthCall: number, ...args: E): void;
1688
+ toHaveBeenLastCalledWith<E extends any[]>(...args: E): void;
1689
+ lastCalledWith<E extends any[]>(...args: E): void;
1690
+ toThrow(expected?: string | Constructable$1 | RegExp | Error): void;
1691
+ toThrowError(expected?: string | Constructable$1 | RegExp | Error): void;
1692
+ toReturn(): void;
1693
+ toHaveReturned(): void;
1694
+ toReturnTimes(times: number): void;
1695
+ toHaveReturnedTimes(times: number): void;
1696
+ toReturnWith<E>(value: E): void;
1697
+ toHaveReturnedWith<E>(value: E): void;
1698
+ toHaveLastReturnedWith<E>(value: E): void;
1699
+ lastReturnedWith<E>(value: E): void;
1700
+ toHaveNthReturnedWith<E>(nthCall: number, value: E): void;
1701
+ nthReturnedWith<E>(nthCall: number, value: E): void;
1702
+ toSatisfy<E>(matcher: (value: E) => boolean, message?: string): void;
1703
+ }
1704
+ type VitestAssertion<A, T> = {
1705
+ [K in keyof A]: A[K] extends Chai.Assertion ? Assertion<T> : A[K] extends (...args: any[]) => any ? A[K] : VitestAssertion<A[K], T>;
1706
+ } & ((type: string, message?: string) => Assertion);
1707
+ interface Assertion<T = any> extends VitestAssertion<Chai.Assertion, T>, JestAssertion<T> {
1708
+ resolves: Promisify<Assertion<T>>;
1709
+ rejects: Promisify<Assertion<T>>;
1710
+ }
1711
+ }
1712
+ }
1713
+
1714
+ declare type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
1715
+ declare type ReturnType$1<T> = T extends (...args: any) => infer R ? R : never;
1716
+ declare type PromisifyFn<T> = ReturnType$1<T> extends Promise<any> ? T : (...args: ArgumentsType<T>) => Promise<Awaited<ReturnType$1<T>>>;
1717
+ declare type BirpcFn<T> = PromisifyFn<T> & {
1718
+ /**
1719
+ * Send event without asking for response
1720
+ */
1721
+ asEvent(...args: ArgumentsType<T>): void;
1722
+ };
1723
+ declare type BirpcReturn<RemoteFunctions> = {
1724
+ [K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]>;
1725
+ };
1726
+
1727
+ interface WorkerContext {
1728
+ workerId: number;
1729
+ port: MessagePort;
1730
+ config: ResolvedConfig;
1731
+ files: string[];
1732
+ invalidates?: string[];
1733
+ }
1734
+ declare type ResolveIdFunction = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
1735
+ interface WorkerRPC {
1736
+ fetch: FetchFunction;
1737
+ resolveId: ResolveIdFunction;
1738
+ getSourceMap: (id: string, force?: boolean) => Promise<RawSourceMap | undefined>;
1739
+ onFinished: (files: File[], errors?: unknown[]) => void;
1740
+ onWorkerExit: (code?: number) => void;
1741
+ onPathsCollected: (paths: string[]) => void;
1742
+ onUserConsoleLog: (log: UserConsoleLog) => void;
1743
+ onUnhandledRejection: (err: unknown) => void;
1744
+ onCollected: (files: File[]) => void;
1745
+ onTaskUpdate: (pack: TaskResultPack[]) => void;
1746
+ snapshotSaved: (snapshot: SnapshotResult) => void;
1747
+ resolveSnapshotPath: (testPath: string) => string;
1748
+ }
1749
+ interface WorkerGlobalState {
1750
+ ctx: WorkerContext;
1751
+ config: ResolvedConfig;
1752
+ rpc: BirpcReturn<WorkerRPC>;
1753
+ current?: Test;
1754
+ filepath?: string;
1755
+ moduleCache: ModuleCacheMap;
1756
+ browserHashMap?: Map<string, string>;
1757
+ mockMap: MockMap;
1758
+ }
1759
+
1760
+ interface MockResultReturn<T> {
1761
+ type: 'return';
1762
+ value: T;
1763
+ }
1764
+ interface MockResultIncomplete {
1765
+ type: 'incomplete';
1766
+ value: undefined;
1767
+ }
1768
+ interface MockResultThrow {
1769
+ type: 'throw';
1770
+ value: any;
1771
+ }
1772
+ declare type MockResult<T> = MockResultReturn<T> | MockResultThrow | MockResultIncomplete;
1773
+ interface MockContext<TArgs, TReturns> {
1774
+ calls: TArgs[];
1775
+ instances: TReturns[];
1776
+ invocationCallOrder: number[];
1777
+ results: MockResult<TReturns>[];
1778
+ lastCall: TArgs | undefined;
1779
+ }
1780
+ declare type Procedure = (...args: any[]) => any;
1781
+ declare type Methods<T> = {
1782
+ [K in keyof T]: T[K] extends Procedure ? K : never;
1783
+ }[keyof T] & (string | symbol);
1784
+ declare type Properties<T> = {
1785
+ [K in keyof T]: T[K] extends Procedure ? never : K;
1786
+ }[keyof T] & (string | symbol);
1787
+ interface SpyInstance<TArgs extends any[] = any[], TReturns = any> {
1788
+ getMockName(): string;
1789
+ mockName(n: string): this;
1790
+ mock: MockContext<TArgs, TReturns>;
1791
+ mockClear(): this;
1792
+ mockReset(): this;
1793
+ mockRestore(): void;
1794
+ getMockImplementation(): ((...args: TArgs) => TReturns) | undefined;
1795
+ mockImplementation(fn: ((...args: TArgs) => TReturns) | (() => Promise<TReturns>)): this;
1796
+ mockImplementationOnce(fn: ((...args: TArgs) => TReturns) | (() => Promise<TReturns>)): this;
1797
+ mockReturnThis(): this;
1798
+ mockReturnValue(obj: TReturns): this;
1799
+ mockReturnValueOnce(obj: TReturns): this;
1800
+ mockResolvedValue(obj: Awaited<TReturns>): this;
1801
+ mockResolvedValueOnce(obj: Awaited<TReturns>): this;
1802
+ mockRejectedValue(obj: any): this;
1803
+ mockRejectedValueOnce(obj: any): this;
1804
+ }
1805
+ interface MockInstance<A extends any[] = any[], R = any> extends SpyInstance<A, R> {
1806
+ }
1807
+ interface Mock<TArgs extends any[] = any, TReturns = any> extends SpyInstance<TArgs, TReturns> {
1808
+ new (...args: TArgs): TReturns;
1809
+ (...args: TArgs): TReturns;
1810
+ }
1811
+ declare type MaybeMockedConstructor<T> = T extends new (...args: Array<any>) => infer R ? Mock<ConstructorParameters<T>, R> : T;
1812
+ declare type MockedFunction<T extends Procedure> = Mock<Parameters<T>, ReturnType<T>> & {
1813
+ [K in keyof T]: T[K];
1814
+ };
1815
+ declare type MockedObject<T> = MaybeMockedConstructor<T> & {
1816
+ [K in Methods<T>]: T[K] extends Procedure ? MockedFunction<T[K]> : T[K];
1817
+ } & {
1818
+ [K in Properties<T>]: T[K];
1819
+ };
1820
+ interface Constructable {
1821
+ new (...args: any[]): any;
1822
+ }
1823
+ declare type MockedClass<T extends Constructable> = MockInstance<InstanceType<T>, T extends new (...args: infer P) => any ? P : never> & {
1824
+ prototype: T extends {
1825
+ prototype: any;
1826
+ } ? Mocked<T['prototype']> : never;
1827
+ } & T;
1828
+ declare type Mocked<T> = {
1829
+ [P in keyof T]: T[P] extends (...args: infer Args) => infer Returns ? MockInstance<Args, Returns> : T[P] extends Constructable ? MockedClass<T[P]> : T[P];
1830
+ } & T;
1831
+ declare type EnhancedSpy<TArgs extends any[] = any[], TReturns = any> = SpyInstance<TArgs, TReturns> & SpyImpl<TArgs, TReturns>;
1832
+
1833
+ declare const suite: SuiteAPI<{}>;
1834
+ declare const test: TestAPI<{}>;
1835
+ declare const describe: SuiteAPI<{}>;
1836
+ declare const it: TestAPI<{}>;
1837
+
1838
+ declare const beforeAll: (fn: SuiteHooks['beforeAll'][0], timeout?: number) => void;
1839
+ declare const afterAll: (fn: SuiteHooks['afterAll'][0], timeout?: number) => void;
1840
+ declare const beforeEach: (fn: SuiteHooks['beforeEach'][0], timeout?: number) => void;
1841
+ declare const afterEach: (fn: SuiteHooks['afterEach'][0], timeout?: number) => void;
1842
+
1843
+ declare function createExpect(test?: Test): Vi.ExpectStatic;
1844
+ declare const globalExpect: Vi.ExpectStatic;
1845
+
1846
+ declare function startTests(paths: string[], config: ResolvedConfig): Promise<void>;
1847
+
1848
+ declare function setupGlobalEnv(config: ResolvedConfig): Promise<void>;
1849
+
1850
+ export { ApiConfig, ArgumentsType$1 as ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, C8Options, Constructable$1 as Constructable, CoverageReporter, DeepMerge, DoneCallback, EnhancedSpy, Environment, EnvironmentOptions, EnvironmentReturn, ErrorWithDiff, File, HookCleanupCallback, HookListener, InlineConfig, JSDOMOptions, MergeInsertions, Mock, MockContext, MockInstance, Mocked, MockedClass, MockedFunction, MockedObject, ModuleCache, ModuleGraphData, MutableArray, Nullable, ParsedStack, Position, Reporter, ResolveIdFunction, ResolvedC8Options, ResolvedConfig, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, SpyInstance, Suite, SuiteAPI, SuiteCollector, SuiteFactory, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestAPI, TestContext, TestFunction, UncheckedSnapshot, UserConfig, UserConsoleLog, Vitest, WorkerContext, WorkerGlobalState, WorkerRPC, afterAll, afterEach, beforeAll, beforeEach, createExpect, describe, globalExpect as expect, it, setupGlobalEnv, startTests, suite, test };