vitest 0.27.2 → 0.28.0
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.
- package/LICENSE.md +4 -93
- package/browser.d.ts +1 -1
- package/dist/browser.d.ts +11 -13
- package/dist/browser.js +10 -34
- package/dist/{chunk-api-setup.029198e3.js → chunk-api-setup.52751a38.js} +27 -12
- package/dist/chunk-constants.797d3ebf.js +42 -0
- package/dist/{chunk-env-node.787e9561.js → chunk-env-node.ffd1183b.js} +26 -0
- package/dist/{chunk-install-pkg.7b006b3e.js → chunk-install-pkg.cfd23146.js} +51 -11
- package/dist/chunk-integrations-coverage.48e6286b.js +3993 -0
- package/dist/chunk-integrations-globals.0d5f50f0.js +29 -0
- package/dist/chunk-integrations-run-once.38756e30.js +27 -0
- package/dist/chunk-integrations-utils.f1f6f1ed.js +118 -0
- package/dist/{chunk-node-git.125c9008.js → chunk-node-git.d9ad64ab.js} +6 -7
- package/dist/{chunk-snapshot-manager.ce714e21.js → chunk-node-pkg.dcdf4369.js} +12653 -9324
- package/dist/{chunk-runtime-mocker.58511c38.js → chunk-runtime-mocker.03017e8c.js} +14 -13
- package/dist/{chunk-runtime-rpc.d709e91b.js → chunk-runtime-rpc.9c0386cc.js} +3 -2
- package/dist/chunk-runtime-setup.d9302cfd.js +20 -0
- package/dist/chunk-snapshot-env.6457638e.js +11 -0
- package/dist/chunk-utils-base.977ae74f.js +77 -0
- package/dist/chunk-utils-env.860d90c2.js +6 -0
- package/dist/chunk-utils-global.442d1d33.js +73 -0
- package/dist/{chunk-utils-import.054ab315.js → chunk-utils-import.9911c99d.js} +3289 -169
- package/dist/chunk-utils-tasks.1b603032.js +103 -0
- package/dist/cli-wrapper.js +8 -6
- package/dist/cli.js +18 -15
- package/dist/config.cjs +10 -7
- package/dist/config.d.ts +22 -4
- package/dist/config.js +10 -8
- package/dist/entry.js +244 -28
- package/dist/env-afee91f0.d.ts +10 -0
- package/dist/environments.d.ts +7 -2
- package/dist/environments.js +1 -1
- package/dist/index.d.ts +160 -11
- package/dist/index.js +18 -18
- package/dist/loader.js +9 -8
- package/dist/node.d.ts +9 -7
- package/dist/node.js +20 -17
- package/dist/runners-chunk.js +215 -0
- package/dist/runners.d.ts +39 -0
- package/dist/runners.js +18 -0
- package/dist/spy.js +1 -2
- package/dist/suite.d.ts +2 -0
- package/dist/suite.js +2 -18
- package/dist/{types-d97c72c7.d.ts → types-c800444e.d.ts} +196 -437
- package/dist/{vendor-index.e6c27006.js → vendor-index.618ca5a1.js} +1078 -10
- package/dist/{vendor-index.b0346fe4.js → vendor-index.bdee400f.js} +1 -0
- package/dist/worker.js +17 -16
- package/package.json +22 -12
- package/runners.d.ts +1 -0
- package/suite.d.ts +1 -0
- package/dist/chunk-integrations-coverage.44413252.js +0 -240
- package/dist/chunk-integrations-globals.0024ce21.js +0 -27
- package/dist/chunk-mock-date.c543fa3e.js +0 -349
- package/dist/chunk-runtime-chain.2da9e75c.js +0 -2595
- package/dist/chunk-runtime-error.de671af0.js +0 -144
- package/dist/chunk-runtime-setup.35da9209.js +0 -649
- package/dist/chunk-utils-env.f4a39d2c.js +0 -228
- package/dist/chunk-utils-source-map.5f5d12cf.js +0 -408
- package/dist/chunk-utils-timers.52534f96.js +0 -3573
- package/dist/index-50755efe.d.ts +0 -258
- package/dist/vendor-index.451e37bc.js +0 -1071
- package/dist/vendor-index.723a074f.js +0 -102
- package/dist/vendor-index.9c919048.js +0 -61
- package/dist/vendor-index.9f20a9be.js +0 -6291
|
@@ -1,10 +1,16 @@
|
|
|
1
|
+
import { MatchersObject, MatcherState } from '@vitest/expect';
|
|
1
2
|
import { UserConfig as UserConfig$1, ViteDevServer, CommonServerOptions, AliasOptions } from 'vite';
|
|
2
|
-
import {
|
|
3
|
+
import { File, Test as Test$1, Suite, TaskResultPack, Task } from '@vitest/runner/types';
|
|
4
|
+
import * as _vitest_runner from '@vitest/runner';
|
|
5
|
+
import { Task as Task$1, File as File$1, TaskResultPack as TaskResultPack$1, Test as Test$2, TaskCustom } from '@vitest/runner';
|
|
6
|
+
import { ParsedStack, ErrorWithDiff, ChainableFunction } from '@vitest/runner/utils';
|
|
7
|
+
import { Arrayable as Arrayable$1 } from '@vitest/utils';
|
|
8
|
+
import { Task as Task$2, TaskResult, Bench, Options } from 'tinybench';
|
|
3
9
|
import { ViteNodeRunner } from 'vite-node/client';
|
|
4
10
|
import { ViteNodeServer } from 'vite-node/server';
|
|
11
|
+
import { MessagePort } from 'node:worker_threads';
|
|
5
12
|
import { RawSourceMap, ViteNodeResolveId, FetchFunction, ModuleCacheMap } from 'vite-node';
|
|
6
13
|
import { Stats } from 'node:fs';
|
|
7
|
-
import { MessagePort } from 'node:worker_threads';
|
|
8
14
|
|
|
9
15
|
/**
|
|
10
16
|
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
@@ -76,10 +82,10 @@ declare type Config = {
|
|
|
76
82
|
spacingOuter: string;
|
|
77
83
|
};
|
|
78
84
|
declare type Printer = (val: unknown, config: Config, indentation: string, depth: number, refs: Refs, hasCalledToJSON?: boolean) => string;
|
|
79
|
-
declare type Test
|
|
85
|
+
declare type Test = (arg0: any) => boolean;
|
|
80
86
|
declare type NewPlugin = {
|
|
81
87
|
serialize: (val: any, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer) => string;
|
|
82
|
-
test: Test
|
|
88
|
+
test: Test;
|
|
83
89
|
};
|
|
84
90
|
declare type PluginOptions = {
|
|
85
91
|
edgeSpacing: string;
|
|
@@ -88,7 +94,7 @@ declare type PluginOptions = {
|
|
|
88
94
|
};
|
|
89
95
|
declare type OldPlugin = {
|
|
90
96
|
print: (val: unknown, print: Print, indent: Indent, options: PluginOptions, colors: Colors) => string;
|
|
91
|
-
test: Test
|
|
97
|
+
test: Test;
|
|
92
98
|
};
|
|
93
99
|
declare type Plugin = NewPlugin | OldPlugin;
|
|
94
100
|
declare type Plugins = Array<Plugin>;
|
|
@@ -173,7 +179,7 @@ interface ParsedFile extends File {
|
|
|
173
179
|
start: number;
|
|
174
180
|
end: number;
|
|
175
181
|
}
|
|
176
|
-
interface ParsedTest extends Test {
|
|
182
|
+
interface ParsedTest extends Test$1 {
|
|
177
183
|
start: number;
|
|
178
184
|
end: number;
|
|
179
185
|
}
|
|
@@ -265,9 +271,7 @@ declare class StateManager {
|
|
|
265
271
|
catchError(err: unknown, type: string): void;
|
|
266
272
|
clearErrors(): void;
|
|
267
273
|
getUnhandledErrors(): unknown[];
|
|
268
|
-
|
|
269
|
-
finishCollectingPaths(): void;
|
|
270
|
-
getPaths(): Promise<string[]>;
|
|
274
|
+
getPaths(): string[];
|
|
271
275
|
getFiles(keys?: string[]): File[];
|
|
272
276
|
getFilepaths(): string[];
|
|
273
277
|
getFailedFilepaths(): string[];
|
|
@@ -440,7 +444,7 @@ declare abstract class BaseReporter implements Reporter {
|
|
|
440
444
|
start: number;
|
|
441
445
|
end: number;
|
|
442
446
|
watchFilters?: string[];
|
|
443
|
-
isTTY:
|
|
447
|
+
isTTY: boolean;
|
|
444
448
|
ctx: Vitest;
|
|
445
449
|
private _filesInWatchMode;
|
|
446
450
|
private _lastRunTimeout;
|
|
@@ -467,6 +471,53 @@ declare abstract class BaseReporter implements Reporter {
|
|
|
467
471
|
registerUnhandledRejection(): void;
|
|
468
472
|
}
|
|
469
473
|
|
|
474
|
+
declare class BasicReporter extends BaseReporter {
|
|
475
|
+
isTTY: boolean;
|
|
476
|
+
reportSummary(files: File[]): Promise<void>;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
type Awaitable<T> = T | PromiseLike<T>;
|
|
480
|
+
type Nullable<T> = T | null | undefined;
|
|
481
|
+
type Arrayable<T> = T | Array<T>;
|
|
482
|
+
type ArgumentsType$1<T> = T extends (...args: infer U) => any ? U : never;
|
|
483
|
+
type MergeInsertions<T> = T extends object ? {
|
|
484
|
+
[K in keyof T]: MergeInsertions<T[K]>;
|
|
485
|
+
} : T;
|
|
486
|
+
type DeepMerge<F, S> = MergeInsertions<{
|
|
487
|
+
[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;
|
|
488
|
+
}>;
|
|
489
|
+
type MutableArray<T extends readonly any[]> = {
|
|
490
|
+
-readonly [k in keyof T]: T[k];
|
|
491
|
+
};
|
|
492
|
+
interface Constructable {
|
|
493
|
+
new (...args: any[]): any;
|
|
494
|
+
}
|
|
495
|
+
interface ModuleCache {
|
|
496
|
+
promise?: Promise<any>;
|
|
497
|
+
exports?: any;
|
|
498
|
+
code?: string;
|
|
499
|
+
}
|
|
500
|
+
interface EnvironmentReturn {
|
|
501
|
+
teardown: (global: any) => Awaitable<void>;
|
|
502
|
+
}
|
|
503
|
+
interface Environment {
|
|
504
|
+
name: string;
|
|
505
|
+
setup(global: any, options: Record<string, any>): Awaitable<EnvironmentReturn>;
|
|
506
|
+
}
|
|
507
|
+
interface UserConsoleLog {
|
|
508
|
+
content: string;
|
|
509
|
+
type: 'stdout' | 'stderr';
|
|
510
|
+
taskId?: string;
|
|
511
|
+
time: number;
|
|
512
|
+
size: number;
|
|
513
|
+
}
|
|
514
|
+
interface ModuleGraphData {
|
|
515
|
+
graph: Record<string, string[]>;
|
|
516
|
+
externalized: string[];
|
|
517
|
+
inlined: string[];
|
|
518
|
+
}
|
|
519
|
+
type OnServerRestartHandler = (reason?: string) => Promise<void> | void;
|
|
520
|
+
|
|
470
521
|
interface ListRendererOptions$1 {
|
|
471
522
|
renderSucceed?: boolean;
|
|
472
523
|
logger: Logger;
|
|
@@ -485,8 +536,8 @@ declare class DefaultReporter extends BaseReporter {
|
|
|
485
536
|
rendererOptions: ListRendererOptions$1;
|
|
486
537
|
onTestRemoved(trigger?: string): Promise<void>;
|
|
487
538
|
onCollected(): void;
|
|
488
|
-
onFinished(files?: File[], errors?: unknown[]): Promise<void>;
|
|
489
|
-
onWatcherStart(files?: File[], errors?: unknown[]): Promise<void>;
|
|
539
|
+
onFinished(files?: _vitest_runner.File[], errors?: unknown[]): Promise<void>;
|
|
540
|
+
onWatcherStart(files?: _vitest_runner.File[], errors?: unknown[]): Promise<void>;
|
|
490
541
|
stopListRender(): Promise<void>;
|
|
491
542
|
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
492
543
|
onUserConsoleLog(log: UserConsoleLog): void;
|
|
@@ -495,7 +546,7 @@ declare class DefaultReporter extends BaseReporter {
|
|
|
495
546
|
declare class DotReporter extends BaseReporter {
|
|
496
547
|
renderer?: ReturnType<typeof createListRenderer>;
|
|
497
548
|
onCollected(): void;
|
|
498
|
-
onFinished(files?: File[], errors?: unknown[]): Promise<void>;
|
|
549
|
+
onFinished(files?: _vitest_runner.File[], errors?: unknown[]): Promise<void>;
|
|
499
550
|
onWatcherStart(): Promise<void>;
|
|
500
551
|
stopListRender(): Promise<void>;
|
|
501
552
|
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
@@ -526,14 +577,28 @@ declare class VerboseReporter extends DefaultReporter {
|
|
|
526
577
|
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
527
578
|
}
|
|
528
579
|
|
|
580
|
+
interface Reporter {
|
|
581
|
+
onInit?(ctx: Vitest): void;
|
|
582
|
+
onPathsCollected?: (paths?: string[]) => Awaitable<void>;
|
|
583
|
+
onCollected?: (files?: File[]) => Awaitable<void>;
|
|
584
|
+
onFinished?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
|
|
585
|
+
onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
|
|
586
|
+
onTestRemoved?: (trigger?: string) => Awaitable<void>;
|
|
587
|
+
onWatcherStart?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
|
|
588
|
+
onWatcherRerun?: (files: string[], trigger?: string) => Awaitable<void>;
|
|
589
|
+
onServerRestart?: (reason?: string) => Awaitable<void>;
|
|
590
|
+
onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
|
|
591
|
+
onProcessTimeout?: () => Awaitable<void>;
|
|
592
|
+
}
|
|
593
|
+
|
|
529
594
|
declare class TapReporter implements Reporter {
|
|
530
595
|
protected ctx: Vitest;
|
|
531
596
|
private logger;
|
|
532
597
|
onInit(ctx: Vitest): void;
|
|
533
|
-
static getComment(task: Task): string;
|
|
598
|
+
static getComment(task: Task$1): string;
|
|
534
599
|
private logErrorDetails;
|
|
535
|
-
protected logTasks(tasks: Task[]): void;
|
|
536
|
-
onFinished(files?: File[]): Promise<void>;
|
|
600
|
+
protected logTasks(tasks: Task$1[]): void;
|
|
601
|
+
onFinished(files?: _vitest_runner.File[]): Promise<void>;
|
|
537
602
|
}
|
|
538
603
|
|
|
539
604
|
declare class JUnitReporter implements Reporter {
|
|
@@ -545,14 +610,14 @@ declare class JUnitReporter implements Reporter {
|
|
|
545
610
|
onInit(ctx: Vitest): Promise<void>;
|
|
546
611
|
writeElement(name: string, attrs: Record<string, any>, children: () => Promise<void>): Promise<void>;
|
|
547
612
|
writeErrorDetails(error: ErrorWithDiff): Promise<void>;
|
|
548
|
-
writeLogs(task: Task, type: 'err' | 'out'): Promise<void>;
|
|
549
|
-
writeTasks(tasks: Task[], filename: string): Promise<void>;
|
|
550
|
-
onFinished(files?: File[]): Promise<void>;
|
|
613
|
+
writeLogs(task: Task$1, type: 'err' | 'out'): Promise<void>;
|
|
614
|
+
writeTasks(tasks: Task$1[], filename: string): Promise<void>;
|
|
615
|
+
onFinished(files?: _vitest_runner.File[]): Promise<void>;
|
|
551
616
|
}
|
|
552
617
|
|
|
553
618
|
declare class TapFlatReporter extends TapReporter {
|
|
554
619
|
onInit(ctx: Vitest): void;
|
|
555
|
-
onFinished(files?: File[]): Promise<void>;
|
|
620
|
+
onFinished(files?: _vitest_runner.File[]): Promise<void>;
|
|
556
621
|
}
|
|
557
622
|
|
|
558
623
|
declare class HangingProcessReporter implements Reporter {
|
|
@@ -592,7 +657,7 @@ declare class TableReporter extends BaseReporter {
|
|
|
592
657
|
rendererOptions: ListRendererOptions$1;
|
|
593
658
|
onTestRemoved(trigger?: string): Promise<void>;
|
|
594
659
|
onCollected(): void;
|
|
595
|
-
onFinished(files?: File[], errors?: unknown[]): Promise<void>;
|
|
660
|
+
onFinished(files?: _vitest_runner.File[], errors?: unknown[]): Promise<void>;
|
|
596
661
|
onWatcherStart(): Promise<void>;
|
|
597
662
|
stopListRender(): Promise<void>;
|
|
598
663
|
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
@@ -608,6 +673,7 @@ type BenchmarkBuiltinReporters = keyof typeof BenchmarkReportsMap;
|
|
|
608
673
|
|
|
609
674
|
declare const ReportersMap: {
|
|
610
675
|
default: typeof DefaultReporter;
|
|
676
|
+
basic: typeof BasicReporter;
|
|
611
677
|
verbose: typeof VerboseReporter;
|
|
612
678
|
dot: typeof DotReporter;
|
|
613
679
|
json: typeof JsonReporter$1;
|
|
@@ -823,67 +889,6 @@ interface AcornNode {
|
|
|
823
889
|
type: string;
|
|
824
890
|
}
|
|
825
891
|
|
|
826
|
-
type Awaitable<T> = T | PromiseLike<T>;
|
|
827
|
-
type Nullable<T> = T | null | undefined;
|
|
828
|
-
type Arrayable<T> = T | Array<T>;
|
|
829
|
-
type ArgumentsType$1<T> = T extends (...args: infer U) => any ? U : never;
|
|
830
|
-
type MergeInsertions<T> = T extends object ? {
|
|
831
|
-
[K in keyof T]: MergeInsertions<T[K]>;
|
|
832
|
-
} : T;
|
|
833
|
-
type DeepMerge<F, S> = MergeInsertions<{
|
|
834
|
-
[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;
|
|
835
|
-
}>;
|
|
836
|
-
type MutableArray<T extends readonly any[]> = {
|
|
837
|
-
-readonly [k in keyof T]: T[k];
|
|
838
|
-
};
|
|
839
|
-
interface Constructable {
|
|
840
|
-
new (...args: any[]): any;
|
|
841
|
-
}
|
|
842
|
-
interface ModuleCache {
|
|
843
|
-
promise?: Promise<any>;
|
|
844
|
-
exports?: any;
|
|
845
|
-
code?: string;
|
|
846
|
-
}
|
|
847
|
-
interface EnvironmentReturn {
|
|
848
|
-
teardown: (global: any) => Awaitable<void>;
|
|
849
|
-
}
|
|
850
|
-
interface Environment {
|
|
851
|
-
name: string;
|
|
852
|
-
setup(global: any, options: Record<string, any>): Awaitable<EnvironmentReturn>;
|
|
853
|
-
}
|
|
854
|
-
interface UserConsoleLog {
|
|
855
|
-
content: string;
|
|
856
|
-
type: 'stdout' | 'stderr';
|
|
857
|
-
taskId?: string;
|
|
858
|
-
time: number;
|
|
859
|
-
size: number;
|
|
860
|
-
}
|
|
861
|
-
interface ParsedStack {
|
|
862
|
-
method: string;
|
|
863
|
-
file: string;
|
|
864
|
-
line: number;
|
|
865
|
-
column: number;
|
|
866
|
-
}
|
|
867
|
-
interface ErrorWithDiff extends Error {
|
|
868
|
-
name: string;
|
|
869
|
-
nameStr?: string;
|
|
870
|
-
stack?: string;
|
|
871
|
-
stackStr?: string;
|
|
872
|
-
stacks?: ParsedStack[];
|
|
873
|
-
showDiff?: boolean;
|
|
874
|
-
actual?: any;
|
|
875
|
-
expected?: any;
|
|
876
|
-
operator?: string;
|
|
877
|
-
type?: string;
|
|
878
|
-
frame?: string;
|
|
879
|
-
}
|
|
880
|
-
interface ModuleGraphData {
|
|
881
|
-
graph: Record<string, string[]>;
|
|
882
|
-
externalized: string[];
|
|
883
|
-
inlined: string[];
|
|
884
|
-
}
|
|
885
|
-
type OnServerRestartHandler = (reason?: string) => Promise<void> | void;
|
|
886
|
-
|
|
887
892
|
declare type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
|
|
888
893
|
declare type ReturnType$1<T> = T extends (...args: any) => infer R ? R : never;
|
|
889
894
|
declare type PromisifyFn<T> = ReturnType$1<T> extends Promise<any> ? T : (...args: ArgumentsType<T>) => Promise<Awaited<ReturnType$1<T>>>;
|
|
@@ -897,221 +902,6 @@ declare type BirpcReturn<RemoteFunctions> = {
|
|
|
897
902
|
[K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]>;
|
|
898
903
|
};
|
|
899
904
|
|
|
900
|
-
type ChainableFunction<T extends string, Args extends any[], R = any, E = {}> = {
|
|
901
|
-
(...args: Args): R;
|
|
902
|
-
} & {
|
|
903
|
-
[x in T]: ChainableFunction<T, Args, R, E>;
|
|
904
|
-
} & {
|
|
905
|
-
fn: (this: Record<T, boolean | undefined>, ...args: Args) => R;
|
|
906
|
-
} & E;
|
|
907
|
-
|
|
908
|
-
interface BenchmarkUserOptions {
|
|
909
|
-
/**
|
|
910
|
-
* Include globs for benchmark test files
|
|
911
|
-
*
|
|
912
|
-
* @default ['**\/*.{bench,benchmark}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}']
|
|
913
|
-
*/
|
|
914
|
-
include?: string[];
|
|
915
|
-
/**
|
|
916
|
-
* Exclude globs for benchmark test files
|
|
917
|
-
* @default ['node_modules', 'dist', '.idea', '.git', '.cache']
|
|
918
|
-
*/
|
|
919
|
-
exclude?: string[];
|
|
920
|
-
/**
|
|
921
|
-
* Include globs for in-source benchmark test files
|
|
922
|
-
*
|
|
923
|
-
* @default []
|
|
924
|
-
*/
|
|
925
|
-
includeSource?: string[];
|
|
926
|
-
/**
|
|
927
|
-
* Custom reporter for output. Can contain one or more built-in report names, reporter instances,
|
|
928
|
-
* and/or paths to custom reporters
|
|
929
|
-
*/
|
|
930
|
-
reporters?: Arrayable<BenchmarkBuiltinReporters | Reporter>;
|
|
931
|
-
/**
|
|
932
|
-
* Write test results to a file when the `--reporter=json` option is also specified.
|
|
933
|
-
* Also definable individually per reporter by using an object instead.
|
|
934
|
-
*/
|
|
935
|
-
outputFile?: string | (Partial<Record<BenchmarkBuiltinReporters, string>> & Record<string, string>);
|
|
936
|
-
}
|
|
937
|
-
interface Benchmark extends TaskBase {
|
|
938
|
-
type: 'benchmark';
|
|
939
|
-
suite: Suite;
|
|
940
|
-
result?: TaskResult;
|
|
941
|
-
fails?: boolean;
|
|
942
|
-
task?: Task$1;
|
|
943
|
-
}
|
|
944
|
-
interface BenchmarkResult extends TaskResult$1 {
|
|
945
|
-
name: string;
|
|
946
|
-
rank: number;
|
|
947
|
-
}
|
|
948
|
-
type BenchFunction = (this: Bench) => Promise<void> | void;
|
|
949
|
-
type BenchmarkAPI = ChainableFunction<'skip' | 'only' | 'todo', [
|
|
950
|
-
name: string,
|
|
951
|
-
fn?: BenchFunction,
|
|
952
|
-
options?: Options
|
|
953
|
-
], void> & {
|
|
954
|
-
skipIf(condition: any): BenchmarkAPI;
|
|
955
|
-
runIf(condition: any): BenchmarkAPI;
|
|
956
|
-
};
|
|
957
|
-
|
|
958
|
-
type RunMode = 'run' | 'skip' | 'only' | 'todo';
|
|
959
|
-
type TaskState = RunMode | 'pass' | 'fail';
|
|
960
|
-
interface TaskBase {
|
|
961
|
-
id: string;
|
|
962
|
-
name: string;
|
|
963
|
-
mode: RunMode;
|
|
964
|
-
concurrent?: boolean;
|
|
965
|
-
shuffle?: boolean;
|
|
966
|
-
suite?: Suite;
|
|
967
|
-
file?: File;
|
|
968
|
-
result?: TaskResult;
|
|
969
|
-
retry?: number;
|
|
970
|
-
logs?: UserConsoleLog[];
|
|
971
|
-
meta?: any;
|
|
972
|
-
}
|
|
973
|
-
interface TaskResult {
|
|
974
|
-
state: TaskState;
|
|
975
|
-
duration?: number;
|
|
976
|
-
startTime?: number;
|
|
977
|
-
heap?: number;
|
|
978
|
-
/**
|
|
979
|
-
* @deprecated Use "errors" instead
|
|
980
|
-
*/
|
|
981
|
-
error?: ErrorWithDiff;
|
|
982
|
-
errors?: ErrorWithDiff[];
|
|
983
|
-
htmlError?: string;
|
|
984
|
-
hooks?: Partial<Record<keyof SuiteHooks, TaskState>>;
|
|
985
|
-
benchmark?: BenchmarkResult;
|
|
986
|
-
retryCount?: number;
|
|
987
|
-
}
|
|
988
|
-
type TaskResultPack = [id: string, result: TaskResult | undefined];
|
|
989
|
-
interface Suite extends TaskBase {
|
|
990
|
-
type: 'suite';
|
|
991
|
-
tasks: Task[];
|
|
992
|
-
filepath?: string;
|
|
993
|
-
benchmark?: Bench;
|
|
994
|
-
projectName?: string;
|
|
995
|
-
}
|
|
996
|
-
interface File extends Suite {
|
|
997
|
-
filepath: string;
|
|
998
|
-
collectDuration?: number;
|
|
999
|
-
setupDuration?: number;
|
|
1000
|
-
}
|
|
1001
|
-
interface Test<ExtraContext = {}> extends TaskBase {
|
|
1002
|
-
type: 'test';
|
|
1003
|
-
suite: Suite;
|
|
1004
|
-
result?: TaskResult;
|
|
1005
|
-
fails?: boolean;
|
|
1006
|
-
context: TestContext & ExtraContext;
|
|
1007
|
-
onFailed?: OnTestFailedHandler[];
|
|
1008
|
-
}
|
|
1009
|
-
type Task = Test | Suite | File | Benchmark;
|
|
1010
|
-
type DoneCallback = (error?: any) => void;
|
|
1011
|
-
type TestFunction<ExtraContext = {}> = (context: TestContext & ExtraContext) => Awaitable<any> | void;
|
|
1012
|
-
type ExtractEachCallbackArgs<T extends ReadonlyArray<any>> = {
|
|
1013
|
-
1: [T[0]];
|
|
1014
|
-
2: [T[0], T[1]];
|
|
1015
|
-
3: [T[0], T[1], T[2]];
|
|
1016
|
-
4: [T[0], T[1], T[2], T[3]];
|
|
1017
|
-
5: [T[0], T[1], T[2], T[3], T[4]];
|
|
1018
|
-
6: [T[0], T[1], T[2], T[3], T[4], T[5]];
|
|
1019
|
-
7: [T[0], T[1], T[2], T[3], T[4], T[5], T[6]];
|
|
1020
|
-
8: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7]];
|
|
1021
|
-
9: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7], T[8]];
|
|
1022
|
-
10: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7], T[8], T[9]];
|
|
1023
|
-
fallback: Array<T extends ReadonlyArray<infer U> ? U : any>;
|
|
1024
|
-
}[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'];
|
|
1025
|
-
interface SuiteEachFunction {
|
|
1026
|
-
<T extends any[] | [any]>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T) => Awaitable<void>) => void;
|
|
1027
|
-
<T extends ReadonlyArray<any>>(cases: ReadonlyArray<T>): (name: string, fn: (...args: ExtractEachCallbackArgs<T>) => Awaitable<void>) => void;
|
|
1028
|
-
<T>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T[]) => Awaitable<void>) => void;
|
|
1029
|
-
}
|
|
1030
|
-
interface TestEachFunction {
|
|
1031
|
-
<T extends any[] | [any]>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T) => Awaitable<void>, options?: number | TestOptions) => void;
|
|
1032
|
-
<T extends ReadonlyArray<any>>(cases: ReadonlyArray<T>): (name: string, fn: (...args: ExtractEachCallbackArgs<T>) => Awaitable<void>, options?: number | TestOptions) => void;
|
|
1033
|
-
<T>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T[]) => Awaitable<void>, options?: number | TestOptions) => void;
|
|
1034
|
-
(...args: [TemplateStringsArray, ...any]): (name: string, fn: (...args: any[]) => Awaitable<void>, options?: number | TestOptions) => void;
|
|
1035
|
-
}
|
|
1036
|
-
type ChainableTestAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo' | 'fails', [
|
|
1037
|
-
name: string,
|
|
1038
|
-
fn?: TestFunction<ExtraContext>,
|
|
1039
|
-
options?: number | TestOptions
|
|
1040
|
-
], void, {
|
|
1041
|
-
each: TestEachFunction;
|
|
1042
|
-
<T extends ExtraContext>(name: string, fn?: TestFunction<T>, options?: number | TestOptions): void;
|
|
1043
|
-
}>;
|
|
1044
|
-
interface TestOptions {
|
|
1045
|
-
/**
|
|
1046
|
-
* Test timeout.
|
|
1047
|
-
*/
|
|
1048
|
-
timeout?: number;
|
|
1049
|
-
/**
|
|
1050
|
-
* Times to retry the test if fails. Useful for making flaky tests more stable.
|
|
1051
|
-
* When retries is up, the last test error will be thrown.
|
|
1052
|
-
*
|
|
1053
|
-
* @default 1
|
|
1054
|
-
*/
|
|
1055
|
-
retry?: number;
|
|
1056
|
-
}
|
|
1057
|
-
type TestAPI<ExtraContext = {}> = ChainableTestAPI<ExtraContext> & {
|
|
1058
|
-
each: TestEachFunction;
|
|
1059
|
-
skipIf(condition: any): ChainableTestAPI<ExtraContext>;
|
|
1060
|
-
runIf(condition: any): ChainableTestAPI<ExtraContext>;
|
|
1061
|
-
};
|
|
1062
|
-
type ChainableSuiteAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo' | 'shuffle', [
|
|
1063
|
-
name: string,
|
|
1064
|
-
factory?: SuiteFactory<ExtraContext>,
|
|
1065
|
-
options?: number | TestOptions
|
|
1066
|
-
], SuiteCollector<ExtraContext>, {
|
|
1067
|
-
each: TestEachFunction;
|
|
1068
|
-
<T extends ExtraContext>(name: string, factory?: SuiteFactory<T>): SuiteCollector<T>;
|
|
1069
|
-
}>;
|
|
1070
|
-
type SuiteAPI<ExtraContext = {}> = ChainableSuiteAPI<ExtraContext> & {
|
|
1071
|
-
each: SuiteEachFunction;
|
|
1072
|
-
skipIf(condition: any): ChainableSuiteAPI<ExtraContext>;
|
|
1073
|
-
runIf(condition: any): ChainableSuiteAPI<ExtraContext>;
|
|
1074
|
-
};
|
|
1075
|
-
type HookListener<T extends any[], Return = void> = (...args: T) => Awaitable<Return>;
|
|
1076
|
-
type HookCleanupCallback = (() => Awaitable<unknown>) | void;
|
|
1077
|
-
interface SuiteHooks<ExtraContext = {}> {
|
|
1078
|
-
beforeAll: HookListener<[Suite | File], HookCleanupCallback>[];
|
|
1079
|
-
afterAll: HookListener<[Suite | File]>[];
|
|
1080
|
-
beforeEach: HookListener<[TestContext & ExtraContext, Suite], HookCleanupCallback>[];
|
|
1081
|
-
afterEach: HookListener<[TestContext & ExtraContext, Suite]>[];
|
|
1082
|
-
}
|
|
1083
|
-
interface SuiteCollector<ExtraContext = {}> {
|
|
1084
|
-
readonly name: string;
|
|
1085
|
-
readonly mode: RunMode;
|
|
1086
|
-
type: 'collector';
|
|
1087
|
-
test: TestAPI<ExtraContext>;
|
|
1088
|
-
benchmark: BenchmarkAPI;
|
|
1089
|
-
tasks: (Suite | Test | Benchmark | SuiteCollector<ExtraContext>)[];
|
|
1090
|
-
collect: (file?: File) => Promise<Suite>;
|
|
1091
|
-
clear: () => void;
|
|
1092
|
-
on: <T extends keyof SuiteHooks<ExtraContext>>(name: T, ...fn: SuiteHooks<ExtraContext>[T]) => void;
|
|
1093
|
-
}
|
|
1094
|
-
type SuiteFactory<ExtraContext = {}> = (test: (name: string, fn: TestFunction<ExtraContext>) => void) => Awaitable<void>;
|
|
1095
|
-
interface RuntimeContext {
|
|
1096
|
-
tasks: (SuiteCollector | Test)[];
|
|
1097
|
-
currentSuite: SuiteCollector | null;
|
|
1098
|
-
}
|
|
1099
|
-
interface TestContext {
|
|
1100
|
-
/**
|
|
1101
|
-
* Metadata of the current test
|
|
1102
|
-
*/
|
|
1103
|
-
meta: Readonly<Test>;
|
|
1104
|
-
/**
|
|
1105
|
-
* A expect instance bound to the test
|
|
1106
|
-
*/
|
|
1107
|
-
expect: Vi.ExpectStatic;
|
|
1108
|
-
/**
|
|
1109
|
-
* Extract hooks on test failed
|
|
1110
|
-
*/
|
|
1111
|
-
onTestFailed: (fn: OnTestFailedHandler) => void;
|
|
1112
|
-
}
|
|
1113
|
-
type OnTestFailedHandler = (result: TaskResult) => Awaitable<void>;
|
|
1114
|
-
|
|
1115
905
|
type SnapshotData = Record<string, string>;
|
|
1116
906
|
type SnapshotUpdateState = 'all' | 'new' | 'none';
|
|
1117
907
|
interface SnapshotStateOptions {
|
|
@@ -1174,14 +964,14 @@ interface WorkerRPC {
|
|
|
1174
964
|
fetch: FetchFunction;
|
|
1175
965
|
resolveId: ResolveIdFunction;
|
|
1176
966
|
getSourceMap: (id: string, force?: boolean) => Promise<RawSourceMap | undefined>;
|
|
1177
|
-
onFinished: (files: File[], errors?: unknown[]) => void;
|
|
967
|
+
onFinished: (files: File$1[], errors?: unknown[]) => void;
|
|
1178
968
|
onWorkerExit: (error: unknown, code?: number) => void;
|
|
1179
969
|
onPathsCollected: (paths: string[]) => void;
|
|
1180
970
|
onUserConsoleLog: (log: UserConsoleLog) => void;
|
|
1181
|
-
|
|
1182
|
-
onCollected: (files: File[]) => void;
|
|
971
|
+
onUnhandledError: (err: unknown, type: string) => void;
|
|
972
|
+
onCollected: (files: File$1[]) => void;
|
|
1183
973
|
onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void;
|
|
1184
|
-
onTaskUpdate: (pack: TaskResultPack[]) => void;
|
|
974
|
+
onTaskUpdate: (pack: TaskResultPack$1[]) => void;
|
|
1185
975
|
snapshotSaved: (snapshot: SnapshotResult) => void;
|
|
1186
976
|
resolveSnapshotPath: (testPath: string) => string;
|
|
1187
977
|
}
|
|
@@ -1189,10 +979,9 @@ interface WorkerGlobalState {
|
|
|
1189
979
|
ctx: WorkerContext;
|
|
1190
980
|
config: ResolvedConfig;
|
|
1191
981
|
rpc: BirpcReturn<WorkerRPC>;
|
|
1192
|
-
current?: Test;
|
|
982
|
+
current?: Test$2;
|
|
1193
983
|
filepath?: string;
|
|
1194
984
|
moduleCache: ModuleCacheMap;
|
|
1195
|
-
browserHashMap?: Map<string, string>;
|
|
1196
985
|
mockMap: MockMap;
|
|
1197
986
|
}
|
|
1198
987
|
|
|
@@ -1203,7 +992,7 @@ interface CoverageProvider {
|
|
|
1203
992
|
clean(clean?: boolean): void | Promise<void>;
|
|
1204
993
|
onBeforeFilesRun?(): void | Promise<void>;
|
|
1205
994
|
onAfterSuiteRun(meta: AfterSuiteRunMeta): void | Promise<void>;
|
|
1206
|
-
reportCoverage(reportContext
|
|
995
|
+
reportCoverage(reportContext?: ReportContext): void | Promise<void>;
|
|
1207
996
|
onFileTransform?(sourceCode: string, id: string, pluginCtx: TransformPluginContext): TransformResult | Promise<TransformResult>;
|
|
1208
997
|
}
|
|
1209
998
|
interface ReportContext {
|
|
@@ -1221,16 +1010,19 @@ interface CoverageProviderModule {
|
|
|
1221
1010
|
takeCoverage?(): unknown | Promise<unknown>;
|
|
1222
1011
|
}
|
|
1223
1012
|
type CoverageReporter = 'clover' | 'cobertura' | 'html-spa' | 'html' | 'json-summary' | 'json' | 'lcov' | 'lcovonly' | 'none' | 'teamcity' | 'text-lcov' | 'text-summary' | 'text';
|
|
1224
|
-
type
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1013
|
+
type Provider = 'c8' | 'istanbul' | CoverageProviderModule | undefined;
|
|
1014
|
+
type CoverageOptions<T extends Provider = Provider> = T extends CoverageProviderModule ? ({
|
|
1015
|
+
provider: T;
|
|
1016
|
+
} & BaseCoverageOptions) : T extends 'istanbul' ? ({
|
|
1017
|
+
provider: T;
|
|
1018
|
+
} & CoverageIstanbulOptions) : ({
|
|
1019
|
+
provider?: T;
|
|
1020
|
+
} & CoverageC8Options);
|
|
1021
|
+
/** Fields that have default values. Internally these will always be defined. */
|
|
1022
|
+
type FieldsWithDefaultValues = 'enabled' | 'clean' | 'cleanOnRerun' | 'reportsDirectory' | 'exclude' | 'extension' | 'reporter';
|
|
1023
|
+
type ResolvedCoverageOptions<T extends Provider = Provider> = CoverageOptions<T> & Required<Pick<CoverageOptions<T>, FieldsWithDefaultValues>> & {
|
|
1024
|
+
reporter: CoverageReporter[];
|
|
1230
1025
|
};
|
|
1231
|
-
type ResolvedCoverageOptions = {
|
|
1232
|
-
tempDirectory: string;
|
|
1233
|
-
} & Required<CoverageOptions>;
|
|
1234
1026
|
interface BaseCoverageOptions {
|
|
1235
1027
|
/**
|
|
1236
1028
|
* Enables coverage collection. Can be overriden using `--coverage` CLI option.
|
|
@@ -1447,19 +1239,55 @@ interface JSDOMOptions {
|
|
|
1447
1239
|
resources?: 'usable' | any;
|
|
1448
1240
|
}
|
|
1449
1241
|
|
|
1450
|
-
interface
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1242
|
+
interface BenchmarkUserOptions {
|
|
1243
|
+
/**
|
|
1244
|
+
* Include globs for benchmark test files
|
|
1245
|
+
*
|
|
1246
|
+
* @default ['**\/*.{bench,benchmark}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}']
|
|
1247
|
+
*/
|
|
1248
|
+
include?: string[];
|
|
1249
|
+
/**
|
|
1250
|
+
* Exclude globs for benchmark test files
|
|
1251
|
+
* @default ['node_modules', 'dist', '.idea', '.git', '.cache']
|
|
1252
|
+
*/
|
|
1253
|
+
exclude?: string[];
|
|
1254
|
+
/**
|
|
1255
|
+
* Include globs for in-source benchmark test files
|
|
1256
|
+
*
|
|
1257
|
+
* @default []
|
|
1258
|
+
*/
|
|
1259
|
+
includeSource?: string[];
|
|
1260
|
+
/**
|
|
1261
|
+
* Custom reporter for output. Can contain one or more built-in report names, reporter instances,
|
|
1262
|
+
* and/or paths to custom reporters
|
|
1263
|
+
*/
|
|
1264
|
+
reporters?: Arrayable$1<BenchmarkBuiltinReporters | Reporter>;
|
|
1265
|
+
/**
|
|
1266
|
+
* Write test results to a file when the `--reporter=json` option is also specified.
|
|
1267
|
+
* Also definable individually per reporter by using an object instead.
|
|
1268
|
+
*/
|
|
1269
|
+
outputFile?: string | (Partial<Record<BenchmarkBuiltinReporters, string>> & Record<string, string>);
|
|
1270
|
+
}
|
|
1271
|
+
interface Benchmark extends TaskCustom {
|
|
1272
|
+
meta: {
|
|
1273
|
+
benchmark: true;
|
|
1274
|
+
task?: Task$2;
|
|
1275
|
+
result?: TaskResult;
|
|
1276
|
+
};
|
|
1277
|
+
}
|
|
1278
|
+
interface BenchmarkResult extends TaskResult {
|
|
1279
|
+
name: string;
|
|
1280
|
+
rank: number;
|
|
1462
1281
|
}
|
|
1282
|
+
type BenchFunction = (this: Bench) => Promise<void> | void;
|
|
1283
|
+
type BenchmarkAPI = ChainableFunction<'skip' | 'only' | 'todo', [
|
|
1284
|
+
name: string,
|
|
1285
|
+
fn?: BenchFunction,
|
|
1286
|
+
options?: Options
|
|
1287
|
+
], void> & {
|
|
1288
|
+
skipIf(condition: any): BenchmarkAPI;
|
|
1289
|
+
runIf(condition: any): BenchmarkAPI;
|
|
1290
|
+
};
|
|
1463
1291
|
|
|
1464
1292
|
type BuiltinEnvironment = 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime';
|
|
1465
1293
|
type VitestEnvironment = BuiltinEnvironment | (string & Record<never, never>);
|
|
@@ -1570,6 +1398,21 @@ interface InlineConfig {
|
|
|
1570
1398
|
* Environment options.
|
|
1571
1399
|
*/
|
|
1572
1400
|
environmentOptions?: EnvironmentOptions;
|
|
1401
|
+
/**
|
|
1402
|
+
* Automatically assign environment based on globs. The first match will be used.
|
|
1403
|
+
*
|
|
1404
|
+
* Format: [glob, environment-name]
|
|
1405
|
+
*
|
|
1406
|
+
* @default []
|
|
1407
|
+
* @example [
|
|
1408
|
+
* // all tests in tests/dom will run in jsdom
|
|
1409
|
+
* ['tests/dom/**', 'jsdom'],
|
|
1410
|
+
* // all tests in tests/ with .edge.test.ts will run in edge-runtime
|
|
1411
|
+
* ['**\/*.edge.test.ts', 'edge-runtime'],
|
|
1412
|
+
* // ...
|
|
1413
|
+
* ]
|
|
1414
|
+
*/
|
|
1415
|
+
environmentMatchGlobs?: [string, VitestEnvironment][];
|
|
1573
1416
|
/**
|
|
1574
1417
|
* Update snapshot
|
|
1575
1418
|
*
|
|
@@ -1882,6 +1725,10 @@ interface InlineConfig {
|
|
|
1882
1725
|
* @default 300
|
|
1883
1726
|
*/
|
|
1884
1727
|
slowTestThreshold?: number;
|
|
1728
|
+
/**
|
|
1729
|
+
* Path to a custom test runner.
|
|
1730
|
+
*/
|
|
1731
|
+
runner?: string;
|
|
1885
1732
|
}
|
|
1886
1733
|
interface TypecheckConfig {
|
|
1887
1734
|
/**
|
|
@@ -1944,7 +1791,7 @@ interface UserConfig extends InlineConfig {
|
|
|
1944
1791
|
*/
|
|
1945
1792
|
shard?: string;
|
|
1946
1793
|
}
|
|
1947
|
-
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'benchmark' | 'shard' | 'cache' | 'sequence' | 'typecheck'> {
|
|
1794
|
+
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'benchmark' | 'shard' | 'cache' | 'sequence' | 'typecheck' | 'runner'> {
|
|
1948
1795
|
mode: VitestRunMode;
|
|
1949
1796
|
base?: string;
|
|
1950
1797
|
config?: string;
|
|
@@ -1973,6 +1820,7 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'
|
|
|
1973
1820
|
seed?: number;
|
|
1974
1821
|
};
|
|
1975
1822
|
typecheck: TypecheckConfig;
|
|
1823
|
+
runner?: string;
|
|
1976
1824
|
}
|
|
1977
1825
|
type RuntimeConfig = Pick<UserConfig, 'allowOnly' | 'testTimeout' | 'hookTimeout' | 'clearMocks' | 'mockReset' | 'restoreMocks' | 'fakeTimers' | 'maxConcurrency'> & {
|
|
1978
1826
|
sequence?: {
|
|
@@ -1990,110 +1838,6 @@ declare module 'vite' {
|
|
|
1990
1838
|
}
|
|
1991
1839
|
}
|
|
1992
1840
|
|
|
1993
|
-
declare function stringify(object: unknown, maxDepth?: number, { maxLength, ...options }?: PrettyFormatOptions & {
|
|
1994
|
-
maxLength?: number;
|
|
1995
|
-
}): string;
|
|
1996
|
-
|
|
1997
|
-
type Formatter = (input: string | number | null | undefined) => string;
|
|
1998
|
-
|
|
1999
|
-
declare const EXPECTED_COLOR: Formatter;
|
|
2000
|
-
declare const RECEIVED_COLOR: Formatter;
|
|
2001
|
-
declare const INVERTED_COLOR: Formatter;
|
|
2002
|
-
declare const BOLD_WEIGHT: Formatter;
|
|
2003
|
-
declare const DIM_COLOR: Formatter;
|
|
2004
|
-
declare function matcherHint(matcherName: string, received?: string, expected?: string, options?: MatcherHintOptions): string;
|
|
2005
|
-
declare const printReceived: (object: unknown) => string;
|
|
2006
|
-
declare const printExpected: (value: unknown) => string;
|
|
2007
|
-
declare function diff(a: any, b: any, options?: DiffOptions): string;
|
|
2008
|
-
|
|
2009
|
-
declare const jestMatcherUtils_stringify: typeof stringify;
|
|
2010
|
-
declare const jestMatcherUtils_EXPECTED_COLOR: typeof EXPECTED_COLOR;
|
|
2011
|
-
declare const jestMatcherUtils_RECEIVED_COLOR: typeof RECEIVED_COLOR;
|
|
2012
|
-
declare const jestMatcherUtils_INVERTED_COLOR: typeof INVERTED_COLOR;
|
|
2013
|
-
declare const jestMatcherUtils_BOLD_WEIGHT: typeof BOLD_WEIGHT;
|
|
2014
|
-
declare const jestMatcherUtils_DIM_COLOR: typeof DIM_COLOR;
|
|
2015
|
-
declare const jestMatcherUtils_matcherHint: typeof matcherHint;
|
|
2016
|
-
declare const jestMatcherUtils_printReceived: typeof printReceived;
|
|
2017
|
-
declare const jestMatcherUtils_printExpected: typeof printExpected;
|
|
2018
|
-
declare const jestMatcherUtils_diff: typeof diff;
|
|
2019
|
-
declare namespace jestMatcherUtils {
|
|
2020
|
-
export {
|
|
2021
|
-
jestMatcherUtils_stringify as stringify,
|
|
2022
|
-
jestMatcherUtils_EXPECTED_COLOR as EXPECTED_COLOR,
|
|
2023
|
-
jestMatcherUtils_RECEIVED_COLOR as RECEIVED_COLOR,
|
|
2024
|
-
jestMatcherUtils_INVERTED_COLOR as INVERTED_COLOR,
|
|
2025
|
-
jestMatcherUtils_BOLD_WEIGHT as BOLD_WEIGHT,
|
|
2026
|
-
jestMatcherUtils_DIM_COLOR as DIM_COLOR,
|
|
2027
|
-
jestMatcherUtils_matcherHint as matcherHint,
|
|
2028
|
-
jestMatcherUtils_printReceived as printReceived,
|
|
2029
|
-
jestMatcherUtils_printExpected as printExpected,
|
|
2030
|
-
jestMatcherUtils_diff as diff,
|
|
2031
|
-
};
|
|
2032
|
-
}
|
|
2033
|
-
type Tester = (a: any, b: any) => boolean | undefined;
|
|
2034
|
-
interface MatcherHintOptions {
|
|
2035
|
-
comment?: string;
|
|
2036
|
-
expectedColor?: Formatter;
|
|
2037
|
-
isDirectExpectCall?: boolean;
|
|
2038
|
-
isNot?: boolean;
|
|
2039
|
-
promise?: string;
|
|
2040
|
-
receivedColor?: Formatter;
|
|
2041
|
-
secondArgument?: string;
|
|
2042
|
-
secondArgumentColor?: Formatter;
|
|
2043
|
-
}
|
|
2044
|
-
interface DiffOptions {
|
|
2045
|
-
aAnnotation?: string;
|
|
2046
|
-
aColor?: Formatter;
|
|
2047
|
-
aIndicator?: string;
|
|
2048
|
-
bAnnotation?: string;
|
|
2049
|
-
bColor?: Formatter;
|
|
2050
|
-
bIndicator?: string;
|
|
2051
|
-
changeColor?: Formatter;
|
|
2052
|
-
changeLineTrailingSpaceColor?: Formatter;
|
|
2053
|
-
commonColor?: Formatter;
|
|
2054
|
-
commonIndicator?: string;
|
|
2055
|
-
commonLineTrailingSpaceColor?: Formatter;
|
|
2056
|
-
contextLines?: number;
|
|
2057
|
-
emptyFirstOrLastLinePlaceholder?: string;
|
|
2058
|
-
expand?: boolean;
|
|
2059
|
-
includeChangeCounts?: boolean;
|
|
2060
|
-
omitAnnotationLines?: boolean;
|
|
2061
|
-
patchColor?: Formatter;
|
|
2062
|
-
compareKeys?: any;
|
|
2063
|
-
}
|
|
2064
|
-
interface MatcherState$1 {
|
|
2065
|
-
assertionCalls: number;
|
|
2066
|
-
currentTestName?: string;
|
|
2067
|
-
dontThrow?: () => void;
|
|
2068
|
-
error?: Error;
|
|
2069
|
-
equals: (a: unknown, b: unknown, customTesters?: Array<Tester>, strictCheck?: boolean) => boolean;
|
|
2070
|
-
expand?: boolean;
|
|
2071
|
-
expectedAssertionsNumber?: number | null;
|
|
2072
|
-
expectedAssertionsNumberErrorGen?: (() => Error) | null;
|
|
2073
|
-
isExpectingAssertions?: boolean;
|
|
2074
|
-
isExpectingAssertionsError?: Error | null;
|
|
2075
|
-
isNot: boolean;
|
|
2076
|
-
promise: string;
|
|
2077
|
-
suppressedErrors: Array<Error>;
|
|
2078
|
-
testPath?: string;
|
|
2079
|
-
utils: typeof jestMatcherUtils & {
|
|
2080
|
-
iterableEquality: Tester;
|
|
2081
|
-
subsetEquality: Tester;
|
|
2082
|
-
};
|
|
2083
|
-
}
|
|
2084
|
-
interface SyncExpectationResult {
|
|
2085
|
-
pass: boolean;
|
|
2086
|
-
message: () => string;
|
|
2087
|
-
actual?: any;
|
|
2088
|
-
expected?: any;
|
|
2089
|
-
}
|
|
2090
|
-
type AsyncExpectationResult = Promise<SyncExpectationResult>;
|
|
2091
|
-
type ExpectationResult = SyncExpectationResult | AsyncExpectationResult;
|
|
2092
|
-
interface RawMatcherFn<T extends MatcherState$1 = MatcherState$1> {
|
|
2093
|
-
(this: T, received: any, expected: any, options?: any): ExpectationResult;
|
|
2094
|
-
}
|
|
2095
|
-
type MatchersObject<T extends MatcherState$1 = MatcherState$1> = Record<string, RawMatcherFn<T>>;
|
|
2096
|
-
|
|
2097
1841
|
/**
|
|
2098
1842
|
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
2099
1843
|
*
|
|
@@ -2123,12 +1867,15 @@ declare class SnapshotState {
|
|
|
2123
1867
|
private _inlineSnapshots;
|
|
2124
1868
|
private _uncheckedKeys;
|
|
2125
1869
|
private _snapshotFormat;
|
|
1870
|
+
private _environment;
|
|
1871
|
+
private _fileExists;
|
|
2126
1872
|
added: number;
|
|
2127
1873
|
expand: boolean;
|
|
2128
1874
|
matched: number;
|
|
2129
1875
|
unmatched: number;
|
|
2130
1876
|
updated: number;
|
|
2131
|
-
constructor(
|
|
1877
|
+
private constructor();
|
|
1878
|
+
static create(testFilePath: string, options: SnapshotStateOptions): Promise<SnapshotState>;
|
|
2132
1879
|
markSnapshotsAsCheckedForTest(testName: string): void;
|
|
2133
1880
|
private _inferInlineSnapshotStack;
|
|
2134
1881
|
private _addSnapshot;
|
|
@@ -2141,14 +1888,26 @@ declare class SnapshotState {
|
|
|
2141
1888
|
pack(): Promise<SnapshotResult>;
|
|
2142
1889
|
}
|
|
2143
1890
|
|
|
2144
|
-
interface MatcherState extends MatcherState$1 {
|
|
2145
|
-
environment: VitestEnvironment;
|
|
2146
|
-
snapshotState: SnapshotState;
|
|
2147
|
-
}
|
|
2148
|
-
|
|
2149
1891
|
type Promisify<O> = {
|
|
2150
1892
|
[K in keyof O]: O[K] extends (...args: infer A) => infer R ? O extends R ? Promisify<O[K]> : (...args: A) => Promise<R> : O[K];
|
|
2151
1893
|
};
|
|
1894
|
+
declare module '@vitest/expect' {
|
|
1895
|
+
interface MatcherState {
|
|
1896
|
+
environment: VitestEnvironment;
|
|
1897
|
+
snapshotState: SnapshotState;
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
declare module '@vitest/runner' {
|
|
1901
|
+
interface TestContext {
|
|
1902
|
+
expect: Vi.ExpectStatic;
|
|
1903
|
+
}
|
|
1904
|
+
interface TaskBase {
|
|
1905
|
+
logs?: UserConsoleLog[];
|
|
1906
|
+
}
|
|
1907
|
+
interface TaskResult {
|
|
1908
|
+
benchmark?: BenchmarkResult;
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
2152
1911
|
declare global {
|
|
2153
1912
|
namespace jest {
|
|
2154
1913
|
interface Matchers<R, T = {}> {
|
|
@@ -2271,4 +2030,4 @@ type Context = RootAndTarget & {
|
|
|
2271
2030
|
lastActivePath?: string;
|
|
2272
2031
|
};
|
|
2273
2032
|
|
|
2274
|
-
export {
|
|
2033
|
+
export { CoverageReporter as $, ApiConfig as A, BenchmarkAPI as B, CollectLineNumbers as C, MergeInsertions as D, EnvironmentOptions as E, FakeTimerInstallOpts as F, DeepMerge as G, MutableArray as H, InlineConfig as I, JSDOMOptions as J, Constructable as K, ModuleCache as L, MockFactoryWithHelper as M, Nullable as N, EnvironmentReturn as O, Environment as P, UserConsoleLog as Q, RuntimeConfig as R, SnapshotResult as S, TscErrorInfo as T, UserConfig as U, VitestEnvironment as V, WorkerContext as W, OnServerRestartHandler as X, CoverageProvider as Y, ReportContext as Z, CoverageProviderModule as _, ResolvedConfig as a, CoverageOptions as a0, ResolvedCoverageOptions as a1, BaseCoverageOptions as a2, CoverageIstanbulOptions as a3, CoverageC8Options as a4, BenchmarkUserOptions as a5, Benchmark as a6, BenchmarkResult as a7, BenchFunction as a8, MockFactory as a9, MockMap as aa, TestSequencer as ab, startVitest as ac, TestSequencerConstructor as ad, ModuleGraphData as b, Reporter as c, RawErrsMap as d, CollectLines as e, RootAndTarget as f, Context as g, BuiltinEnvironment as h, CSSModuleScopeStrategy as i, SequenceHooks as j, VitestRunMode as k, TypecheckConfig as l, Vitest as m, SnapshotData as n, SnapshotUpdateState as o, SnapshotStateOptions as p, SnapshotMatchOptions as q, UncheckedSnapshot as r, SnapshotSummary as s, ResolveIdFunction as t, AfterSuiteRunMeta as u, WorkerRPC as v, WorkerGlobalState as w, Awaitable as x, Arrayable as y, ArgumentsType$1 as z };
|