vitest 2.0.0-beta.1 → 2.0.0-beta.10
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 -1
- package/dist/browser.d.ts +22 -2
- package/dist/browser.js +3 -1
- package/dist/chunks/{integrations-globals.B5Jl0grA.js → integrations-globals.C6Ah-pUW.js} +3 -3
- package/dist/chunks/{runtime-console.CUES-L8X.js → runtime-console.DiVMr5d4.js} +54 -24
- package/dist/chunks/{runtime-runBaseTests._dXkRAZc.js → runtime-runBaseTests.Cukyr5-I.js} +5 -5
- package/dist/cli.js +2 -2
- package/dist/config.cjs +3 -3
- package/dist/config.d.ts +2 -2
- package/dist/config.js +3 -3
- package/dist/coverage.d.ts +1 -1
- package/dist/coverage.js +33 -7
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +2 -2
- package/dist/execute.js +1 -1
- package/dist/index.d.ts +11 -47
- package/dist/index.js +3 -3
- package/dist/node.d.ts +7 -7
- package/dist/node.js +12 -10
- package/dist/{reporters-MGvT5U9f.d.ts → reporters-CYVC6LOl.d.ts} +424 -201
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +4 -4
- package/dist/runners.d.ts +4 -2
- package/dist/runners.js +9 -1
- package/dist/{suite-8WAe-urM.d.ts → suite-Dpu9EC_k.d.ts} +1 -1
- package/dist/suite.d.ts +2 -2
- package/dist/vendor/{base.VFkIJ66g.js → base.Dln9yllP.js} +2 -2
- package/dist/vendor/{cac.DzKZaJu2.js → cac.CtYFkoSJ.js} +65 -23
- package/dist/vendor/{cli-api.DTeni0Qq.js → cli-api.CUtJc4r3.js} +2425 -549
- package/dist/vendor/{constants.5SOfHUj0.js → constants.TCjCaw2D.js} +4 -3
- package/dist/vendor/{execute.CLLNVNnK.js → execute.BHj6OMh4.js} +3 -3
- package/dist/vendor/{index.BfoZyXD1.js → index.B5SKBLvV.js} +1 -1
- package/dist/vendor/{index.CRxYS9H3.js → index.BOMEjpjj.js} +271 -52
- package/dist/vendor/{index.DP-km6lF.js → index.CThipSqB.js} +2537 -2524
- package/dist/vendor/{index.CmILuxzC.js → index.D3hs2WiI.js} +1 -1
- package/dist/vendor/{index.DeR1hhfY.js → index.kpsSqFiz.js} +2 -1
- package/dist/vendor/{setup-common.XeoZAW8t.js → setup-common.DAu7t7mY.js} +1 -1
- package/dist/vendor/spy.Cf_4R5Oe.js +22 -0
- package/dist/vendor/{utils.D5gGkwyH.js → utils.YuQ3LT2a.js} +1 -1
- package/dist/vendor/{vi.ClD3hi7L.js → vi.hATFzZbX.js} +101 -46
- package/dist/vendor/{vm.Bi3bljci.js → vm.Ow-X2mkS.js} +2 -2
- package/dist/worker.js +1 -1
- package/dist/workers/forks.js +2 -2
- package/dist/workers/runVmTests.js +4 -4
- package/dist/workers/threads.js +2 -2
- package/dist/workers/vmForks.js +3 -3
- package/dist/workers/vmThreads.js +3 -3
- package/dist/workers.d.ts +1 -1
- package/dist/workers.js +5 -5
- package/package.json +20 -20
- package/suppress-warnings.cjs +2 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as vite from 'vite';
|
|
2
|
-
import {
|
|
2
|
+
import { TransformResult as TransformResult$1, ViteDevServer, UserConfig as UserConfig$1, ConfigEnv, ServerOptions, DepOptimizationConfig, AliasOptions } from 'vite';
|
|
3
3
|
import * as _vitest_runner from '@vitest/runner';
|
|
4
|
-
import { File, Test as Test$1, Suite, TaskResultPack, Task,
|
|
5
|
-
import { RawSourceMap,
|
|
6
|
-
import {
|
|
7
|
-
import { ExpectStatic } from '@vitest/expect';
|
|
4
|
+
import { File, Test as Test$1, Suite, TaskResultPack, CancelReason, Task, TaskMeta, Custom, SequenceHooks, SequenceSetupFiles } from '@vitest/runner';
|
|
5
|
+
import { RawSourceMap, ViteNodeResolveId, FetchResult, ModuleCacheMap, ViteNodeServerOptions } from 'vite-node';
|
|
6
|
+
import { SnapshotResult, SnapshotSummary, SnapshotStateOptions, SnapshotState } from '@vitest/snapshot';
|
|
7
|
+
import { PromisifyAssertion, Tester, ExpectStatic } from '@vitest/expect';
|
|
8
8
|
import { ChainableFunction } from '@vitest/runner/utils';
|
|
9
9
|
import { ParsedStack, Awaitable as Awaitable$1, Arrayable as Arrayable$1 } from '@vitest/utils';
|
|
10
10
|
import { TaskResult, Bench, Options as Options$1 } from 'tinybench';
|
|
@@ -647,8 +647,15 @@ interface BrowserProviderInitializationOptions {
|
|
|
647
647
|
}
|
|
648
648
|
interface BrowserProvider {
|
|
649
649
|
name: string;
|
|
650
|
+
/**
|
|
651
|
+
* @experimental opt-in into file parallelisation
|
|
652
|
+
*/
|
|
653
|
+
supportsParallelism: boolean;
|
|
650
654
|
getSupportedBrowsers: () => readonly string[];
|
|
651
|
-
|
|
655
|
+
beforeCommand?: (command: string, args: unknown[]) => Awaitable$1<void>;
|
|
656
|
+
afterCommand?: (command: string, args: unknown[]) => Awaitable$1<void>;
|
|
657
|
+
getCommandsContext: (contextId: string) => Record<string, unknown>;
|
|
658
|
+
openPage: (contextId: string, url: string) => Promise<void>;
|
|
652
659
|
close: () => Awaitable$1<void>;
|
|
653
660
|
initialize(ctx: WorkspaceProject, options: BrowserProviderInitializationOptions): Awaitable$1<void>;
|
|
654
661
|
}
|
|
@@ -668,9 +675,9 @@ interface BrowserConfigOptions {
|
|
|
668
675
|
/**
|
|
669
676
|
* Browser provider
|
|
670
677
|
*
|
|
671
|
-
* @default '
|
|
678
|
+
* @default 'preview'
|
|
672
679
|
*/
|
|
673
|
-
provider?: 'webdriverio' | 'playwright' | '
|
|
680
|
+
provider?: 'webdriverio' | 'playwright' | 'preview' | (string & {});
|
|
674
681
|
/**
|
|
675
682
|
* Options that are passed down to a browser provider.
|
|
676
683
|
* To support type hinting, add one of the types to your tsconfig.json "compilerOptions.types" field:
|
|
@@ -694,14 +701,6 @@ interface BrowserConfigOptions {
|
|
|
694
701
|
* The default port is 63315.
|
|
695
702
|
*/
|
|
696
703
|
api?: ApiConfig | number;
|
|
697
|
-
/**
|
|
698
|
-
* Update ESM imports so they can be spied/stubbed with vi.spyOn.
|
|
699
|
-
* Enabled by default when running in browser.
|
|
700
|
-
*
|
|
701
|
-
* @default false
|
|
702
|
-
* @experimental
|
|
703
|
-
*/
|
|
704
|
-
slowHijackESM?: boolean;
|
|
705
704
|
/**
|
|
706
705
|
* Isolate test environment after each test
|
|
707
706
|
*
|
|
@@ -709,11 +708,40 @@ interface BrowserConfigOptions {
|
|
|
709
708
|
*/
|
|
710
709
|
isolate?: boolean;
|
|
711
710
|
/**
|
|
712
|
-
* Run test files in parallel
|
|
711
|
+
* Run test files in parallel if provider supports this option
|
|
712
|
+
* This option only has effect in headless mode (enabled in CI by default)
|
|
713
713
|
*
|
|
714
|
-
* @default test.fileParallelism
|
|
714
|
+
* @default // Same as "test.fileParallelism"
|
|
715
715
|
*/
|
|
716
716
|
fileParallelism?: boolean;
|
|
717
|
+
/**
|
|
718
|
+
* Show Vitest UI
|
|
719
|
+
*
|
|
720
|
+
* @default !process.env.CI
|
|
721
|
+
*/
|
|
722
|
+
ui?: boolean;
|
|
723
|
+
/**
|
|
724
|
+
* Default viewport size
|
|
725
|
+
*/
|
|
726
|
+
viewport?: {
|
|
727
|
+
/**
|
|
728
|
+
* Width of the viewport
|
|
729
|
+
* @default 414
|
|
730
|
+
*/
|
|
731
|
+
width: number;
|
|
732
|
+
/**
|
|
733
|
+
* Height of the viewport
|
|
734
|
+
* @default 896
|
|
735
|
+
*/
|
|
736
|
+
height: number;
|
|
737
|
+
};
|
|
738
|
+
/**
|
|
739
|
+
* Directory where screenshots will be saved when page.screenshot() is called
|
|
740
|
+
* If not set, all screenshots are saved to __screenshots__ directory in the same folder as the test file.
|
|
741
|
+
* If this is set, it will be resolved relative to the project root.
|
|
742
|
+
* @default __screenshots__
|
|
743
|
+
*/
|
|
744
|
+
screenshotDirectory?: string;
|
|
717
745
|
/**
|
|
718
746
|
* Scripts injected into the tester iframe.
|
|
719
747
|
*/
|
|
@@ -721,7 +749,22 @@ interface BrowserConfigOptions {
|
|
|
721
749
|
/**
|
|
722
750
|
* Scripts injected into the main window.
|
|
723
751
|
*/
|
|
724
|
-
|
|
752
|
+
orchestratorScripts?: BrowserScript[];
|
|
753
|
+
/**
|
|
754
|
+
* Commands that will be executed on the server
|
|
755
|
+
* via the browser `import("@vitest/browser/context").commands` API.
|
|
756
|
+
* @see {@link https://vitest.dev/guide/browser#commands}
|
|
757
|
+
*/
|
|
758
|
+
commands?: Record<string, BrowserCommand<any>>;
|
|
759
|
+
}
|
|
760
|
+
interface BrowserCommandContext {
|
|
761
|
+
testPath: string | undefined;
|
|
762
|
+
provider: BrowserProvider;
|
|
763
|
+
project: WorkspaceProject;
|
|
764
|
+
contextId: string;
|
|
765
|
+
}
|
|
766
|
+
interface BrowserCommand<Payload extends unknown[]> {
|
|
767
|
+
(context: BrowserCommandContext, ...payload: Payload): Awaitable$1<any>;
|
|
725
768
|
}
|
|
726
769
|
interface BrowserScript {
|
|
727
770
|
/**
|
|
@@ -755,9 +798,160 @@ interface ResolvedBrowserOptions extends BrowserConfigOptions {
|
|
|
755
798
|
enabled: boolean;
|
|
756
799
|
headless: boolean;
|
|
757
800
|
isolate: boolean;
|
|
801
|
+
fileParallelism: boolean;
|
|
758
802
|
api: ApiConfig;
|
|
803
|
+
ui: boolean;
|
|
804
|
+
viewport: {
|
|
805
|
+
width: number;
|
|
806
|
+
height: number;
|
|
807
|
+
};
|
|
759
808
|
}
|
|
760
809
|
|
|
810
|
+
declare class VitestBrowserServerMocker {
|
|
811
|
+
#private;
|
|
812
|
+
mocks: Map<string, {
|
|
813
|
+
sessionId: string;
|
|
814
|
+
mock: string | null | undefined;
|
|
815
|
+
}>;
|
|
816
|
+
constructor(project: WorkspaceProject);
|
|
817
|
+
resolveMock(rawId: string, importer: string, hasFactory: boolean): Promise<{
|
|
818
|
+
type: "factory";
|
|
819
|
+
resolvedId: string;
|
|
820
|
+
mockPath?: undefined;
|
|
821
|
+
} | {
|
|
822
|
+
type: "redirect" | "automock";
|
|
823
|
+
mockPath: string | null;
|
|
824
|
+
resolvedId: string;
|
|
825
|
+
}>;
|
|
826
|
+
private resolveId;
|
|
827
|
+
resolveMockPath(mockPath: string, external: string | null): string | null;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
type ArgumentsType$1<T> = T extends (...args: infer A) => any ? A : never;
|
|
831
|
+
type ReturnType$1<T> = T extends (...args: any) => infer R ? R : never;
|
|
832
|
+
type PromisifyFn<T> = ReturnType$1<T> extends Promise<any> ? T : (...args: ArgumentsType$1<T>) => Promise<Awaited<ReturnType$1<T>>>;
|
|
833
|
+
type BirpcResolver = (name: string, resolved: (...args: unknown[]) => unknown) => ((...args: unknown[]) => unknown) | undefined;
|
|
834
|
+
interface ChannelOptions {
|
|
835
|
+
/**
|
|
836
|
+
* Function to post raw message
|
|
837
|
+
*/
|
|
838
|
+
post: (data: any, ...extras: any[]) => any | Promise<any>;
|
|
839
|
+
/**
|
|
840
|
+
* Listener to receive raw message
|
|
841
|
+
*/
|
|
842
|
+
on: (fn: (data: any, ...extras: any[]) => void) => any | Promise<any>;
|
|
843
|
+
/**
|
|
844
|
+
* Custom function to serialize data
|
|
845
|
+
*
|
|
846
|
+
* by default it passes the data as-is
|
|
847
|
+
*/
|
|
848
|
+
serialize?: (data: any) => any;
|
|
849
|
+
/**
|
|
850
|
+
* Custom function to deserialize data
|
|
851
|
+
*
|
|
852
|
+
* by default it passes the data as-is
|
|
853
|
+
*/
|
|
854
|
+
deserialize?: (data: any) => any;
|
|
855
|
+
}
|
|
856
|
+
interface EventOptions<Remote> {
|
|
857
|
+
/**
|
|
858
|
+
* Names of remote functions that do not need response.
|
|
859
|
+
*/
|
|
860
|
+
eventNames?: (keyof Remote)[];
|
|
861
|
+
/**
|
|
862
|
+
* Maximum timeout for waiting for response, in milliseconds.
|
|
863
|
+
*
|
|
864
|
+
* @default 60_000
|
|
865
|
+
*/
|
|
866
|
+
timeout?: number;
|
|
867
|
+
/**
|
|
868
|
+
* Custom resolver to resolve function to be called
|
|
869
|
+
*
|
|
870
|
+
* For advanced use cases only
|
|
871
|
+
*/
|
|
872
|
+
resolver?: BirpcResolver;
|
|
873
|
+
/**
|
|
874
|
+
* Custom error handler
|
|
875
|
+
*/
|
|
876
|
+
onError?: (error: Error, functionName: string, args: any[]) => boolean | void;
|
|
877
|
+
/**
|
|
878
|
+
* Custom error handler for timeouts
|
|
879
|
+
*/
|
|
880
|
+
onTimeoutError?: (functionName: string, args: any[]) => boolean | void;
|
|
881
|
+
}
|
|
882
|
+
type BirpcOptions<Remote> = EventOptions<Remote> & ChannelOptions;
|
|
883
|
+
type BirpcFn<T> = PromisifyFn<T> & {
|
|
884
|
+
/**
|
|
885
|
+
* Send event without asking for response
|
|
886
|
+
*/
|
|
887
|
+
asEvent: (...args: ArgumentsType$1<T>) => void;
|
|
888
|
+
};
|
|
889
|
+
type BirpcReturn<RemoteFunctions, LocalFunctions = Record<string, never>> = {
|
|
890
|
+
[K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]>;
|
|
891
|
+
} & {
|
|
892
|
+
$functions: LocalFunctions;
|
|
893
|
+
};
|
|
894
|
+
|
|
895
|
+
interface TransformResultWithSource extends TransformResult$1 {
|
|
896
|
+
source?: string;
|
|
897
|
+
}
|
|
898
|
+
interface WebSocketHandlers {
|
|
899
|
+
onCollected: (files?: File[]) => Promise<void>;
|
|
900
|
+
onTaskUpdate: (packs: TaskResultPack[]) => void;
|
|
901
|
+
getFiles: () => File[];
|
|
902
|
+
getTestFiles: () => Promise<[{
|
|
903
|
+
name: string;
|
|
904
|
+
root: string;
|
|
905
|
+
}, file: string][]>;
|
|
906
|
+
getPaths: () => string[];
|
|
907
|
+
getConfig: () => ResolvedConfig;
|
|
908
|
+
getModuleGraph: (projectName: string, id: string, browser?: boolean) => Promise<ModuleGraphData>;
|
|
909
|
+
getTransformResult: (projectName: string, id: string, browser?: boolean) => Promise<TransformResultWithSource | undefined>;
|
|
910
|
+
readTestFile: (id: string) => Promise<string | null>;
|
|
911
|
+
saveTestFile: (id: string, content: string) => Promise<void>;
|
|
912
|
+
rerun: (files: string[]) => Promise<void>;
|
|
913
|
+
updateSnapshot: (file?: File) => Promise<void>;
|
|
914
|
+
getUnhandledErrors: () => unknown[];
|
|
915
|
+
}
|
|
916
|
+
interface WebSocketBrowserHandlers {
|
|
917
|
+
resolveSnapshotPath: (testPath: string) => string;
|
|
918
|
+
resolveSnapshotRawPath: (testPath: string, rawPath: string) => string;
|
|
919
|
+
onUnhandledError: (error: unknown, type: string) => Promise<void>;
|
|
920
|
+
onCollected: (files?: File[]) => Promise<void>;
|
|
921
|
+
onTaskUpdate: (packs: TaskResultPack[]) => void;
|
|
922
|
+
onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void;
|
|
923
|
+
onCancel: (reason: CancelReason) => void;
|
|
924
|
+
getCountOfFailedTests: () => number;
|
|
925
|
+
readSnapshotFile: (id: string) => Promise<string | null>;
|
|
926
|
+
saveSnapshotFile: (id: string, content: string) => Promise<void>;
|
|
927
|
+
removeSnapshotFile: (id: string) => Promise<void>;
|
|
928
|
+
sendLog: (log: UserConsoleLog) => void;
|
|
929
|
+
finishBrowserTests: (contextId: string) => void;
|
|
930
|
+
snapshotSaved: (snapshot: SnapshotResult) => void;
|
|
931
|
+
debug: (...args: string[]) => void;
|
|
932
|
+
resolveId: (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
|
|
933
|
+
triggerCommand: <T>(contextId: string, command: string, testPath: string | undefined, payload: unknown[]) => Promise<T>;
|
|
934
|
+
resolveMock: (id: string, importer: string, hasFactory: boolean) => Promise<{
|
|
935
|
+
type: 'factory' | 'redirect' | 'automock';
|
|
936
|
+
mockPath?: string | null;
|
|
937
|
+
resolvedId: string;
|
|
938
|
+
}>;
|
|
939
|
+
automock: (id: string) => Promise<string>;
|
|
940
|
+
invalidate: (ids: string[]) => void;
|
|
941
|
+
getBrowserFileSourceMap: (id: string) => Promise<TransformResult$1['map'] | undefined>;
|
|
942
|
+
getProvidedContext: () => ProvidedContext;
|
|
943
|
+
}
|
|
944
|
+
interface WebSocketEvents extends Pick<Reporter, 'onCollected' | 'onFinished' | 'onTaskUpdate' | 'onUserConsoleLog' | 'onPathsCollected' | 'onSpecsCollected'> {
|
|
945
|
+
onFinishedReportCoverage: () => void;
|
|
946
|
+
}
|
|
947
|
+
interface WebSocketBrowserEvents {
|
|
948
|
+
onCancel: (reason: CancelReason) => void;
|
|
949
|
+
startMocking: (id: string) => Promise<string[]>;
|
|
950
|
+
createTesters: (files: string[]) => Promise<void>;
|
|
951
|
+
}
|
|
952
|
+
type WebSocketRPC = BirpcReturn<WebSocketEvents, WebSocketHandlers>;
|
|
953
|
+
type WebSocketBrowserRPC = BirpcReturn<WebSocketBrowserEvents, WebSocketBrowserHandlers>;
|
|
954
|
+
|
|
761
955
|
interface InitializeProjectOptions extends UserWorkspaceConfig {
|
|
762
956
|
workspaceConfigPath: string;
|
|
763
957
|
extends?: string;
|
|
@@ -775,11 +969,16 @@ declare class WorkspaceProject {
|
|
|
775
969
|
typechecker?: Typechecker;
|
|
776
970
|
closingPromise: Promise<unknown> | undefined;
|
|
777
971
|
browserProvider: BrowserProvider | undefined;
|
|
778
|
-
|
|
972
|
+
browserMocker: VitestBrowserServerMocker;
|
|
973
|
+
browserRpc: {
|
|
974
|
+
orchestrators: Map<string, WebSocketBrowserRPC>;
|
|
975
|
+
testers: Map<string, WebSocketBrowserRPC>;
|
|
976
|
+
};
|
|
977
|
+
browserState: Map<string, {
|
|
779
978
|
files: string[];
|
|
780
979
|
resolve: () => void;
|
|
781
980
|
reject: (v: unknown) => void;
|
|
782
|
-
}
|
|
981
|
+
}>;
|
|
783
982
|
testFilesList: string[] | null;
|
|
784
983
|
readonly id: string;
|
|
785
984
|
readonly tmpDir: string;
|
|
@@ -823,11 +1022,12 @@ interface ProcessPool {
|
|
|
823
1022
|
runTests: RunWithFiles;
|
|
824
1023
|
close?: () => Awaitable$1<void>;
|
|
825
1024
|
}
|
|
1025
|
+
declare function getFilePoolName(project: WorkspaceProject, file: string): Pool;
|
|
826
1026
|
|
|
827
1027
|
type Awaitable<T> = T | PromiseLike<T>;
|
|
828
1028
|
type Nullable<T> = T | null | undefined;
|
|
829
1029
|
type Arrayable<T> = T | Array<T>;
|
|
830
|
-
type ArgumentsType
|
|
1030
|
+
type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never;
|
|
831
1031
|
type MutableArray<T extends readonly any[]> = {
|
|
832
1032
|
-readonly [k in keyof T]: T[k];
|
|
833
1033
|
};
|
|
@@ -856,6 +1056,8 @@ interface Environment {
|
|
|
856
1056
|
}
|
|
857
1057
|
interface UserConsoleLog {
|
|
858
1058
|
content: string;
|
|
1059
|
+
origin?: string;
|
|
1060
|
+
browser?: boolean;
|
|
859
1061
|
type: 'stdout' | 'stderr';
|
|
860
1062
|
taskId?: string;
|
|
861
1063
|
time: number;
|
|
@@ -890,7 +1092,8 @@ declare class StateManager {
|
|
|
890
1092
|
collectFiles(files?: File[]): void;
|
|
891
1093
|
clearFiles(_project: {
|
|
892
1094
|
config: {
|
|
893
|
-
name: string;
|
|
1095
|
+
name: string | undefined;
|
|
1096
|
+
root: string;
|
|
894
1097
|
};
|
|
895
1098
|
}, paths?: string[]): void;
|
|
896
1099
|
updateId(task: Task): void;
|
|
@@ -989,10 +1192,12 @@ declare class Vitest {
|
|
|
989
1192
|
private createCoreProject;
|
|
990
1193
|
getCoreWorkspaceProject(): WorkspaceProject;
|
|
991
1194
|
getProjectByTaskId(taskId: string): WorkspaceProject;
|
|
1195
|
+
getProjectByName(name?: string): WorkspaceProject;
|
|
992
1196
|
private getWorkspaceConfigPath;
|
|
993
1197
|
private resolveWorkspace;
|
|
994
1198
|
private initCoverageProvider;
|
|
995
1199
|
private initBrowserProviders;
|
|
1200
|
+
mergeReports(): Promise<void>;
|
|
996
1201
|
start(filters?: string[]): Promise<void>;
|
|
997
1202
|
init(): Promise<void>;
|
|
998
1203
|
private getTestDependencies;
|
|
@@ -1000,7 +1205,7 @@ declare class Vitest {
|
|
|
1000
1205
|
getProjectsByTestFile(file: string): WorkspaceSpec[];
|
|
1001
1206
|
initializeGlobalSetup(paths: WorkspaceSpec[]): Promise<void>;
|
|
1002
1207
|
private initializeDistPath;
|
|
1003
|
-
runFiles(
|
|
1208
|
+
runFiles(specs: WorkspaceSpec[], allTestsRun: boolean): Promise<void>;
|
|
1004
1209
|
cancelCurrentRun(reason: CancelReason): Promise<void>;
|
|
1005
1210
|
rerunFiles(files?: string[], trigger?: string): Promise<void>;
|
|
1006
1211
|
changeProjectName(pattern: string): Promise<void>;
|
|
@@ -1027,7 +1232,7 @@ declare class Vitest {
|
|
|
1027
1232
|
* Close the thread pool and exit the process
|
|
1028
1233
|
*/
|
|
1029
1234
|
exit(force?: boolean): Promise<void>;
|
|
1030
|
-
report<T extends keyof Reporter>(name: T, ...args: ArgumentsType
|
|
1235
|
+
report<T extends keyof Reporter>(name: T, ...args: ArgumentsType<Reporter[T]>): Promise<void>;
|
|
1031
1236
|
getTestFilepaths(): Promise<string[]>;
|
|
1032
1237
|
globTestFiles(filters?: string[]): Promise<WorkspaceSpec[]>;
|
|
1033
1238
|
shouldKeepServer(): boolean;
|
|
@@ -1049,91 +1254,6 @@ interface TestSequencerConstructor {
|
|
|
1049
1254
|
new (ctx: Vitest): TestSequencer;
|
|
1050
1255
|
}
|
|
1051
1256
|
|
|
1052
|
-
declare abstract class BaseReporter implements Reporter {
|
|
1053
|
-
start: number;
|
|
1054
|
-
end: number;
|
|
1055
|
-
watchFilters?: string[];
|
|
1056
|
-
isTTY: boolean;
|
|
1057
|
-
ctx: Vitest;
|
|
1058
|
-
private _filesInWatchMode;
|
|
1059
|
-
private _lastRunTimeout;
|
|
1060
|
-
private _lastRunTimer;
|
|
1061
|
-
private _lastRunCount;
|
|
1062
|
-
private _timeStart;
|
|
1063
|
-
private _offUnhandledRejection?;
|
|
1064
|
-
constructor();
|
|
1065
|
-
get mode(): VitestRunMode;
|
|
1066
|
-
onInit(ctx: Vitest): void;
|
|
1067
|
-
relative(path: string): string;
|
|
1068
|
-
onFinished(files?: File[], errors?: unknown[]): void;
|
|
1069
|
-
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
1070
|
-
onWatcherStart(files?: File[], errors?: unknown[]): void;
|
|
1071
|
-
private resetLastRunLog;
|
|
1072
|
-
onWatcherRerun(files: string[], trigger?: string): void;
|
|
1073
|
-
onUserConsoleLog(log: UserConsoleLog): void;
|
|
1074
|
-
shouldLog(log: UserConsoleLog): boolean;
|
|
1075
|
-
onServerRestart(reason?: string): void;
|
|
1076
|
-
reportSummary(files: File[], errors: unknown[]): void;
|
|
1077
|
-
reportTestSummary(files: File[], errors: unknown[]): void;
|
|
1078
|
-
private printErrorsSummary;
|
|
1079
|
-
reportBenchmarkSummary(files: File[]): void;
|
|
1080
|
-
private printTaskErrors;
|
|
1081
|
-
registerUnhandledRejection(): void;
|
|
1082
|
-
}
|
|
1083
|
-
|
|
1084
|
-
declare class BasicReporter extends BaseReporter {
|
|
1085
|
-
isTTY: boolean;
|
|
1086
|
-
reportSummary(files: File[], errors: unknown[]): void;
|
|
1087
|
-
}
|
|
1088
|
-
|
|
1089
|
-
interface ListRendererOptions {
|
|
1090
|
-
renderSucceed?: boolean;
|
|
1091
|
-
logger: Logger;
|
|
1092
|
-
showHeap: boolean;
|
|
1093
|
-
slowTestThreshold: number;
|
|
1094
|
-
mode: VitestRunMode;
|
|
1095
|
-
}
|
|
1096
|
-
declare function createListRenderer(_tasks: Task[], options: ListRendererOptions): {
|
|
1097
|
-
start(): any;
|
|
1098
|
-
update(_tasks: Task[]): any;
|
|
1099
|
-
stop(): any;
|
|
1100
|
-
clear(): void;
|
|
1101
|
-
};
|
|
1102
|
-
|
|
1103
|
-
declare class DefaultReporter extends BaseReporter {
|
|
1104
|
-
renderer?: ReturnType<typeof createListRenderer>;
|
|
1105
|
-
rendererOptions: ListRendererOptions;
|
|
1106
|
-
private renderSucceedDefault?;
|
|
1107
|
-
onPathsCollected(paths?: string[]): void;
|
|
1108
|
-
onTestRemoved(trigger?: string): Promise<void>;
|
|
1109
|
-
onCollected(): void;
|
|
1110
|
-
onFinished(files?: _vitest_runner.File[], errors?: unknown[]): void;
|
|
1111
|
-
onWatcherStart(files?: _vitest_runner.File[], errors?: unknown[]): Promise<void>;
|
|
1112
|
-
stopListRender(): void;
|
|
1113
|
-
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
1114
|
-
onUserConsoleLog(log: UserConsoleLog): void;
|
|
1115
|
-
}
|
|
1116
|
-
|
|
1117
|
-
interface DotRendererOptions {
|
|
1118
|
-
logger: Logger;
|
|
1119
|
-
}
|
|
1120
|
-
declare function createDotRenderer(_tasks: Task[], options: DotRendererOptions): {
|
|
1121
|
-
start(): any;
|
|
1122
|
-
update(_tasks: Task[]): any;
|
|
1123
|
-
stop(): Promise<any>;
|
|
1124
|
-
clear(): void;
|
|
1125
|
-
};
|
|
1126
|
-
|
|
1127
|
-
declare class DotReporter extends BaseReporter {
|
|
1128
|
-
renderer?: ReturnType<typeof createDotRenderer>;
|
|
1129
|
-
onCollected(): void;
|
|
1130
|
-
onFinished(files?: _vitest_runner.File[], errors?: unknown[]): Promise<void>;
|
|
1131
|
-
onWatcherStart(): Promise<void>;
|
|
1132
|
-
stopListRender(): Promise<void>;
|
|
1133
|
-
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
1134
|
-
onUserConsoleLog(log: UserConsoleLog): void;
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
1257
|
type Status = 'passed' | 'failed' | 'skipped' | 'pending' | 'todo' | 'disabled';
|
|
1138
1258
|
type Milliseconds = number;
|
|
1139
1259
|
interface Callsite {
|
|
@@ -1145,6 +1265,7 @@ interface JsonAssertionResult {
|
|
|
1145
1265
|
fullName: string;
|
|
1146
1266
|
status: Status;
|
|
1147
1267
|
title: string;
|
|
1268
|
+
meta: TaskMeta;
|
|
1148
1269
|
duration?: Milliseconds | null;
|
|
1149
1270
|
failureMessages: Array<string> | null;
|
|
1150
1271
|
location?: Callsite | null;
|
|
@@ -1191,16 +1312,12 @@ declare class JsonReporter implements Reporter {
|
|
|
1191
1312
|
writeReport(report: string): Promise<void>;
|
|
1192
1313
|
}
|
|
1193
1314
|
|
|
1194
|
-
declare class VerboseReporter extends DefaultReporter {
|
|
1195
|
-
constructor();
|
|
1196
|
-
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
1197
|
-
}
|
|
1198
|
-
|
|
1199
1315
|
interface Reporter {
|
|
1200
1316
|
onInit?: (ctx: Vitest) => void;
|
|
1201
1317
|
onPathsCollected?: (paths?: string[]) => Awaitable<void>;
|
|
1318
|
+
onSpecsCollected?: (specs?: SerializableSpec[]) => Awaitable<void>;
|
|
1202
1319
|
onCollected?: (files?: File[]) => Awaitable<void>;
|
|
1203
|
-
onFinished?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
|
|
1320
|
+
onFinished?: (files?: File[], errors?: unknown[], coverage?: unknown) => Awaitable<void>;
|
|
1204
1321
|
onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
|
|
1205
1322
|
onTestRemoved?: (trigger?: string) => Awaitable<void>;
|
|
1206
1323
|
onWatcherStart?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
|
|
@@ -1210,15 +1327,10 @@ interface Reporter {
|
|
|
1210
1327
|
onProcessTimeout?: () => Awaitable<void>;
|
|
1211
1328
|
}
|
|
1212
1329
|
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
static getComment(task: Task): string;
|
|
1218
|
-
private logErrorDetails;
|
|
1219
|
-
protected logTasks(tasks: Task[]): void;
|
|
1220
|
-
onFinished(files?: _vitest_runner.File[]): void;
|
|
1221
|
-
}
|
|
1330
|
+
type SerializableSpec = [project: {
|
|
1331
|
+
name: string | undefined;
|
|
1332
|
+
root: string;
|
|
1333
|
+
}, file: string];
|
|
1222
1334
|
|
|
1223
1335
|
interface JUnitOptions {
|
|
1224
1336
|
outputFile?: string;
|
|
@@ -1251,6 +1363,113 @@ declare class JUnitReporter implements Reporter {
|
|
|
1251
1363
|
onFinished(files?: _vitest_runner.File[]): Promise<void>;
|
|
1252
1364
|
}
|
|
1253
1365
|
|
|
1366
|
+
interface HTMLOptions {
|
|
1367
|
+
outputFile?: string;
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
interface BaseOptions {
|
|
1371
|
+
isTTY?: boolean;
|
|
1372
|
+
}
|
|
1373
|
+
declare abstract class BaseReporter implements Reporter {
|
|
1374
|
+
start: number;
|
|
1375
|
+
end: number;
|
|
1376
|
+
watchFilters?: string[];
|
|
1377
|
+
isTTY: boolean;
|
|
1378
|
+
ctx: Vitest;
|
|
1379
|
+
private _filesInWatchMode;
|
|
1380
|
+
private _lastRunTimeout;
|
|
1381
|
+
private _lastRunTimer;
|
|
1382
|
+
private _lastRunCount;
|
|
1383
|
+
private _timeStart;
|
|
1384
|
+
private _offUnhandledRejection?;
|
|
1385
|
+
constructor(options?: BaseOptions);
|
|
1386
|
+
get mode(): VitestRunMode;
|
|
1387
|
+
onInit(ctx: Vitest): void;
|
|
1388
|
+
relative(path: string): string;
|
|
1389
|
+
onFinished(files?: File[], errors?: unknown[]): void;
|
|
1390
|
+
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
1391
|
+
onWatcherStart(files?: File[], errors?: unknown[]): void;
|
|
1392
|
+
private resetLastRunLog;
|
|
1393
|
+
onWatcherRerun(files: string[], trigger?: string): void;
|
|
1394
|
+
onUserConsoleLog(log: UserConsoleLog): void;
|
|
1395
|
+
shouldLog(log: UserConsoleLog): boolean;
|
|
1396
|
+
onServerRestart(reason?: string): void;
|
|
1397
|
+
reportSummary(files: File[], errors: unknown[]): void;
|
|
1398
|
+
reportTestSummary(files: File[], errors: unknown[]): void;
|
|
1399
|
+
private printErrorsSummary;
|
|
1400
|
+
reportBenchmarkSummary(files: File[]): void;
|
|
1401
|
+
private printTaskErrors;
|
|
1402
|
+
registerUnhandledRejection(): void;
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
declare class BasicReporter extends BaseReporter {
|
|
1406
|
+
isTTY: boolean;
|
|
1407
|
+
reportSummary(files: File[], errors: unknown[]): void;
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
interface ListRendererOptions {
|
|
1411
|
+
renderSucceed?: boolean;
|
|
1412
|
+
logger: Logger;
|
|
1413
|
+
showHeap: boolean;
|
|
1414
|
+
slowTestThreshold: number;
|
|
1415
|
+
mode: VitestRunMode;
|
|
1416
|
+
}
|
|
1417
|
+
declare function createListRenderer(_tasks: Task[], options: ListRendererOptions): {
|
|
1418
|
+
start(): any;
|
|
1419
|
+
update(_tasks: Task[]): any;
|
|
1420
|
+
stop(): any;
|
|
1421
|
+
clear(): void;
|
|
1422
|
+
};
|
|
1423
|
+
|
|
1424
|
+
declare class DefaultReporter extends BaseReporter {
|
|
1425
|
+
renderer?: ReturnType<typeof createListRenderer>;
|
|
1426
|
+
rendererOptions: ListRendererOptions;
|
|
1427
|
+
private renderSucceedDefault?;
|
|
1428
|
+
onPathsCollected(paths?: string[]): void;
|
|
1429
|
+
onTestRemoved(trigger?: string): Promise<void>;
|
|
1430
|
+
onCollected(): void;
|
|
1431
|
+
onFinished(files?: _vitest_runner.File[], errors?: unknown[]): void;
|
|
1432
|
+
onWatcherStart(files?: _vitest_runner.File[], errors?: unknown[]): Promise<void>;
|
|
1433
|
+
stopListRender(): void;
|
|
1434
|
+
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
1435
|
+
onUserConsoleLog(log: UserConsoleLog): void;
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
interface DotRendererOptions {
|
|
1439
|
+
logger: Logger;
|
|
1440
|
+
}
|
|
1441
|
+
declare function createDotRenderer(_tasks: Task[], options: DotRendererOptions): {
|
|
1442
|
+
start(): any;
|
|
1443
|
+
update(_tasks: Task[]): any;
|
|
1444
|
+
stop(): Promise<any>;
|
|
1445
|
+
clear(): void;
|
|
1446
|
+
};
|
|
1447
|
+
|
|
1448
|
+
declare class DotReporter extends BaseReporter {
|
|
1449
|
+
renderer?: ReturnType<typeof createDotRenderer>;
|
|
1450
|
+
onCollected(): void;
|
|
1451
|
+
onFinished(files?: _vitest_runner.File[], errors?: unknown[]): Promise<void>;
|
|
1452
|
+
onWatcherStart(): Promise<void>;
|
|
1453
|
+
stopListRender(): Promise<void>;
|
|
1454
|
+
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
1455
|
+
onUserConsoleLog(log: UserConsoleLog): void;
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
declare class VerboseReporter extends DefaultReporter {
|
|
1459
|
+
constructor();
|
|
1460
|
+
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
declare class TapReporter implements Reporter {
|
|
1464
|
+
protected ctx: Vitest;
|
|
1465
|
+
private logger;
|
|
1466
|
+
onInit(ctx: Vitest): void;
|
|
1467
|
+
static getComment(task: Task): string;
|
|
1468
|
+
private logErrorDetails;
|
|
1469
|
+
protected logTasks(tasks: Task[]): void;
|
|
1470
|
+
onFinished(files?: _vitest_runner.File[]): void;
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1254
1473
|
declare class TapFlatReporter extends TapReporter {
|
|
1255
1474
|
onInit(ctx: Vitest): void;
|
|
1256
1475
|
onFinished(files?: _vitest_runner.File[]): void;
|
|
@@ -1268,6 +1487,17 @@ declare class GithubActionsReporter implements Reporter {
|
|
|
1268
1487
|
onFinished(files?: File[], errors?: unknown[]): void;
|
|
1269
1488
|
}
|
|
1270
1489
|
|
|
1490
|
+
interface BlobOptions {
|
|
1491
|
+
outputFile?: string;
|
|
1492
|
+
}
|
|
1493
|
+
declare class BlobReporter implements Reporter {
|
|
1494
|
+
ctx: Vitest;
|
|
1495
|
+
options: BlobOptions;
|
|
1496
|
+
constructor(options: BlobOptions);
|
|
1497
|
+
onInit(ctx: Vitest): void;
|
|
1498
|
+
onFinished(files: File[] | undefined, errors: unknown[] | undefined, coverage: unknown): Promise<void>;
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1271
1501
|
interface TableRendererOptions {
|
|
1272
1502
|
renderSucceed?: boolean;
|
|
1273
1503
|
logger: Logger;
|
|
@@ -1300,6 +1530,7 @@ interface FlatBenchmarkReport {
|
|
|
1300
1530
|
type FormattedBenchmarkResult = Omit<BenchmarkResult, 'samples'> & {
|
|
1301
1531
|
id: string;
|
|
1302
1532
|
sampleCount: number;
|
|
1533
|
+
median: number;
|
|
1303
1534
|
};
|
|
1304
1535
|
|
|
1305
1536
|
declare const BenchmarkReportsMap: {
|
|
@@ -1311,6 +1542,7 @@ type BenchmarkBuiltinReporters = keyof typeof BenchmarkReportsMap;
|
|
|
1311
1542
|
declare const ReportersMap: {
|
|
1312
1543
|
default: typeof DefaultReporter;
|
|
1313
1544
|
basic: typeof BasicReporter;
|
|
1545
|
+
blob: typeof BlobReporter;
|
|
1314
1546
|
verbose: typeof VerboseReporter;
|
|
1315
1547
|
dot: typeof DotReporter;
|
|
1316
1548
|
json: typeof JsonReporter;
|
|
@@ -1322,18 +1554,17 @@ declare const ReportersMap: {
|
|
|
1322
1554
|
};
|
|
1323
1555
|
type BuiltinReporters = keyof typeof ReportersMap;
|
|
1324
1556
|
interface BuiltinReporterOptions {
|
|
1325
|
-
'default':
|
|
1326
|
-
'basic':
|
|
1557
|
+
'default': BaseOptions;
|
|
1558
|
+
'basic': BaseOptions;
|
|
1327
1559
|
'verbose': never;
|
|
1328
|
-
'dot':
|
|
1560
|
+
'dot': BaseOptions;
|
|
1329
1561
|
'json': JsonOptions$1;
|
|
1562
|
+
'blob': BlobOptions;
|
|
1330
1563
|
'tap': never;
|
|
1331
1564
|
'tap-flat': never;
|
|
1332
1565
|
'junit': JUnitOptions;
|
|
1333
1566
|
'hanging-process': never;
|
|
1334
|
-
'html':
|
|
1335
|
-
outputFile?: string;
|
|
1336
|
-
};
|
|
1567
|
+
'html': HTMLOptions;
|
|
1337
1568
|
}
|
|
1338
1569
|
|
|
1339
1570
|
type ChaiConfig = Omit<Partial<typeof chai.config>, 'useProxy' | 'proxyExcludedKeys'>;
|
|
@@ -1413,71 +1644,6 @@ interface LinkMapper {
|
|
|
1413
1644
|
assetPath(node: Node, name: string): string;
|
|
1414
1645
|
}
|
|
1415
1646
|
|
|
1416
|
-
type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
|
|
1417
|
-
type ReturnType$1<T> = T extends (...args: any) => infer R ? R : never;
|
|
1418
|
-
type PromisifyFn<T> = ReturnType$1<T> extends Promise<any> ? T : (...args: ArgumentsType<T>) => Promise<Awaited<ReturnType$1<T>>>;
|
|
1419
|
-
type BirpcResolver = (name: string, resolved: (...args: unknown[]) => unknown) => ((...args: unknown[]) => unknown) | undefined;
|
|
1420
|
-
interface ChannelOptions {
|
|
1421
|
-
/**
|
|
1422
|
-
* Function to post raw message
|
|
1423
|
-
*/
|
|
1424
|
-
post: (data: any, ...extras: any[]) => any | Promise<any>;
|
|
1425
|
-
/**
|
|
1426
|
-
* Listener to receive raw message
|
|
1427
|
-
*/
|
|
1428
|
-
on: (fn: (data: any, ...extras: any[]) => void) => any | Promise<any>;
|
|
1429
|
-
/**
|
|
1430
|
-
* Custom function to serialize data
|
|
1431
|
-
*
|
|
1432
|
-
* by default it passes the data as-is
|
|
1433
|
-
*/
|
|
1434
|
-
serialize?: (data: any) => any;
|
|
1435
|
-
/**
|
|
1436
|
-
* Custom function to deserialize data
|
|
1437
|
-
*
|
|
1438
|
-
* by default it passes the data as-is
|
|
1439
|
-
*/
|
|
1440
|
-
deserialize?: (data: any) => any;
|
|
1441
|
-
}
|
|
1442
|
-
interface EventOptions<Remote> {
|
|
1443
|
-
/**
|
|
1444
|
-
* Names of remote functions that do not need response.
|
|
1445
|
-
*/
|
|
1446
|
-
eventNames?: (keyof Remote)[];
|
|
1447
|
-
/**
|
|
1448
|
-
* Maximum timeout for waiting for response, in milliseconds.
|
|
1449
|
-
*
|
|
1450
|
-
* @default 60_000
|
|
1451
|
-
*/
|
|
1452
|
-
timeout?: number;
|
|
1453
|
-
/**
|
|
1454
|
-
* Custom resolver to resolve function to be called
|
|
1455
|
-
*
|
|
1456
|
-
* For advanced use cases only
|
|
1457
|
-
*/
|
|
1458
|
-
resolver?: BirpcResolver;
|
|
1459
|
-
/**
|
|
1460
|
-
* Custom error handler
|
|
1461
|
-
*/
|
|
1462
|
-
onError?: (error: Error, functionName: string, args: any[]) => boolean | void;
|
|
1463
|
-
/**
|
|
1464
|
-
* Custom error handler for timeouts
|
|
1465
|
-
*/
|
|
1466
|
-
onTimeoutError?: (functionName: string, args: any[]) => boolean | void;
|
|
1467
|
-
}
|
|
1468
|
-
type BirpcOptions<Remote> = EventOptions<Remote> & ChannelOptions;
|
|
1469
|
-
type BirpcFn<T> = PromisifyFn<T> & {
|
|
1470
|
-
/**
|
|
1471
|
-
* Send event without asking for response
|
|
1472
|
-
*/
|
|
1473
|
-
asEvent: (...args: ArgumentsType<T>) => void;
|
|
1474
|
-
};
|
|
1475
|
-
type BirpcReturn<RemoteFunctions, LocalFunctions = Record<string, never>> = {
|
|
1476
|
-
[K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]>;
|
|
1477
|
-
} & {
|
|
1478
|
-
$functions: LocalFunctions;
|
|
1479
|
-
};
|
|
1480
|
-
|
|
1481
1647
|
type MockFactoryWithHelper<M = unknown> = (importOriginal: <T extends M>() => Promise<T>) => any;
|
|
1482
1648
|
type MockFactory = () => any;
|
|
1483
1649
|
type MockMap = Map<string, Record<string, string | null | MockFactory>>;
|
|
@@ -1563,13 +1729,24 @@ interface WorkerGlobalState {
|
|
|
1563
1729
|
}
|
|
1564
1730
|
|
|
1565
1731
|
type TransformResult = string | Partial<TransformResult$1> | undefined | null | void;
|
|
1732
|
+
type CoverageResults = unknown;
|
|
1566
1733
|
interface CoverageProvider {
|
|
1567
1734
|
name: string;
|
|
1735
|
+
/** Called when provider is being initialized before tests run */
|
|
1568
1736
|
initialize: (ctx: Vitest) => Promise<void> | void;
|
|
1737
|
+
/** Called when setting coverage options for Vitest context (`ctx.config.coverage`) */
|
|
1569
1738
|
resolveOptions: () => ResolvedCoverageOptions;
|
|
1739
|
+
/** Callback to clean previous reports */
|
|
1570
1740
|
clean: (clean?: boolean) => void | Promise<void>;
|
|
1741
|
+
/** Called with coverage results after a single test file has been run */
|
|
1571
1742
|
onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void | Promise<void>;
|
|
1572
|
-
|
|
1743
|
+
/** Callback to generate final coverage results */
|
|
1744
|
+
generateCoverage: (reportContext: ReportContext) => CoverageResults | Promise<CoverageResults>;
|
|
1745
|
+
/** Callback to convert coverage results to coverage reports. Called with results returned from `generateCoverage` */
|
|
1746
|
+
reportCoverage: (coverage: CoverageResults, reportContext: ReportContext) => void | Promise<void>;
|
|
1747
|
+
/** Callback for `--merge-reports` options. Called with multiple coverage results generated by `generateCoverage`. */
|
|
1748
|
+
mergeReports?: (coverages: CoverageResults[]) => void | Promise<void>;
|
|
1749
|
+
/** Callback called for instrumenting files with coverage counters. */
|
|
1573
1750
|
onFileTransform?: (sourceCode: string, id: string, pluginCtx: any) => TransformResult | Promise<TransformResult>;
|
|
1574
1751
|
}
|
|
1575
1752
|
interface ReportContext {
|
|
@@ -1939,7 +2116,7 @@ declare const configDefaults: Readonly<{
|
|
|
1939
2116
|
watch: boolean;
|
|
1940
2117
|
globals: false;
|
|
1941
2118
|
environment: "node";
|
|
1942
|
-
pool: "
|
|
2119
|
+
pool: "forks";
|
|
1943
2120
|
clearMocks: false;
|
|
1944
2121
|
restoreMocks: false;
|
|
1945
2122
|
mockReset: false;
|
|
@@ -2487,7 +2664,7 @@ interface InlineConfig {
|
|
|
2487
2664
|
/**
|
|
2488
2665
|
* Custom environment variables assigned to `process.env` before running tests.
|
|
2489
2666
|
*/
|
|
2490
|
-
env?:
|
|
2667
|
+
env?: Partial<NodeJS.ProcessEnv>;
|
|
2491
2668
|
/**
|
|
2492
2669
|
* Options for @sinon/fake-timers
|
|
2493
2670
|
*/
|
|
@@ -2599,6 +2776,30 @@ interface InlineConfig {
|
|
|
2599
2776
|
*/
|
|
2600
2777
|
waitForDebugger?: boolean;
|
|
2601
2778
|
};
|
|
2779
|
+
/**
|
|
2780
|
+
* Configuration options for expect() matches.
|
|
2781
|
+
*/
|
|
2782
|
+
expect?: {
|
|
2783
|
+
/**
|
|
2784
|
+
* Throw an error if tests don't have any expect() assertions.
|
|
2785
|
+
*/
|
|
2786
|
+
requireAssertions?: boolean;
|
|
2787
|
+
/**
|
|
2788
|
+
* Default options for expect.poll()
|
|
2789
|
+
*/
|
|
2790
|
+
poll?: {
|
|
2791
|
+
/**
|
|
2792
|
+
* Timeout in milliseconds
|
|
2793
|
+
* @default 1000
|
|
2794
|
+
*/
|
|
2795
|
+
timeout?: number;
|
|
2796
|
+
/**
|
|
2797
|
+
* Polling interval in milliseconds
|
|
2798
|
+
* @default 50
|
|
2799
|
+
*/
|
|
2800
|
+
interval?: number;
|
|
2801
|
+
};
|
|
2802
|
+
};
|
|
2602
2803
|
/**
|
|
2603
2804
|
* Modify default Chai config. Vitest uses Chai for `expect` and `assert` matches.
|
|
2604
2805
|
* https://github.com/chaijs/chai/blob/4.x.x/lib/chai/config.js
|
|
@@ -2628,6 +2829,12 @@ interface InlineConfig {
|
|
|
2628
2829
|
* @default false
|
|
2629
2830
|
*/
|
|
2630
2831
|
disableConsoleIntercept?: boolean;
|
|
2832
|
+
/**
|
|
2833
|
+
* Always print console stack traces.
|
|
2834
|
+
*
|
|
2835
|
+
* @default false
|
|
2836
|
+
*/
|
|
2837
|
+
printConsoleTrace?: boolean;
|
|
2631
2838
|
/**
|
|
2632
2839
|
* Include "location" property inside the test definition
|
|
2633
2840
|
*
|
|
@@ -2739,6 +2946,11 @@ interface UserConfig extends InlineConfig {
|
|
|
2739
2946
|
* benchmark.outputJson option exposed at the top level for cli
|
|
2740
2947
|
*/
|
|
2741
2948
|
outputJson?: string;
|
|
2949
|
+
/**
|
|
2950
|
+
* Directory of blob reports to merge
|
|
2951
|
+
* @default '.vitest-reports'
|
|
2952
|
+
*/
|
|
2953
|
+
mergeReports?: string;
|
|
2742
2954
|
}
|
|
2743
2955
|
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'browser' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'benchmark' | 'shard' | 'cache' | 'sequence' | 'typecheck' | 'runner' | 'poolOptions' | 'pool' | 'cliExclude'> {
|
|
2744
2956
|
mode: VitestRunMode;
|
|
@@ -2789,7 +3001,7 @@ type ProjectConfig = Omit<UserConfig, 'sequencer' | 'shard' | 'watch' | 'run' |
|
|
|
2789
3001
|
forks?: Pick<NonNullable<PoolOptions['forks']>, 'singleFork' | 'isolate'>;
|
|
2790
3002
|
};
|
|
2791
3003
|
};
|
|
2792
|
-
type RuntimeConfig = Pick<UserConfig, 'allowOnly' | 'testTimeout' | 'hookTimeout' | 'clearMocks' | 'mockReset' | 'restoreMocks' | 'fakeTimers' | 'maxConcurrency'> & {
|
|
3004
|
+
type RuntimeConfig = Pick<UserConfig, 'allowOnly' | 'testTimeout' | 'hookTimeout' | 'clearMocks' | 'mockReset' | 'restoreMocks' | 'fakeTimers' | 'maxConcurrency' | 'expect' | 'printConsoleTrace'> & {
|
|
2793
3005
|
sequence?: {
|
|
2794
3006
|
concurrent?: boolean;
|
|
2795
3007
|
hooks?: SequenceHooks;
|
|
@@ -2833,7 +3045,18 @@ declare module '@vitest/expect' {
|
|
|
2833
3045
|
environment: VitestEnvironment;
|
|
2834
3046
|
snapshotState: SnapshotState;
|
|
2835
3047
|
}
|
|
3048
|
+
interface ExpectPollOptions {
|
|
3049
|
+
interval?: number;
|
|
3050
|
+
timeout?: number;
|
|
3051
|
+
message?: string;
|
|
3052
|
+
}
|
|
2836
3053
|
interface ExpectStatic {
|
|
3054
|
+
unreachable: (message?: string) => never;
|
|
3055
|
+
soft: <T>(actual: T, message?: string) => Assertion<T>;
|
|
3056
|
+
poll: <T>(actual: () => T, options?: ExpectPollOptions) => PromisifyAssertion<Awaited<T>>;
|
|
3057
|
+
addEqualityTesters: (testers: Array<Tester>) => void;
|
|
3058
|
+
assertions: (expected: number) => void;
|
|
3059
|
+
hasAssertions: () => void;
|
|
2837
3060
|
addSnapshotSerializer: (plugin: Plugin_2) => void;
|
|
2838
3061
|
}
|
|
2839
3062
|
interface Assertion<T> {
|
|
@@ -2891,4 +3114,4 @@ type Context = RootAndTarget & {
|
|
|
2891
3114
|
lastActivePath?: string;
|
|
2892
3115
|
};
|
|
2893
3116
|
|
|
2894
|
-
export { type
|
|
3117
|
+
export { type ArgumentsType as $, type ApiConfig as A, type BaseCoverageOptions as B, type CoverageOptions as C, type DepsOptimizationOptions as D, type Environment as E, type FakeTimerInstallOpts as F, type ContextTestEnvironment as G, type HappyDOMOptions as H, type InlineConfig as I, type JSDOMOptions as J, type ResolvedTestEnvironment as K, Vitest as L, type MockFactoryWithHelper as M, type Reporter as N, type ResolveIdFunction as O, type ProvidedContext as P, type AfterSuiteRunMeta as Q, type ResolvedConfig as R, type SerializableSpec as S, type TscErrorInfo as T, type UserConfig as U, type VitestEnvironment as V, type WorkerGlobalState as W, type WorkerRPC as X, type Awaitable as Y, type Nullable as Z, type Arrayable as _, type ResolvedCoverageOptions as a, TapReporter as a$, type MutableArray as a0, type Constructable as a1, type ModuleCache as a2, type EnvironmentReturn as a3, type VmEnvironmentReturn as a4, type UserConsoleLog as a5, type ModuleGraphData as a6, type OnServerRestartHandler as a7, type ReportContext as a8, type CoverageReporter as a9, type BrowserCommand as aA, type BrowserCommandContext as aB, type JsonOptions$1 as aC, type JUnitOptions as aD, type HTMLOptions as aE, type PendingSuiteMock as aF, type MockFactory as aG, type MockMap as aH, type UserConfigFnObject as aI, type UserConfigFnPromise as aJ, type UserConfigFn as aK, type UserConfigExport as aL, type UserProjectConfigFn as aM, type UserProjectConfigExport as aN, defineConfig as aO, defineProject as aP, defineWorkspace as aQ, configDefaults as aR, defaultInclude as aS, defaultExclude as aT, coverageConfigDefaults as aU, extraInlineDeps as aV, DefaultReporter as aW, BasicReporter as aX, DotReporter as aY, JsonReporter as aZ, VerboseReporter as a_, type CoverageIstanbulOptions as aa, type CoverageV8Options as ab, type CustomProviderOptions as ac, type BenchmarkUserOptions as ad, type Benchmark as ae, type BenchmarkResult as af, type BenchFunction as ag, type BenchmarkAPI as ah, type TransformResultWithSource as ai, type WebSocketHandlers as aj, type WebSocketBrowserHandlers as ak, type WebSocketEvents as al, type WebSocketBrowserEvents as am, type WebSocketRPC as an, type WebSocketBrowserRPC as ao, type VitestOptions as ap, WorkspaceProject as aq, type TestSequencer as ar, type WorkspaceSpec as as, type ProcessPool as at, getFilePoolName as au, VitestPackageInstaller as av, type TestSequencerConstructor as aw, type BrowserProviderInitializationOptions as ax, type BrowserProvider as ay, type BrowserProviderOptions as az, type CoverageProvider as b, JUnitReporter as b0, TapFlatReporter as b1, HangingProcessReporter as b2, GithubActionsReporter as b3, BaseReporter as b4, ReportersMap as b5, type BuiltinReporters as b6, type BuiltinReporterOptions as b7, type JsonAssertionResult as b8, type JsonTestResult as b9, type JsonTestResults as ba, BenchmarkReportsMap as bb, type BenchmarkBuiltinReporters as bc, type CoverageProviderModule as c, type BirpcOptions as d, type RuntimeRPC as e, type ContextRPC as f, type WorkerContext as g, type RuntimeConfig as h, type RawErrsMap as i, type CollectLineNumbers as j, type CollectLines as k, type RootAndTarget as l, type Context as m, type Pool as n, type PoolOptions as o, type BuiltinEnvironment as p, type CSSModuleScopeStrategy as q, type EnvironmentOptions as r, type VitestRunMode as s, type TransformModePatterns as t, type TypecheckConfig as u, type ProjectConfig as v, type BrowserScript as w, type BrowserConfigOptions as x, type UserWorkspaceConfig as y, type RunnerRPC as z };
|