vitest 0.30.0 → 0.31.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 +331 -594
- package/dist/browser.d.ts +3 -4
- package/dist/browser.js +2 -2
- package/dist/child.js +12 -4
- package/dist/{chunk-api-setup.6662587e.js → chunk-api-setup.df3106cd.js} +14 -5
- package/dist/{chunk-install-pkg.6450b372.js → chunk-install-pkg.e0e70dba.js} +4 -5
- package/dist/{chunk-integrations-globals.d419838f.js → chunk-integrations-globals.88c8a0cf.js} +2 -2
- package/dist/cli.js +6 -7
- package/dist/config.cjs +1 -0
- package/dist/config.d.ts +11 -8
- package/dist/config.js +1 -0
- package/dist/coverage.d.ts +5 -5
- package/dist/coverage.js +6 -6
- package/dist/entry.js +22 -5
- package/dist/environments.d.ts +3 -4
- package/dist/index.d.ts +14 -6
- package/dist/index.js +3 -3
- package/dist/node.d.ts +4 -5
- package/dist/node.js +6 -7
- package/dist/runners.d.ts +7 -5
- package/dist/runners.js +12 -1
- package/dist/{types-f03c83c4.d.ts → types-b7007192.d.ts} +84 -328
- package/dist/{vendor-cli-api.c04eaa34.js → vendor-cli-api.de0530cb.js} +2061 -2353
- package/dist/{vendor-coverage.a585b712.js → vendor-coverage.c8fd34c3.js} +2 -0
- package/dist/{vendor-execute.8eaab47b.js → vendor-execute.a08cff9c.js} +2 -2
- package/dist/{vendor-index.4f82d248.js → vendor-index.7dcbfa46.js} +7 -1
- package/dist/{vendor-index.81b9e499.js → vendor-index.b0b501c8.js} +1 -1
- package/dist/{vendor-setup.common.cef38f4e.js → vendor-setup.common.266b69fb.js} +1 -1
- package/dist/{vendor-vi.a3ff54b1.js → vendor-vi.458e47b1.js} +9 -1
- package/dist/worker.js +13 -4
- package/package.json +11 -10
- package/suppress-warnings.cjs +1 -0
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import { MatchersObject, MatcherState } from '@vitest/expect';
|
|
2
1
|
import { SnapshotResult, SnapshotStateOptions, SnapshotState } from '@vitest/snapshot';
|
|
3
|
-
import {
|
|
2
|
+
import { ExpectStatic } from '@vitest/expect';
|
|
3
|
+
import { ViteDevServer, UserConfig as UserConfig$1, TransformResult as TransformResult$1, CommonServerOptions, AliasOptions, DepOptimizationConfig } from 'vite';
|
|
4
4
|
import * as _vitest_runner from '@vitest/runner';
|
|
5
|
-
import { Task as Task$1, Test as Test$2, TaskCustom, SequenceHooks, SequenceSetupFiles } from '@vitest/runner';
|
|
5
|
+
import { CancelReason, Task as Task$1, Test as Test$2, TaskCustom, SequenceHooks, SequenceSetupFiles } from '@vitest/runner';
|
|
6
6
|
import { File, Test as Test$1, Suite, TaskResultPack, Task } from '@vitest/runner/types';
|
|
7
7
|
import { ParsedStack, ErrorWithDiff, ChainableFunction } from '@vitest/runner/utils';
|
|
8
8
|
import { Awaitable as Awaitable$1, Arrayable as Arrayable$1 } from '@vitest/utils';
|
|
9
9
|
import { Task as Task$2, TaskResult, Bench, Options } from 'tinybench';
|
|
10
10
|
import { ViteNodeRunner } from 'vite-node/client';
|
|
11
11
|
import { SnapshotManager } from '@vitest/snapshot/manager';
|
|
12
|
+
import { ViteNodeServer } from 'vite-node/server';
|
|
12
13
|
import { MessagePort } from 'node:worker_threads';
|
|
13
14
|
import { RawSourceMap, FetchResult, ViteNodeResolveId, ModuleCacheMap } from 'vite-node';
|
|
14
|
-
import { RawSourceMap as RawSourceMap$1 } from 'source-map';
|
|
15
|
-
import { ViteNodeServer } from 'vite-node/server';
|
|
16
15
|
import { Stats } from 'node:fs';
|
|
17
16
|
import * as chai from 'chai';
|
|
18
17
|
|
|
@@ -244,14 +243,8 @@ declare class Typechecker {
|
|
|
244
243
|
getTestPacks(): TaskResultPack[];
|
|
245
244
|
}
|
|
246
245
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
private getVitestPath;
|
|
250
|
-
protected processTransformResult(id: string, result: TransformResult$1): Promise<TransformResult$1>;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
interface InitializeOptions {
|
|
254
|
-
server?: VitestServer;
|
|
246
|
+
interface InitializeServerOptions {
|
|
247
|
+
server?: ViteNodeServer;
|
|
255
248
|
runner?: ViteNodeRunner;
|
|
256
249
|
}
|
|
257
250
|
declare class WorkspaceProject {
|
|
@@ -260,7 +253,7 @@ declare class WorkspaceProject {
|
|
|
260
253
|
configOverride: Partial<ResolvedConfig> | undefined;
|
|
261
254
|
config: ResolvedConfig;
|
|
262
255
|
server: ViteDevServer;
|
|
263
|
-
vitenode:
|
|
256
|
+
vitenode: ViteNodeServer;
|
|
264
257
|
runner: ViteNodeRunner;
|
|
265
258
|
browser: ViteDevServer;
|
|
266
259
|
typechecker?: Typechecker;
|
|
@@ -273,9 +266,11 @@ declare class WorkspaceProject {
|
|
|
273
266
|
globTestFiles(filters?: string[]): Promise<string[]>;
|
|
274
267
|
globAllTestFiles(config: ResolvedConfig, cwd: string): Promise<string[]>;
|
|
275
268
|
globFiles(include: string[], exclude: string[], cwd: string): Promise<string[]>;
|
|
269
|
+
isTargetFile(id: string, source?: string): Promise<boolean>;
|
|
270
|
+
isInSourceTestFile(code: string): boolean;
|
|
276
271
|
filterFiles(testFiles: string[], filters?: string[]): string[];
|
|
277
272
|
initBrowserServer(options: UserConfig): Promise<void>;
|
|
278
|
-
setServer(options: UserConfig, server: ViteDevServer, params?:
|
|
273
|
+
setServer(options: UserConfig, server: ViteDevServer, params?: InitializeServerOptions): Promise<void>;
|
|
279
274
|
report<T extends keyof Reporter>(name: T, ...args: ArgumentsType$1<Reporter[T]>): Promise<void>;
|
|
280
275
|
typecheck(filters?: string[]): Promise<void>;
|
|
281
276
|
isBrowserEnabled(): boolean | 0;
|
|
@@ -323,6 +318,14 @@ interface BrowserConfigOptions {
|
|
|
323
318
|
* The default port is 63315.
|
|
324
319
|
*/
|
|
325
320
|
api?: ApiConfig | number;
|
|
321
|
+
/**
|
|
322
|
+
* Update ESM imports so they can be spied/stubbed with vi.spyOn.
|
|
323
|
+
* Enabled by default when running in browser.
|
|
324
|
+
*
|
|
325
|
+
* @default true
|
|
326
|
+
* @experimental
|
|
327
|
+
*/
|
|
328
|
+
slowHijackESM?: boolean;
|
|
326
329
|
}
|
|
327
330
|
interface ResolvedBrowserOptions extends BrowserConfigOptions {
|
|
328
331
|
enabled: boolean;
|
|
@@ -368,6 +371,8 @@ declare class StateManager {
|
|
|
368
371
|
updateId(task: Task): void;
|
|
369
372
|
updateTasks(packs: TaskResultPack[]): void;
|
|
370
373
|
updateUserLog(log: UserConsoleLog): void;
|
|
374
|
+
getCountOfFailedTests(): number;
|
|
375
|
+
cancelFiles(files: string[], root: string): void;
|
|
371
376
|
}
|
|
372
377
|
|
|
373
378
|
declare class Logger {
|
|
@@ -466,12 +471,13 @@ declare class Vitest {
|
|
|
466
471
|
browserProvider: BrowserProvider | undefined;
|
|
467
472
|
logger: Logger;
|
|
468
473
|
pool: ProcessPool | undefined;
|
|
469
|
-
vitenode:
|
|
474
|
+
vitenode: ViteNodeServer;
|
|
470
475
|
invalidates: Set<string>;
|
|
471
476
|
changedTests: Set<string>;
|
|
472
477
|
filenamePattern?: string;
|
|
473
478
|
runningPromise?: Promise<void>;
|
|
474
479
|
closingPromise?: Promise<void>;
|
|
480
|
+
isCancelling: boolean;
|
|
475
481
|
isFirstRun: boolean;
|
|
476
482
|
restartsCount: number;
|
|
477
483
|
runner: ViteNodeRunner;
|
|
@@ -481,9 +487,10 @@ declare class Vitest {
|
|
|
481
487
|
constructor(mode: VitestRunMode);
|
|
482
488
|
private _onRestartListeners;
|
|
483
489
|
private _onSetServer;
|
|
490
|
+
private _onCancelListeners;
|
|
484
491
|
setServer(options: UserConfig, server: ViteDevServer, cliOptions: UserConfig): Promise<void>;
|
|
485
492
|
private createCoreWorkspace;
|
|
486
|
-
getCoreWorkspaceProject(): WorkspaceProject;
|
|
493
|
+
getCoreWorkspaceProject(): WorkspaceProject | null;
|
|
487
494
|
private resolveWorkspace;
|
|
488
495
|
private initCoverageProvider;
|
|
489
496
|
private initBrowserProviders;
|
|
@@ -493,6 +500,7 @@ declare class Vitest {
|
|
|
493
500
|
filterTestsBySource(specs: WorkspaceSpec[]): Promise<WorkspaceSpec[]>;
|
|
494
501
|
getProjectsByTestFile(file: string): WorkspaceSpec[];
|
|
495
502
|
runFiles(paths: WorkspaceSpec[]): Promise<void>;
|
|
503
|
+
cancelCurrentRun(reason: CancelReason): Promise<void>;
|
|
496
504
|
rerunFiles(files?: string[], trigger?: string): Promise<void>;
|
|
497
505
|
changeNamePattern(pattern: string, files?: string[], trigger?: string): Promise<void>;
|
|
498
506
|
changeFilenamePattern(pattern: string): Promise<void>;
|
|
@@ -515,11 +523,10 @@ declare class Vitest {
|
|
|
515
523
|
exit(force?: boolean): Promise<void>;
|
|
516
524
|
report<T extends keyof Reporter>(name: T, ...args: ArgumentsType$1<Reporter[T]>): Promise<void>;
|
|
517
525
|
globTestFiles(filters?: string[]): Promise<WorkspaceSpec[]>;
|
|
518
|
-
private isTargetFile;
|
|
519
526
|
shouldKeepServer(): boolean;
|
|
520
|
-
isInSourceTestFile(code: string): boolean;
|
|
521
527
|
onServerRestart(fn: OnServerRestartHandler): void;
|
|
522
528
|
onAfterSetServer(fn: OnServerRestartHandler): void;
|
|
529
|
+
onCancel(fn: (reason: CancelReason) => void): void;
|
|
523
530
|
}
|
|
524
531
|
|
|
525
532
|
type MockFactoryWithHelper = (importOriginal: <T = unknown>() => Promise<T>) => any;
|
|
@@ -776,202 +783,12 @@ declare const ReportersMap: {
|
|
|
776
783
|
};
|
|
777
784
|
type BuiltinReporters = keyof typeof ReportersMap;
|
|
778
785
|
|
|
779
|
-
declare function createExpect(test?: Test$2):
|
|
780
|
-
declare const globalExpect:
|
|
786
|
+
declare function createExpect(test?: Test$2): ExpectStatic;
|
|
787
|
+
declare const globalExpect: ExpectStatic;
|
|
781
788
|
|
|
782
789
|
declare function setupChaiConfig(config: ChaiConfig): void;
|
|
783
790
|
type ChaiConfig = Omit<Partial<typeof chai.config>, 'useProxy' | 'proxyExcludedKeys'>;
|
|
784
791
|
|
|
785
|
-
// utils
|
|
786
|
-
type NullValue = null | undefined | void;
|
|
787
|
-
|
|
788
|
-
type PartialNull<T> = {
|
|
789
|
-
[P in keyof T]: T[P] | null;
|
|
790
|
-
};
|
|
791
|
-
|
|
792
|
-
interface RollupError extends RollupLog {
|
|
793
|
-
name?: string;
|
|
794
|
-
stack?: string;
|
|
795
|
-
watchFiles?: string[];
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
type RollupWarning = RollupLog;
|
|
799
|
-
|
|
800
|
-
interface RollupLog {
|
|
801
|
-
binding?: string;
|
|
802
|
-
cause?: unknown;
|
|
803
|
-
code?: string;
|
|
804
|
-
exporter?: string;
|
|
805
|
-
frame?: string;
|
|
806
|
-
hook?: string;
|
|
807
|
-
id?: string;
|
|
808
|
-
ids?: string[];
|
|
809
|
-
loc?: {
|
|
810
|
-
column: number;
|
|
811
|
-
file?: string;
|
|
812
|
-
line: number;
|
|
813
|
-
};
|
|
814
|
-
message: string;
|
|
815
|
-
names?: string[];
|
|
816
|
-
plugin?: string;
|
|
817
|
-
pluginCode?: string;
|
|
818
|
-
pos?: number;
|
|
819
|
-
reexporter?: string;
|
|
820
|
-
stack?: string;
|
|
821
|
-
url?: string;
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
interface ExistingRawSourceMap {
|
|
825
|
-
file?: string;
|
|
826
|
-
mappings: string;
|
|
827
|
-
names: string[];
|
|
828
|
-
sourceRoot?: string;
|
|
829
|
-
sources: string[];
|
|
830
|
-
sourcesContent?: (string | null)[];
|
|
831
|
-
version: number;
|
|
832
|
-
x_google_ignoreList?: number[];
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
interface SourceMap {
|
|
836
|
-
file: string;
|
|
837
|
-
mappings: string;
|
|
838
|
-
names: string[];
|
|
839
|
-
sources: string[];
|
|
840
|
-
sourcesContent: (string | null)[];
|
|
841
|
-
version: number;
|
|
842
|
-
toString(): string;
|
|
843
|
-
toUrl(): string;
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
type SourceMapInput = ExistingRawSourceMap | string | null | { mappings: '' };
|
|
847
|
-
|
|
848
|
-
interface ModuleOptions {
|
|
849
|
-
assertions: Record<string, string>;
|
|
850
|
-
meta: CustomPluginOptions;
|
|
851
|
-
moduleSideEffects: boolean | 'no-treeshake';
|
|
852
|
-
syntheticNamedExports: boolean | string;
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
interface SourceDescription extends Partial<PartialNull<ModuleOptions>> {
|
|
856
|
-
ast?: AcornNode;
|
|
857
|
-
code: string;
|
|
858
|
-
map?: SourceMapInput;
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
interface PluginCache {
|
|
862
|
-
delete(id: string): boolean;
|
|
863
|
-
get<T = any>(id: string): T;
|
|
864
|
-
has(id: string): boolean;
|
|
865
|
-
set<T = any>(id: string, value: T): void;
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
interface MinimalPluginContext {
|
|
869
|
-
meta: PluginContextMeta;
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
interface EmittedAsset {
|
|
873
|
-
fileName?: string;
|
|
874
|
-
name?: string;
|
|
875
|
-
needsCodeReference?: boolean;
|
|
876
|
-
source?: string | Uint8Array;
|
|
877
|
-
type: 'asset';
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
interface EmittedChunk {
|
|
881
|
-
fileName?: string;
|
|
882
|
-
id: string;
|
|
883
|
-
implicitlyLoadedAfterOneOf?: string[];
|
|
884
|
-
importer?: string;
|
|
885
|
-
name?: string;
|
|
886
|
-
preserveSignature?: PreserveEntrySignaturesOption;
|
|
887
|
-
type: 'chunk';
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
type EmittedFile = EmittedAsset | EmittedChunk;
|
|
891
|
-
|
|
892
|
-
type EmitFile = (emittedFile: EmittedFile) => string;
|
|
893
|
-
|
|
894
|
-
interface ModuleInfo extends ModuleOptions {
|
|
895
|
-
ast: AcornNode | null;
|
|
896
|
-
code: string | null;
|
|
897
|
-
dynamicImporters: readonly string[];
|
|
898
|
-
dynamicallyImportedIdResolutions: readonly ResolvedId[];
|
|
899
|
-
dynamicallyImportedIds: readonly string[];
|
|
900
|
-
exportedBindings: Record<string, string[]> | null;
|
|
901
|
-
exports: string[] | null;
|
|
902
|
-
hasDefaultExport: boolean | null;
|
|
903
|
-
/** @deprecated Use `moduleSideEffects` instead */
|
|
904
|
-
hasModuleSideEffects: boolean | 'no-treeshake';
|
|
905
|
-
id: string;
|
|
906
|
-
implicitlyLoadedAfterOneOf: readonly string[];
|
|
907
|
-
implicitlyLoadedBefore: readonly string[];
|
|
908
|
-
importedIdResolutions: readonly ResolvedId[];
|
|
909
|
-
importedIds: readonly string[];
|
|
910
|
-
importers: readonly string[];
|
|
911
|
-
isEntry: boolean;
|
|
912
|
-
isExternal: boolean;
|
|
913
|
-
isIncluded: boolean | null;
|
|
914
|
-
}
|
|
915
|
-
|
|
916
|
-
type GetModuleInfo = (moduleId: string) => ModuleInfo | null;
|
|
917
|
-
|
|
918
|
-
interface CustomPluginOptions {
|
|
919
|
-
[plugin: string]: any;
|
|
920
|
-
}
|
|
921
|
-
|
|
922
|
-
interface PluginContext extends MinimalPluginContext {
|
|
923
|
-
addWatchFile: (id: string) => void;
|
|
924
|
-
cache: PluginCache;
|
|
925
|
-
emitFile: EmitFile;
|
|
926
|
-
error: (error: RollupError | string, pos?: number | { column: number; line: number }) => never;
|
|
927
|
-
getFileName: (fileReferenceId: string) => string;
|
|
928
|
-
getModuleIds: () => IterableIterator<string>;
|
|
929
|
-
getModuleInfo: GetModuleInfo;
|
|
930
|
-
getWatchFiles: () => string[];
|
|
931
|
-
load: (
|
|
932
|
-
options: { id: string; resolveDependencies?: boolean } & Partial<PartialNull<ModuleOptions>>
|
|
933
|
-
) => Promise<ModuleInfo>;
|
|
934
|
-
/** @deprecated Use `this.getModuleIds` instead */
|
|
935
|
-
moduleIds: IterableIterator<string>;
|
|
936
|
-
parse: (input: string, options?: any) => AcornNode;
|
|
937
|
-
resolve: (
|
|
938
|
-
source: string,
|
|
939
|
-
importer?: string,
|
|
940
|
-
options?: {
|
|
941
|
-
assertions?: Record<string, string>;
|
|
942
|
-
custom?: CustomPluginOptions;
|
|
943
|
-
isEntry?: boolean;
|
|
944
|
-
skipSelf?: boolean;
|
|
945
|
-
}
|
|
946
|
-
) => Promise<ResolvedId | null>;
|
|
947
|
-
setAssetSource: (assetReferenceId: string, source: string | Uint8Array) => void;
|
|
948
|
-
warn: (warning: RollupWarning | string, pos?: number | { column: number; line: number }) => void;
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
interface PluginContextMeta {
|
|
952
|
-
rollupVersion: string;
|
|
953
|
-
watchMode: boolean;
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
interface ResolvedId extends ModuleOptions {
|
|
957
|
-
external: boolean | 'absolute';
|
|
958
|
-
id: string;
|
|
959
|
-
resolvedBy: string;
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
interface TransformPluginContext extends PluginContext {
|
|
963
|
-
getCombinedSourcemap: () => SourceMap;
|
|
964
|
-
}
|
|
965
|
-
|
|
966
|
-
type TransformResult = string | NullValue | Partial<SourceDescription>;
|
|
967
|
-
type PreserveEntrySignaturesOption = false | 'strict' | 'allow-extension' | 'exports-only';
|
|
968
|
-
|
|
969
|
-
interface AcornNode {
|
|
970
|
-
end: number;
|
|
971
|
-
start: number;
|
|
972
|
-
type: string;
|
|
973
|
-
}
|
|
974
|
-
|
|
975
792
|
// Type definitions for istanbul-lib-report 3.0
|
|
976
793
|
|
|
977
794
|
|
|
@@ -1069,7 +886,7 @@ declare type BirpcReturn<RemoteFunctions> = {
|
|
|
1069
886
|
interface RuntimeRPC {
|
|
1070
887
|
fetch: (id: string, environment: VitestEnvironment) => Promise<FetchResult>;
|
|
1071
888
|
resolveId: (id: string, importer: string | undefined, environment: VitestEnvironment) => Promise<ViteNodeResolveId | null>;
|
|
1072
|
-
getSourceMap: (id: string, force?: boolean) => Promise<RawSourceMap
|
|
889
|
+
getSourceMap: (id: string, force?: boolean) => Promise<RawSourceMap | undefined>;
|
|
1073
890
|
onFinished: (files: File[], errors?: unknown[]) => void;
|
|
1074
891
|
onWorkerExit: (error: unknown, code?: number) => void;
|
|
1075
892
|
onPathsCollected: (paths: string[]) => void;
|
|
@@ -1078,9 +895,14 @@ interface RuntimeRPC {
|
|
|
1078
895
|
onCollected: (files: File[]) => void;
|
|
1079
896
|
onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void;
|
|
1080
897
|
onTaskUpdate: (pack: TaskResultPack[]) => void;
|
|
898
|
+
onCancel(reason: CancelReason): void;
|
|
899
|
+
getCountOfFailedTests(): number;
|
|
1081
900
|
snapshotSaved: (snapshot: SnapshotResult) => void;
|
|
1082
901
|
resolveSnapshotPath: (testPath: string) => string;
|
|
1083
902
|
}
|
|
903
|
+
interface RunnerRPC {
|
|
904
|
+
onCancel: (reason: CancelReason) => void;
|
|
905
|
+
}
|
|
1084
906
|
interface ContextTestEnvironment {
|
|
1085
907
|
name: VitestEnvironment;
|
|
1086
908
|
options: EnvironmentOptions | null;
|
|
@@ -1107,6 +929,7 @@ interface WorkerGlobalState {
|
|
|
1107
929
|
current?: Test$2;
|
|
1108
930
|
filepath?: string;
|
|
1109
931
|
environmentTeardownRun?: boolean;
|
|
932
|
+
onCancel: Promise<CancelReason>;
|
|
1110
933
|
moduleCache: ModuleCacheMap;
|
|
1111
934
|
mockMap: MockMap;
|
|
1112
935
|
durations: {
|
|
@@ -1115,6 +938,7 @@ interface WorkerGlobalState {
|
|
|
1115
938
|
};
|
|
1116
939
|
}
|
|
1117
940
|
|
|
941
|
+
type TransformResult = string | Partial<TransformResult$1> | undefined | null | void;
|
|
1118
942
|
interface CoverageProvider {
|
|
1119
943
|
name: string;
|
|
1120
944
|
initialize(ctx: Vitest): Promise<void> | void;
|
|
@@ -1122,7 +946,7 @@ interface CoverageProvider {
|
|
|
1122
946
|
clean(clean?: boolean): void | Promise<void>;
|
|
1123
947
|
onAfterSuiteRun(meta: AfterSuiteRunMeta): void | Promise<void>;
|
|
1124
948
|
reportCoverage(reportContext?: ReportContext): void | Promise<void>;
|
|
1125
|
-
onFileTransform?(sourceCode: string, id: string, pluginCtx:
|
|
949
|
+
onFileTransform?(sourceCode: string, id: string, pluginCtx: any): TransformResult | Promise<TransformResult>;
|
|
1126
950
|
}
|
|
1127
951
|
interface ReportContext {
|
|
1128
952
|
/** Indicates whether all tests were run. False when only specific tests were run. */
|
|
@@ -1252,6 +1076,17 @@ interface BaseCoverageOptions {
|
|
|
1252
1076
|
* @default undefined
|
|
1253
1077
|
*/
|
|
1254
1078
|
statements?: number;
|
|
1079
|
+
/**
|
|
1080
|
+
* Watermarks for statements, lines, branches and functions.
|
|
1081
|
+
*
|
|
1082
|
+
* Default value is `[50,80]` for each property.
|
|
1083
|
+
*/
|
|
1084
|
+
watermarks?: {
|
|
1085
|
+
statements?: [number, number];
|
|
1086
|
+
functions?: [number, number];
|
|
1087
|
+
branches?: [number, number];
|
|
1088
|
+
lines?: [number, number];
|
|
1089
|
+
};
|
|
1255
1090
|
/**
|
|
1256
1091
|
* Update threshold values automatically when current coverage is higher than earlier thresholds
|
|
1257
1092
|
*
|
|
@@ -1266,17 +1101,6 @@ interface CoverageIstanbulOptions extends BaseCoverageOptions {
|
|
|
1266
1101
|
* @default []
|
|
1267
1102
|
*/
|
|
1268
1103
|
ignoreClassMethods?: string[];
|
|
1269
|
-
/**
|
|
1270
|
-
* Watermarks for statements, lines, branches and functions.
|
|
1271
|
-
*
|
|
1272
|
-
* Default value is `[50,80]` for each property.
|
|
1273
|
-
*/
|
|
1274
|
-
watermarks?: {
|
|
1275
|
-
statements?: [number, number];
|
|
1276
|
-
functions?: [number, number];
|
|
1277
|
-
branches?: [number, number];
|
|
1278
|
-
lines?: [number, number];
|
|
1279
|
-
};
|
|
1280
1104
|
}
|
|
1281
1105
|
interface CoverageC8Options extends BaseCoverageOptions {
|
|
1282
1106
|
/**
|
|
@@ -1591,6 +1415,7 @@ interface InlineConfig {
|
|
|
1591
1415
|
environmentOptions?: EnvironmentOptions;
|
|
1592
1416
|
/**
|
|
1593
1417
|
* Automatically assign environment based on globs. The first match will be used.
|
|
1418
|
+
* This has effect only when running tests inside Node.js.
|
|
1594
1419
|
*
|
|
1595
1420
|
* Format: [glob, environment-name]
|
|
1596
1421
|
*
|
|
@@ -1611,13 +1436,13 @@ interface InlineConfig {
|
|
|
1611
1436
|
*
|
|
1612
1437
|
* @default []
|
|
1613
1438
|
* @example [
|
|
1614
|
-
* // all tests in "
|
|
1615
|
-
* ['tests/
|
|
1439
|
+
* // all tests in "child_process" directory will run using "child_process" API
|
|
1440
|
+
* ['tests/child_process/**', 'child_process'],
|
|
1616
1441
|
* // all other tests will run based on "threads" option, if you didn't specify other globs
|
|
1617
1442
|
* // ...
|
|
1618
1443
|
* ]
|
|
1619
1444
|
*/
|
|
1620
|
-
poolMatchGlobs?: [string, VitestPool][];
|
|
1445
|
+
poolMatchGlobs?: [string, Omit<VitestPool, 'browser'>][];
|
|
1621
1446
|
/**
|
|
1622
1447
|
* Update snapshot
|
|
1623
1448
|
*
|
|
@@ -1696,6 +1521,12 @@ interface InlineConfig {
|
|
|
1696
1521
|
* @default false
|
|
1697
1522
|
*/
|
|
1698
1523
|
silent?: boolean;
|
|
1524
|
+
/**
|
|
1525
|
+
* Hide logs for skipped tests
|
|
1526
|
+
*
|
|
1527
|
+
* @default false
|
|
1528
|
+
*/
|
|
1529
|
+
hideSkippedTests?: boolean;
|
|
1699
1530
|
/**
|
|
1700
1531
|
* Path to setup files
|
|
1701
1532
|
*/
|
|
@@ -1918,6 +1749,10 @@ interface InlineConfig {
|
|
|
1918
1749
|
* https://github.com/chaijs/chai/blob/4.x.x/lib/chai/config.js
|
|
1919
1750
|
*/
|
|
1920
1751
|
chaiConfig?: ChaiConfig;
|
|
1752
|
+
/**
|
|
1753
|
+
* Stop test execution when given number of tests have failed.
|
|
1754
|
+
*/
|
|
1755
|
+
bail?: number;
|
|
1921
1756
|
}
|
|
1922
1757
|
interface TypecheckConfig {
|
|
1923
1758
|
/**
|
|
@@ -2035,18 +1870,35 @@ declare module 'vite' {
|
|
|
2035
1870
|
}
|
|
2036
1871
|
}
|
|
2037
1872
|
|
|
2038
|
-
type Promisify<O> = {
|
|
2039
|
-
[K in keyof O]: O[K] extends (...args: infer A) => infer R ? O extends R ? Promisify<O[K]> : (...args: A) => Promise<R> : O[K];
|
|
2040
|
-
};
|
|
2041
1873
|
declare module '@vitest/expect' {
|
|
2042
1874
|
interface MatcherState {
|
|
2043
1875
|
environment: VitestEnvironment;
|
|
2044
1876
|
snapshotState: SnapshotState;
|
|
2045
1877
|
}
|
|
1878
|
+
interface ExpectStatic {
|
|
1879
|
+
addSnapshotSerializer(plugin: Plugin): void;
|
|
1880
|
+
}
|
|
1881
|
+
interface Assertion<T> {
|
|
1882
|
+
matchSnapshot<U extends {
|
|
1883
|
+
[P in keyof T]: any;
|
|
1884
|
+
}>(snapshot: Partial<U>, message?: string): void;
|
|
1885
|
+
matchSnapshot(message?: string): void;
|
|
1886
|
+
toMatchSnapshot<U extends {
|
|
1887
|
+
[P in keyof T]: any;
|
|
1888
|
+
}>(snapshot: Partial<U>, message?: string): void;
|
|
1889
|
+
toMatchSnapshot(message?: string): void;
|
|
1890
|
+
toMatchInlineSnapshot<U extends {
|
|
1891
|
+
[P in keyof T]: any;
|
|
1892
|
+
}>(properties: Partial<U>, snapshot?: string, message?: string): void;
|
|
1893
|
+
toMatchInlineSnapshot(snapshot?: string, message?: string): void;
|
|
1894
|
+
toThrowErrorMatchingSnapshot(message?: string): void;
|
|
1895
|
+
toThrowErrorMatchingInlineSnapshot(snapshot?: string, message?: string): void;
|
|
1896
|
+
toMatchFileSnapshot(filepath: string, message?: string): Promise<void>;
|
|
1897
|
+
}
|
|
2046
1898
|
}
|
|
2047
1899
|
declare module '@vitest/runner' {
|
|
2048
1900
|
interface TestContext {
|
|
2049
|
-
expect:
|
|
1901
|
+
expect: ExpectStatic;
|
|
2050
1902
|
}
|
|
2051
1903
|
interface File {
|
|
2052
1904
|
prepareDuration?: number;
|
|
@@ -2059,102 +1911,6 @@ declare module '@vitest/runner' {
|
|
|
2059
1911
|
benchmark?: BenchmarkResult;
|
|
2060
1912
|
}
|
|
2061
1913
|
}
|
|
2062
|
-
declare global {
|
|
2063
|
-
namespace jest {
|
|
2064
|
-
interface Matchers<_R, _T = {}> {
|
|
2065
|
-
}
|
|
2066
|
-
}
|
|
2067
|
-
namespace Vi {
|
|
2068
|
-
interface ExpectStatic extends Chai.ExpectStatic, AsymmetricMatchersContaining {
|
|
2069
|
-
<T>(actual: T, message?: string): Vi.Assertion<T>;
|
|
2070
|
-
extend(expects: MatchersObject): void;
|
|
2071
|
-
assertions(expected: number): void;
|
|
2072
|
-
hasAssertions(): void;
|
|
2073
|
-
anything(): any;
|
|
2074
|
-
any(constructor: unknown): any;
|
|
2075
|
-
addSnapshotSerializer(plugin: Plugin): void;
|
|
2076
|
-
getState(): MatcherState;
|
|
2077
|
-
setState(state: Partial<MatcherState>): void;
|
|
2078
|
-
not: AsymmetricMatchersContaining;
|
|
2079
|
-
}
|
|
2080
|
-
interface AsymmetricMatchersContaining {
|
|
2081
|
-
stringContaining(expected: string): any;
|
|
2082
|
-
objectContaining<T = any>(expected: T): any;
|
|
2083
|
-
arrayContaining<T = unknown>(expected: Array<T>): any;
|
|
2084
|
-
stringMatching(expected: string | RegExp): any;
|
|
2085
|
-
}
|
|
2086
|
-
interface JestAssertion<T = any> extends jest.Matchers<void, T> {
|
|
2087
|
-
matchSnapshot<U extends {
|
|
2088
|
-
[P in keyof T]: any;
|
|
2089
|
-
}>(snapshot: Partial<U>, message?: string): void;
|
|
2090
|
-
matchSnapshot(message?: string): void;
|
|
2091
|
-
toMatchSnapshot<U extends {
|
|
2092
|
-
[P in keyof T]: any;
|
|
2093
|
-
}>(snapshot: Partial<U>, message?: string): void;
|
|
2094
|
-
toMatchSnapshot(message?: string): void;
|
|
2095
|
-
toMatchInlineSnapshot<U extends {
|
|
2096
|
-
[P in keyof T]: any;
|
|
2097
|
-
}>(properties: Partial<U>, snapshot?: string, message?: string): void;
|
|
2098
|
-
toMatchInlineSnapshot(snapshot?: string, message?: string): void;
|
|
2099
|
-
toMatchFileSnapshot(filepath: string, message?: string): Promise<void>;
|
|
2100
|
-
toThrowErrorMatchingSnapshot(message?: string): void;
|
|
2101
|
-
toThrowErrorMatchingInlineSnapshot(snapshot?: string, message?: string): void;
|
|
2102
|
-
toEqual<E>(expected: E): void;
|
|
2103
|
-
toStrictEqual<E>(expected: E): void;
|
|
2104
|
-
toBe<E>(expected: E): void;
|
|
2105
|
-
toMatch(expected: string | RegExp): void;
|
|
2106
|
-
toMatchObject<E extends {} | any[]>(expected: E): void;
|
|
2107
|
-
toContain<E>(item: E): void;
|
|
2108
|
-
toContainEqual<E>(item: E): void;
|
|
2109
|
-
toBeTruthy(): void;
|
|
2110
|
-
toBeFalsy(): void;
|
|
2111
|
-
toBeGreaterThan(num: number | bigint): void;
|
|
2112
|
-
toBeGreaterThanOrEqual(num: number | bigint): void;
|
|
2113
|
-
toBeLessThan(num: number | bigint): void;
|
|
2114
|
-
toBeLessThanOrEqual(num: number | bigint): void;
|
|
2115
|
-
toBeNaN(): void;
|
|
2116
|
-
toBeUndefined(): void;
|
|
2117
|
-
toBeNull(): void;
|
|
2118
|
-
toBeDefined(): void;
|
|
2119
|
-
toBeTypeOf(expected: 'bigint' | 'boolean' | 'function' | 'number' | 'object' | 'string' | 'symbol' | 'undefined'): void;
|
|
2120
|
-
toBeInstanceOf<E>(expected: E): void;
|
|
2121
|
-
toBeCalledTimes(times: number): void;
|
|
2122
|
-
toHaveLength(length: number): void;
|
|
2123
|
-
toHaveProperty<E>(property: string | (string | number)[], value?: E): void;
|
|
2124
|
-
toBeCloseTo(number: number, numDigits?: number): void;
|
|
2125
|
-
toHaveBeenCalledTimes(times: number): void;
|
|
2126
|
-
toHaveBeenCalledOnce(): void;
|
|
2127
|
-
toHaveBeenCalled(): void;
|
|
2128
|
-
toBeCalled(): void;
|
|
2129
|
-
toHaveBeenCalledWith<E extends any[]>(...args: E): void;
|
|
2130
|
-
toBeCalledWith<E extends any[]>(...args: E): void;
|
|
2131
|
-
toHaveBeenNthCalledWith<E extends any[]>(n: number, ...args: E): void;
|
|
2132
|
-
nthCalledWith<E extends any[]>(nthCall: number, ...args: E): void;
|
|
2133
|
-
toHaveBeenLastCalledWith<E extends any[]>(...args: E): void;
|
|
2134
|
-
lastCalledWith<E extends any[]>(...args: E): void;
|
|
2135
|
-
toThrow(expected?: string | Constructable | RegExp | Error): void;
|
|
2136
|
-
toThrowError(expected?: string | Constructable | RegExp | Error): void;
|
|
2137
|
-
toReturn(): void;
|
|
2138
|
-
toHaveReturned(): void;
|
|
2139
|
-
toReturnTimes(times: number): void;
|
|
2140
|
-
toHaveReturnedTimes(times: number): void;
|
|
2141
|
-
toReturnWith<E>(value: E): void;
|
|
2142
|
-
toHaveReturnedWith<E>(value: E): void;
|
|
2143
|
-
toHaveLastReturnedWith<E>(value: E): void;
|
|
2144
|
-
lastReturnedWith<E>(value: E): void;
|
|
2145
|
-
toHaveNthReturnedWith<E>(nthCall: number, value: E): void;
|
|
2146
|
-
nthReturnedWith<E>(nthCall: number, value: E): void;
|
|
2147
|
-
toSatisfy<E>(matcher: (value: E) => boolean, message?: string): void;
|
|
2148
|
-
}
|
|
2149
|
-
type VitestAssertion<A, T> = {
|
|
2150
|
-
[K in keyof A]: A[K] extends Chai.Assertion ? Assertion<T> : A[K] extends (...args: any[]) => any ? A[K] : VitestAssertion<A[K], T>;
|
|
2151
|
-
} & ((type: string, message?: string) => Assertion);
|
|
2152
|
-
interface Assertion<T = any> extends VitestAssertion<Chai.Assertion, T>, JestAssertion<T> {
|
|
2153
|
-
resolves: Promisify<Assertion<T>>;
|
|
2154
|
-
rejects: Promisify<Assertion<T>>;
|
|
2155
|
-
}
|
|
2156
|
-
}
|
|
2157
|
-
}
|
|
2158
1914
|
|
|
2159
1915
|
type RawErrsMap = Map<string, TscErrorInfo[]>;
|
|
2160
1916
|
interface TscErrorInfo {
|
|
@@ -2182,4 +1938,4 @@ type Context = RootAndTarget & {
|
|
|
2182
1938
|
lastActivePath?: string;
|
|
2183
1939
|
};
|
|
2184
1940
|
|
|
2185
|
-
export {
|
|
1941
|
+
export { CoverageOptions as $, AfterSuiteRunMeta as A, BenchmarkAPI as B, ChaiConfig as C, Arrayable as D, EnvironmentOptions as E, FakeTimerInstallOpts as F, ArgumentsType$1 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, ProjectConfig as P, Environment as Q, RuntimeConfig as R, OnServerRestartHandler as S, TscErrorInfo as T, UserConsoleLog as U, VitestEnvironment as V, WorkerContext as W, CoverageProvider as X, ReportContext as Y, CoverageProviderModule as Z, CoverageReporter as _, ResolvedConfig as a, ResolvedCoverageOptions as a0, BaseCoverageOptions as a1, CoverageIstanbulOptions as a2, CoverageC8Options as a3, CustomProviderOptions as a4, BenchmarkUserOptions as a5, Benchmark as a6, BenchmarkResult as a7, BenchFunction as a8, MockFactory as a9, MockMap as aa, TestSequencer as ab, WorkspaceSpec as ac, WorkspaceProject as ad, startVitest as ae, TestSequencerConstructor as af, HtmlOptions as ag, FileOptions as ah, CloverOptions as ai, CoberturaOptions as aj, HtmlSpaOptions as ak, LcovOptions as al, LcovOnlyOptions as am, TeamcityOptions as an, TextOptions as ao, ProjectOptions as ap, ModuleGraphData as b, Reporter as c, createExpect as d, RawErrsMap as e, CollectLineNumbers as f, globalExpect as g, CollectLines as h, RootAndTarget as i, Context as j, BuiltinEnvironment as k, VitestPool as l, CSSModuleScopeStrategy as m, ApiConfig as n, VitestRunMode as o, TypecheckConfig as p, UserConfig as q, RuntimeRPC as r, setupChaiConfig as s, RunnerRPC as t, ContextTestEnvironment as u, ContextRPC as v, Vitest as w, ResolveIdFunction as x, WorkerGlobalState as y, Awaitable as z };
|