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