vitest 0.30.1 → 0.31.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.
- package/LICENSE.md +1 -264
- package/dist/browser.d.ts +3 -4
- package/dist/browser.js +2 -2
- package/dist/child.js +12 -4
- package/dist/{chunk-api-setup.c93e5069.js → chunk-api-setup.86042fed.js} +9 -2
- package/dist/{chunk-install-pkg.ee5cc9a8.js → chunk-install-pkg.d1609923.js} +4 -5
- package/dist/{chunk-integrations-globals.d419838f.js → chunk-integrations-globals.88c8a0cf.js} +2 -2
- package/dist/cli.js +23 -8
- package/dist/config.cjs +1 -0
- package/dist/config.d.ts +11 -14
- package/dist/config.js +1 -0
- package/dist/coverage.d.ts +5 -5
- package/dist/coverage.js +6 -6
- package/dist/entry.js +21 -5
- package/dist/environments.d.ts +3 -4
- package/dist/index.d.ts +13 -5
- package/dist/index.js +3 -3
- package/dist/loader.js +1 -0
- package/dist/node.d.ts +4 -5
- package/dist/node.js +6 -7
- package/dist/runners.d.ts +7 -5
- package/dist/runners.js +11 -1
- package/dist/{types-e3c9754d.d.ts → types-ad1c3f45.d.ts} +94 -334
- package/dist/{vendor-cli-api.70680cd5.js → vendor-cli-api.d608f86b.js} +2092 -2340
- package/dist/{vendor-coverage.a585b712.js → vendor-coverage.c8fd34c3.js} +2 -0
- package/dist/{vendor-execute.70609f6f.js → vendor-execute.3e144152.js} +2 -2
- package/dist/{vendor-index.7dcbfa46.js → vendor-index.3982ff76.js} +33 -13
- 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 +12 -4
- package/package.json +20 -19
- 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
|
-
declare class VitestServer extends ViteNodeServer {
|
|
248
|
-
private _vitestPath?;
|
|
249
|
-
private getVitestPath;
|
|
250
|
-
protected processTransformResult(id: string, result: TransformResult$1): Promise<TransformResult$1>;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
246
|
interface InitializeServerOptions {
|
|
254
|
-
server?:
|
|
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,7 +266,9 @@ 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[]>;
|
|
276
|
-
|
|
269
|
+
isTargetFile(id: string, source?: string): Promise<boolean>;
|
|
270
|
+
isInSourceTestFile(code: string): boolean;
|
|
271
|
+
filterFiles(testFiles: string[], filters: string[] | undefined, dir: string): string[];
|
|
277
272
|
initBrowserServer(options: UserConfig): Promise<void>;
|
|
278
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>;
|
|
@@ -292,11 +287,12 @@ interface BrowserProvider {
|
|
|
292
287
|
getSupportedBrowsers(): readonly string[];
|
|
293
288
|
initialize(ctx: WorkspaceProject, options: BrowserProviderOptions): Awaitable$1<void>;
|
|
294
289
|
openPage(url: string): Awaitable$1<void>;
|
|
290
|
+
catchError(cb: (error: Error) => Awaitable$1<void>): () => Awaitable$1<void>;
|
|
295
291
|
close(): Awaitable$1<void>;
|
|
296
292
|
}
|
|
297
293
|
interface BrowserConfigOptions {
|
|
298
294
|
/**
|
|
299
|
-
* if running tests in the
|
|
295
|
+
* if running tests in the browser should be the default
|
|
300
296
|
*
|
|
301
297
|
* @default false
|
|
302
298
|
*/
|
|
@@ -323,6 +319,14 @@ interface BrowserConfigOptions {
|
|
|
323
319
|
* The default port is 63315.
|
|
324
320
|
*/
|
|
325
321
|
api?: ApiConfig | number;
|
|
322
|
+
/**
|
|
323
|
+
* Update ESM imports so they can be spied/stubbed with vi.spyOn.
|
|
324
|
+
* Enabled by default when running in browser.
|
|
325
|
+
*
|
|
326
|
+
* @default true
|
|
327
|
+
* @experimental
|
|
328
|
+
*/
|
|
329
|
+
slowHijackESM?: boolean;
|
|
326
330
|
}
|
|
327
331
|
interface ResolvedBrowserOptions extends BrowserConfigOptions {
|
|
328
332
|
enabled: boolean;
|
|
@@ -368,6 +372,8 @@ declare class StateManager {
|
|
|
368
372
|
updateId(task: Task): void;
|
|
369
373
|
updateTasks(packs: TaskResultPack[]): void;
|
|
370
374
|
updateUserLog(log: UserConsoleLog): void;
|
|
375
|
+
getCountOfFailedTests(): number;
|
|
376
|
+
cancelFiles(files: string[], root: string): void;
|
|
371
377
|
}
|
|
372
378
|
|
|
373
379
|
declare class Logger {
|
|
@@ -428,7 +434,7 @@ interface CliOptions extends UserConfig {
|
|
|
428
434
|
*
|
|
429
435
|
* Returns a Vitest instance if initialized successfully.
|
|
430
436
|
*/
|
|
431
|
-
declare function startVitest(mode: VitestRunMode, cliFilters
|
|
437
|
+
declare function startVitest(mode: VitestRunMode, cliFilters?: string[], options?: CliOptions, viteOverrides?: UserConfig$1): Promise<Vitest | undefined>;
|
|
432
438
|
|
|
433
439
|
type FileStatsCache = Pick<Stats, 'size'>;
|
|
434
440
|
declare class FilesStatsCache {
|
|
@@ -466,12 +472,13 @@ declare class Vitest {
|
|
|
466
472
|
browserProvider: BrowserProvider | undefined;
|
|
467
473
|
logger: Logger;
|
|
468
474
|
pool: ProcessPool | undefined;
|
|
469
|
-
vitenode:
|
|
475
|
+
vitenode: ViteNodeServer;
|
|
470
476
|
invalidates: Set<string>;
|
|
471
477
|
changedTests: Set<string>;
|
|
472
478
|
filenamePattern?: string;
|
|
473
479
|
runningPromise?: Promise<void>;
|
|
474
480
|
closingPromise?: Promise<void>;
|
|
481
|
+
isCancelling: boolean;
|
|
475
482
|
isFirstRun: boolean;
|
|
476
483
|
restartsCount: number;
|
|
477
484
|
runner: ViteNodeRunner;
|
|
@@ -481,9 +488,10 @@ declare class Vitest {
|
|
|
481
488
|
constructor(mode: VitestRunMode);
|
|
482
489
|
private _onRestartListeners;
|
|
483
490
|
private _onSetServer;
|
|
491
|
+
private _onCancelListeners;
|
|
484
492
|
setServer(options: UserConfig, server: ViteDevServer, cliOptions: UserConfig): Promise<void>;
|
|
485
493
|
private createCoreWorkspace;
|
|
486
|
-
getCoreWorkspaceProject(): WorkspaceProject;
|
|
494
|
+
getCoreWorkspaceProject(): WorkspaceProject | null;
|
|
487
495
|
private resolveWorkspace;
|
|
488
496
|
private initCoverageProvider;
|
|
489
497
|
private initBrowserProviders;
|
|
@@ -493,6 +501,7 @@ declare class Vitest {
|
|
|
493
501
|
filterTestsBySource(specs: WorkspaceSpec[]): Promise<WorkspaceSpec[]>;
|
|
494
502
|
getProjectsByTestFile(file: string): WorkspaceSpec[];
|
|
495
503
|
runFiles(paths: WorkspaceSpec[]): Promise<void>;
|
|
504
|
+
cancelCurrentRun(reason: CancelReason): Promise<void>;
|
|
496
505
|
rerunFiles(files?: string[], trigger?: string): Promise<void>;
|
|
497
506
|
changeNamePattern(pattern: string, files?: string[], trigger?: string): Promise<void>;
|
|
498
507
|
changeFilenamePattern(pattern: string): Promise<void>;
|
|
@@ -515,11 +524,10 @@ declare class Vitest {
|
|
|
515
524
|
exit(force?: boolean): Promise<void>;
|
|
516
525
|
report<T extends keyof Reporter>(name: T, ...args: ArgumentsType$1<Reporter[T]>): Promise<void>;
|
|
517
526
|
globTestFiles(filters?: string[]): Promise<WorkspaceSpec[]>;
|
|
518
|
-
private isTargetFile;
|
|
519
527
|
shouldKeepServer(): boolean;
|
|
520
|
-
isInSourceTestFile(code: string): boolean;
|
|
521
528
|
onServerRestart(fn: OnServerRestartHandler): void;
|
|
522
529
|
onAfterSetServer(fn: OnServerRestartHandler): void;
|
|
530
|
+
onCancel(fn: (reason: CancelReason) => void): void;
|
|
523
531
|
}
|
|
524
532
|
|
|
525
533
|
type MockFactoryWithHelper = (importOriginal: <T = unknown>() => Promise<T>) => any;
|
|
@@ -699,6 +707,7 @@ declare class JUnitReporter implements Reporter {
|
|
|
699
707
|
private baseLog;
|
|
700
708
|
private logger;
|
|
701
709
|
private _timeStart;
|
|
710
|
+
private fileFd?;
|
|
702
711
|
onInit(ctx: Vitest): Promise<void>;
|
|
703
712
|
writeElement(name: string, attrs: Record<string, any>, children: () => Promise<void>): Promise<void>;
|
|
704
713
|
writeErrorDetails(error: ErrorWithDiff): Promise<void>;
|
|
@@ -776,202 +785,12 @@ declare const ReportersMap: {
|
|
|
776
785
|
};
|
|
777
786
|
type BuiltinReporters = keyof typeof ReportersMap;
|
|
778
787
|
|
|
779
|
-
declare function createExpect(test?: Test$2):
|
|
780
|
-
declare const globalExpect:
|
|
788
|
+
declare function createExpect(test?: Test$2): ExpectStatic;
|
|
789
|
+
declare const globalExpect: ExpectStatic;
|
|
781
790
|
|
|
782
791
|
declare function setupChaiConfig(config: ChaiConfig): void;
|
|
783
792
|
type ChaiConfig = Omit<Partial<typeof chai.config>, 'useProxy' | 'proxyExcludedKeys'>;
|
|
784
793
|
|
|
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
794
|
// Type definitions for istanbul-lib-report 3.0
|
|
976
795
|
|
|
977
796
|
|
|
@@ -1053,23 +872,25 @@ interface LinkMapper {
|
|
|
1053
872
|
assetPath(node: Node, name: string): string;
|
|
1054
873
|
}
|
|
1055
874
|
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
875
|
+
type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
|
|
876
|
+
type ReturnType$1<T> = T extends (...args: any) => infer R ? R : never;
|
|
877
|
+
type PromisifyFn<T> = ReturnType$1<T> extends Promise<any> ? T : (...args: ArgumentsType<T>) => Promise<Awaited<ReturnType$1<T>>>;
|
|
878
|
+
type BirpcFn<T> = PromisifyFn<T> & {
|
|
1060
879
|
/**
|
|
1061
880
|
* Send event without asking for response
|
|
1062
881
|
*/
|
|
1063
882
|
asEvent(...args: ArgumentsType<T>): void;
|
|
1064
883
|
};
|
|
1065
|
-
|
|
884
|
+
type BirpcReturn<RemoteFunctions, LocalFunctions = {}> = {
|
|
1066
885
|
[K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]>;
|
|
886
|
+
} & {
|
|
887
|
+
$functions: LocalFunctions;
|
|
1067
888
|
};
|
|
1068
889
|
|
|
1069
890
|
interface RuntimeRPC {
|
|
1070
891
|
fetch: (id: string, environment: VitestEnvironment) => Promise<FetchResult>;
|
|
1071
892
|
resolveId: (id: string, importer: string | undefined, environment: VitestEnvironment) => Promise<ViteNodeResolveId | null>;
|
|
1072
|
-
getSourceMap: (id: string, force?: boolean) => Promise<RawSourceMap
|
|
893
|
+
getSourceMap: (id: string, force?: boolean) => Promise<RawSourceMap | undefined>;
|
|
1073
894
|
onFinished: (files: File[], errors?: unknown[]) => void;
|
|
1074
895
|
onWorkerExit: (error: unknown, code?: number) => void;
|
|
1075
896
|
onPathsCollected: (paths: string[]) => void;
|
|
@@ -1078,9 +899,14 @@ interface RuntimeRPC {
|
|
|
1078
899
|
onCollected: (files: File[]) => void;
|
|
1079
900
|
onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void;
|
|
1080
901
|
onTaskUpdate: (pack: TaskResultPack[]) => void;
|
|
902
|
+
onCancel(reason: CancelReason): void;
|
|
903
|
+
getCountOfFailedTests(): number;
|
|
1081
904
|
snapshotSaved: (snapshot: SnapshotResult) => void;
|
|
1082
905
|
resolveSnapshotPath: (testPath: string) => string;
|
|
1083
906
|
}
|
|
907
|
+
interface RunnerRPC {
|
|
908
|
+
onCancel: (reason: CancelReason) => void;
|
|
909
|
+
}
|
|
1084
910
|
interface ContextTestEnvironment {
|
|
1085
911
|
name: VitestEnvironment;
|
|
1086
912
|
options: EnvironmentOptions | null;
|
|
@@ -1107,6 +933,7 @@ interface WorkerGlobalState {
|
|
|
1107
933
|
current?: Test$2;
|
|
1108
934
|
filepath?: string;
|
|
1109
935
|
environmentTeardownRun?: boolean;
|
|
936
|
+
onCancel: Promise<CancelReason>;
|
|
1110
937
|
moduleCache: ModuleCacheMap;
|
|
1111
938
|
mockMap: MockMap;
|
|
1112
939
|
durations: {
|
|
@@ -1115,6 +942,7 @@ interface WorkerGlobalState {
|
|
|
1115
942
|
};
|
|
1116
943
|
}
|
|
1117
944
|
|
|
945
|
+
type TransformResult = string | Partial<TransformResult$1> | undefined | null | void;
|
|
1118
946
|
interface CoverageProvider {
|
|
1119
947
|
name: string;
|
|
1120
948
|
initialize(ctx: Vitest): Promise<void> | void;
|
|
@@ -1122,7 +950,7 @@ interface CoverageProvider {
|
|
|
1122
950
|
clean(clean?: boolean): void | Promise<void>;
|
|
1123
951
|
onAfterSuiteRun(meta: AfterSuiteRunMeta): void | Promise<void>;
|
|
1124
952
|
reportCoverage(reportContext?: ReportContext): void | Promise<void>;
|
|
1125
|
-
onFileTransform?(sourceCode: string, id: string, pluginCtx:
|
|
953
|
+
onFileTransform?(sourceCode: string, id: string, pluginCtx: any): TransformResult | Promise<TransformResult>;
|
|
1126
954
|
}
|
|
1127
955
|
interface ReportContext {
|
|
1128
956
|
/** Indicates whether all tests were run. False when only specific tests were run. */
|
|
@@ -1252,6 +1080,17 @@ interface BaseCoverageOptions {
|
|
|
1252
1080
|
* @default undefined
|
|
1253
1081
|
*/
|
|
1254
1082
|
statements?: number;
|
|
1083
|
+
/**
|
|
1084
|
+
* Watermarks for statements, lines, branches and functions.
|
|
1085
|
+
*
|
|
1086
|
+
* Default value is `[50,80]` for each property.
|
|
1087
|
+
*/
|
|
1088
|
+
watermarks?: {
|
|
1089
|
+
statements?: [number, number];
|
|
1090
|
+
functions?: [number, number];
|
|
1091
|
+
branches?: [number, number];
|
|
1092
|
+
lines?: [number, number];
|
|
1093
|
+
};
|
|
1255
1094
|
/**
|
|
1256
1095
|
* Update threshold values automatically when current coverage is higher than earlier thresholds
|
|
1257
1096
|
*
|
|
@@ -1266,17 +1105,6 @@ interface CoverageIstanbulOptions extends BaseCoverageOptions {
|
|
|
1266
1105
|
* @default []
|
|
1267
1106
|
*/
|
|
1268
1107
|
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
1108
|
}
|
|
1281
1109
|
interface CoverageC8Options extends BaseCoverageOptions {
|
|
1282
1110
|
/**
|
|
@@ -1591,6 +1419,7 @@ interface InlineConfig {
|
|
|
1591
1419
|
environmentOptions?: EnvironmentOptions;
|
|
1592
1420
|
/**
|
|
1593
1421
|
* Automatically assign environment based on globs. The first match will be used.
|
|
1422
|
+
* This has effect only when running tests inside Node.js.
|
|
1594
1423
|
*
|
|
1595
1424
|
* Format: [glob, environment-name]
|
|
1596
1425
|
*
|
|
@@ -1611,13 +1440,13 @@ interface InlineConfig {
|
|
|
1611
1440
|
*
|
|
1612
1441
|
* @default []
|
|
1613
1442
|
* @example [
|
|
1614
|
-
* // all tests in "
|
|
1615
|
-
* ['tests/
|
|
1443
|
+
* // all tests in "child_process" directory will run using "child_process" API
|
|
1444
|
+
* ['tests/child_process/**', 'child_process'],
|
|
1616
1445
|
* // all other tests will run based on "threads" option, if you didn't specify other globs
|
|
1617
1446
|
* // ...
|
|
1618
1447
|
* ]
|
|
1619
1448
|
*/
|
|
1620
|
-
poolMatchGlobs?: [string, VitestPool][];
|
|
1449
|
+
poolMatchGlobs?: [string, Omit<VitestPool, 'browser'>][];
|
|
1621
1450
|
/**
|
|
1622
1451
|
* Update snapshot
|
|
1623
1452
|
*
|
|
@@ -1696,6 +1525,12 @@ interface InlineConfig {
|
|
|
1696
1525
|
* @default false
|
|
1697
1526
|
*/
|
|
1698
1527
|
silent?: boolean;
|
|
1528
|
+
/**
|
|
1529
|
+
* Hide logs for skipped tests
|
|
1530
|
+
*
|
|
1531
|
+
* @default false
|
|
1532
|
+
*/
|
|
1533
|
+
hideSkippedTests?: boolean;
|
|
1699
1534
|
/**
|
|
1700
1535
|
* Path to setup files
|
|
1701
1536
|
*/
|
|
@@ -1918,6 +1753,10 @@ interface InlineConfig {
|
|
|
1918
1753
|
* https://github.com/chaijs/chai/blob/4.x.x/lib/chai/config.js
|
|
1919
1754
|
*/
|
|
1920
1755
|
chaiConfig?: ChaiConfig;
|
|
1756
|
+
/**
|
|
1757
|
+
* Stop test execution when given number of tests have failed.
|
|
1758
|
+
*/
|
|
1759
|
+
bail?: number;
|
|
1921
1760
|
}
|
|
1922
1761
|
interface TypecheckConfig {
|
|
1923
1762
|
/**
|
|
@@ -2035,18 +1874,35 @@ declare module 'vite' {
|
|
|
2035
1874
|
}
|
|
2036
1875
|
}
|
|
2037
1876
|
|
|
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
1877
|
declare module '@vitest/expect' {
|
|
2042
1878
|
interface MatcherState {
|
|
2043
1879
|
environment: VitestEnvironment;
|
|
2044
1880
|
snapshotState: SnapshotState;
|
|
2045
1881
|
}
|
|
1882
|
+
interface ExpectStatic {
|
|
1883
|
+
addSnapshotSerializer(plugin: Plugin): void;
|
|
1884
|
+
}
|
|
1885
|
+
interface Assertion<T> {
|
|
1886
|
+
matchSnapshot<U extends {
|
|
1887
|
+
[P in keyof T]: any;
|
|
1888
|
+
}>(snapshot: Partial<U>, message?: string): void;
|
|
1889
|
+
matchSnapshot(message?: string): void;
|
|
1890
|
+
toMatchSnapshot<U extends {
|
|
1891
|
+
[P in keyof T]: any;
|
|
1892
|
+
}>(snapshot: Partial<U>, message?: string): void;
|
|
1893
|
+
toMatchSnapshot(message?: string): void;
|
|
1894
|
+
toMatchInlineSnapshot<U extends {
|
|
1895
|
+
[P in keyof T]: any;
|
|
1896
|
+
}>(properties: Partial<U>, snapshot?: string, message?: string): void;
|
|
1897
|
+
toMatchInlineSnapshot(snapshot?: string, message?: string): void;
|
|
1898
|
+
toThrowErrorMatchingSnapshot(message?: string): void;
|
|
1899
|
+
toThrowErrorMatchingInlineSnapshot(snapshot?: string, message?: string): void;
|
|
1900
|
+
toMatchFileSnapshot(filepath: string, message?: string): Promise<void>;
|
|
1901
|
+
}
|
|
2046
1902
|
}
|
|
2047
1903
|
declare module '@vitest/runner' {
|
|
2048
1904
|
interface TestContext {
|
|
2049
|
-
expect:
|
|
1905
|
+
expect: ExpectStatic;
|
|
2050
1906
|
}
|
|
2051
1907
|
interface File {
|
|
2052
1908
|
prepareDuration?: number;
|
|
@@ -2059,102 +1915,6 @@ declare module '@vitest/runner' {
|
|
|
2059
1915
|
benchmark?: BenchmarkResult;
|
|
2060
1916
|
}
|
|
2061
1917
|
}
|
|
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
1918
|
|
|
2159
1919
|
type RawErrsMap = Map<string, TscErrorInfo[]>;
|
|
2160
1920
|
interface TscErrorInfo {
|
|
@@ -2182,4 +1942,4 @@ type Context = RootAndTarget & {
|
|
|
2182
1942
|
lastActivePath?: string;
|
|
2183
1943
|
};
|
|
2184
1944
|
|
|
2185
|
-
export {
|
|
1945
|
+
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 };
|