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