vitest 0.21.1 → 0.22.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 +32 -4
- package/dist/browser.d.ts +4 -5
- package/dist/browser.mjs +8 -9
- package/dist/{chunk-api-setup.7a6ba7fb.mjs → chunk-api-setup.ecd02c18.mjs} +8 -7
- package/dist/{chunk-constants.26dc9f85.mjs → chunk-constants.d3f8437b.mjs} +4 -4
- package/dist/{chunk-install-pkg.6c6dc0c2.mjs → chunk-install-pkg.3aa3eae6.mjs} +3 -2
- package/dist/{chunk-defaults.02abff90.mjs → chunk-integrations-coverage.d205bd87.mjs} +23 -152
- package/dist/{chunk-integrations-globals.44a8f047.mjs → chunk-integrations-globals.e81d2091.mjs} +7 -6
- package/dist/{chunk-mock-date.bc81a3ac.mjs → chunk-mock-date.debe9954.mjs} +6 -67
- package/dist/chunk-node-git.71b74da4.mjs +80 -0
- package/dist/{chunk-runtime-chain.98d42d89.mjs → chunk-runtime-chain.6e363ba2.mjs} +4 -3
- package/dist/{chunk-runtime-error.87a2b5a2.mjs → chunk-runtime-error.975bd80a.mjs} +13 -12
- package/dist/{chunk-runtime-hooks.453f8858.mjs → chunk-runtime-hooks.4789e99d.mjs} +3 -3
- package/dist/{chunk-runtime-mocker.23b62bfa.mjs → chunk-runtime-mocker.c91d29ce.mjs} +5 -5
- package/dist/{chunk-runtime-rpc.b50ab560.mjs → chunk-runtime-rpc.29488183.mjs} +1 -1
- package/dist/{chunk-utils-source-map.94107ee8.mjs → chunk-utils-source-map.2a082ffd.mjs} +2 -1
- package/dist/{chunk-vite-node-client.fdd9592c.mjs → chunk-vite-node-client.d1ead698.mjs} +2 -2
- package/dist/{chunk-vite-node-debug.09afb76f.mjs → chunk-vite-node-debug.ff1d2a9f.mjs} +3 -2
- package/dist/{chunk-vite-node-externalize.27aee038.mjs → chunk-vite-node-externalize.3a38c8af.mjs} +153 -35
- package/dist/{chunk-vite-node-utils.f34df9d3.mjs → chunk-vite-node-utils.d8e5ff7b.mjs} +42 -8
- package/dist/cli-wrapper.mjs +107 -0
- package/dist/cli.mjs +15 -13
- package/dist/config.cjs +3 -0
- package/dist/config.d.ts +6 -3
- package/dist/config.mjs +2 -1
- package/dist/entry.mjs +8 -9
- package/dist/{global-60f880c6.d.ts → global-74489cc9.d.ts} +485 -166
- package/dist/{index-4a906fa4.d.ts → index-9eded9ec.d.ts} +2 -50
- package/dist/index.d.ts +5 -6
- package/dist/index.mjs +6 -5
- package/dist/loader.mjs +3 -2
- package/dist/node.d.ts +3 -3
- package/dist/node.mjs +14 -12
- package/dist/suite.mjs +5 -4
- package/dist/{vendor-index.61438b77.mjs → vendor-index.29636037.mjs} +1 -61
- package/dist/{vendor-index.62ce5c33.mjs → vendor-index.2ae8040a.mjs} +0 -0
- package/dist/vendor-index.9d9196cc.mjs +61 -0
- package/dist/{chunk-node-git.c2be9c49.mjs → vendor-index.fbec8a81.mjs} +5 -73
- package/dist/vendor-picocolors.807856aa.mjs +64 -0
- package/dist/worker.mjs +7 -6
- package/package.json +6 -10
- package/vitest.mjs +1 -1
- package/dist/mocker-5e2a8e41.d.ts +0 -3
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ViteDevServer, TransformResult, UserConfig as UserConfig$1, CommonServerOptions, AliasOptions } from 'vite';
|
|
1
|
+
import { ViteDevServer, TransformResult as TransformResult$1, UserConfig as UserConfig$1, CommonServerOptions, AliasOptions } from 'vite';
|
|
2
|
+
import { MessagePort } from 'worker_threads';
|
|
2
3
|
import { Stats } from 'fs';
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -297,7 +298,7 @@ interface FetchResult {
|
|
|
297
298
|
}
|
|
298
299
|
declare type HotContext = Omit<ViteHotContext, 'acceptDeps' | 'decline'>;
|
|
299
300
|
declare type FetchFunction = (id: string) => Promise<FetchResult>;
|
|
300
|
-
declare type ResolveIdFunction = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
|
|
301
|
+
declare type ResolveIdFunction$1 = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
|
|
301
302
|
declare type CreateHotContextFunction = (runner: ViteNodeRunner, url: string) => HotContext;
|
|
302
303
|
interface ModuleCache$1 {
|
|
303
304
|
promise?: Promise<any>;
|
|
@@ -307,7 +308,7 @@ interface ModuleCache$1 {
|
|
|
307
308
|
interface ViteNodeRunnerOptions {
|
|
308
309
|
root: string;
|
|
309
310
|
fetchModule: FetchFunction;
|
|
310
|
-
resolveId?: ResolveIdFunction;
|
|
311
|
+
resolveId?: ResolveIdFunction$1;
|
|
311
312
|
createHotContext?: CreateHotContextFunction;
|
|
312
313
|
base?: string;
|
|
313
314
|
moduleCache?: ModuleCacheMap;
|
|
@@ -363,8 +364,8 @@ declare class Debugger {
|
|
|
363
364
|
clearDump(): Promise<void>;
|
|
364
365
|
encodeId(id: string): string;
|
|
365
366
|
recordExternalize(id: string, path: string): Promise<void>;
|
|
366
|
-
dumpFile(id: string, result: TransformResult | null): Promise<void>;
|
|
367
|
-
loadDump(id: string): Promise<TransformResult | null>;
|
|
367
|
+
dumpFile(id: string, result: TransformResult$1 | null): Promise<void>;
|
|
368
|
+
loadDump(id: string): Promise<TransformResult$1 | null>;
|
|
368
369
|
writeInfo(): Promise<void>;
|
|
369
370
|
}
|
|
370
371
|
|
|
@@ -383,7 +384,7 @@ declare class ViteNodeServer {
|
|
|
383
384
|
shouldExternalize(id: string): Promise<string | false>;
|
|
384
385
|
resolveId(id: string, importer?: string): Promise<ViteNodeResolveId | null>;
|
|
385
386
|
fetchModule(id: string): Promise<FetchResult>;
|
|
386
|
-
transformRequest(id: string): Promise<TransformResult | null | undefined>;
|
|
387
|
+
transformRequest(id: string): Promise<TransformResult$1 | null | undefined>;
|
|
387
388
|
getTransformMode(id: string): "web" | "ssr";
|
|
388
389
|
private _fetchModule;
|
|
389
390
|
private _transformRequest;
|
|
@@ -515,6 +516,7 @@ declare class Vitest {
|
|
|
515
516
|
snapshot: SnapshotManager;
|
|
516
517
|
cache: VitestCache;
|
|
517
518
|
reporters: Reporter[];
|
|
519
|
+
coverageProvider: CoverageProvider | null | undefined;
|
|
518
520
|
logger: Logger;
|
|
519
521
|
pool: WorkerPool | undefined;
|
|
520
522
|
vitenode: ViteNodeServer;
|
|
@@ -528,6 +530,7 @@ declare class Vitest {
|
|
|
528
530
|
constructor();
|
|
529
531
|
private _onRestartListeners;
|
|
530
532
|
setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
|
|
533
|
+
initCoverageProvider(): Promise<CoverageProvider | null | undefined>;
|
|
531
534
|
getSerializableConfig(): ResolvedConfig;
|
|
532
535
|
start(filters?: string[]): Promise<void>;
|
|
533
536
|
private getTestDependencies;
|
|
@@ -547,13 +550,15 @@ declare class Vitest {
|
|
|
547
550
|
private handleFileChanged;
|
|
548
551
|
close(): Promise<void>;
|
|
549
552
|
exit(force?: boolean): Promise<void>;
|
|
550
|
-
report<T extends keyof Reporter>(name: T, ...args: ArgumentsType<Reporter[T]>): Promise<void>;
|
|
553
|
+
report<T extends keyof Reporter>(name: T, ...args: ArgumentsType$1<Reporter[T]>): Promise<void>;
|
|
551
554
|
globTestFiles(filters?: string[]): Promise<string[]>;
|
|
552
555
|
isTargetFile(id: string, source?: string): Promise<boolean>;
|
|
553
556
|
isInSourceTestFile(code: string): boolean;
|
|
554
557
|
onServerRestarted(fn: () => void): void;
|
|
555
558
|
}
|
|
556
559
|
|
|
560
|
+
declare type MockMap = Map<string, Record<string, string | null | (() => unknown)>>;
|
|
561
|
+
|
|
557
562
|
interface TestSequencer {
|
|
558
563
|
/**
|
|
559
564
|
* Slicing tests into shards. Will be run before `sort`.
|
|
@@ -690,10 +695,215 @@ declare const ReportersMap: {
|
|
|
690
695
|
};
|
|
691
696
|
declare type BuiltinReporters = keyof typeof ReportersMap;
|
|
692
697
|
|
|
698
|
+
interface RollupError extends RollupLogProps {
|
|
699
|
+
parserError?: Error;
|
|
700
|
+
stack?: string;
|
|
701
|
+
watchFiles?: string[];
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
interface RollupWarning extends RollupLogProps {
|
|
705
|
+
chunkName?: string;
|
|
706
|
+
cycle?: string[];
|
|
707
|
+
exportName?: string;
|
|
708
|
+
exporter?: string;
|
|
709
|
+
guess?: string;
|
|
710
|
+
importer?: string;
|
|
711
|
+
missing?: string;
|
|
712
|
+
modules?: string[];
|
|
713
|
+
names?: string[];
|
|
714
|
+
reexporter?: string;
|
|
715
|
+
source?: string;
|
|
716
|
+
sources?: string[];
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
interface RollupLogProps {
|
|
720
|
+
code?: string;
|
|
721
|
+
frame?: string;
|
|
722
|
+
hook?: string;
|
|
723
|
+
id?: string;
|
|
724
|
+
loc?: {
|
|
725
|
+
column: number;
|
|
726
|
+
file?: string;
|
|
727
|
+
line: number;
|
|
728
|
+
};
|
|
729
|
+
message: string;
|
|
730
|
+
name?: string;
|
|
731
|
+
plugin?: string;
|
|
732
|
+
pluginCode?: string;
|
|
733
|
+
pos?: number;
|
|
734
|
+
url?: string;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
interface ExistingRawSourceMap {
|
|
738
|
+
file?: string;
|
|
739
|
+
mappings: string;
|
|
740
|
+
names: string[];
|
|
741
|
+
sourceRoot?: string;
|
|
742
|
+
sources: string[];
|
|
743
|
+
sourcesContent?: string[];
|
|
744
|
+
version: number;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
interface SourceMap {
|
|
748
|
+
file: string;
|
|
749
|
+
mappings: string;
|
|
750
|
+
names: string[];
|
|
751
|
+
sources: string[];
|
|
752
|
+
sourcesContent: string[];
|
|
753
|
+
version: number;
|
|
754
|
+
toString(): string;
|
|
755
|
+
toUrl(): string;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
type SourceMapInput = ExistingRawSourceMap | string | null | { mappings: '' };
|
|
759
|
+
|
|
760
|
+
type PartialNull<T> = {
|
|
761
|
+
[P in keyof T]: T[P] | null;
|
|
762
|
+
};
|
|
763
|
+
|
|
764
|
+
interface ModuleOptions {
|
|
765
|
+
meta: CustomPluginOptions;
|
|
766
|
+
moduleSideEffects: boolean | 'no-treeshake';
|
|
767
|
+
syntheticNamedExports: boolean | string;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
interface SourceDescription extends Partial<PartialNull<ModuleOptions>> {
|
|
771
|
+
ast?: AcornNode;
|
|
772
|
+
code: string;
|
|
773
|
+
map?: SourceMapInput;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
interface PluginCache {
|
|
777
|
+
delete(id: string): boolean;
|
|
778
|
+
get<T = any>(id: string): T;
|
|
779
|
+
has(id: string): boolean;
|
|
780
|
+
set<T = any>(id: string, value: T): void;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
interface MinimalPluginContext {
|
|
784
|
+
meta: PluginContextMeta;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
interface EmittedAsset {
|
|
788
|
+
fileName?: string;
|
|
789
|
+
name?: string;
|
|
790
|
+
source?: string | Uint8Array;
|
|
791
|
+
type: 'asset';
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
interface EmittedChunk {
|
|
795
|
+
fileName?: string;
|
|
796
|
+
id: string;
|
|
797
|
+
implicitlyLoadedAfterOneOf?: string[];
|
|
798
|
+
importer?: string;
|
|
799
|
+
name?: string;
|
|
800
|
+
preserveSignature?: PreserveEntrySignaturesOption;
|
|
801
|
+
type: 'chunk';
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
type EmittedFile = EmittedAsset | EmittedChunk;
|
|
805
|
+
|
|
806
|
+
type EmitAsset = (name: string, source?: string | Uint8Array) => string;
|
|
807
|
+
|
|
808
|
+
type EmitChunk = (id: string, options?: { name?: string }) => string;
|
|
809
|
+
|
|
810
|
+
type EmitFile = (emittedFile: EmittedFile) => string;
|
|
811
|
+
|
|
812
|
+
interface ModuleInfo extends ModuleOptions {
|
|
813
|
+
ast: AcornNode | null;
|
|
814
|
+
code: string | null;
|
|
815
|
+
dynamicImporters: readonly string[];
|
|
816
|
+
dynamicallyImportedIdResolutions: readonly ResolvedId[];
|
|
817
|
+
dynamicallyImportedIds: readonly string[];
|
|
818
|
+
hasDefaultExport: boolean | null;
|
|
819
|
+
/** @deprecated Use `moduleSideEffects` instead */
|
|
820
|
+
hasModuleSideEffects: boolean | 'no-treeshake';
|
|
821
|
+
id: string;
|
|
822
|
+
implicitlyLoadedAfterOneOf: readonly string[];
|
|
823
|
+
implicitlyLoadedBefore: readonly string[];
|
|
824
|
+
importedIdResolutions: readonly ResolvedId[];
|
|
825
|
+
importedIds: readonly string[];
|
|
826
|
+
importers: readonly string[];
|
|
827
|
+
isEntry: boolean;
|
|
828
|
+
isExternal: boolean;
|
|
829
|
+
isIncluded: boolean | null;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
type GetModuleInfo = (moduleId: string) => ModuleInfo | null;
|
|
833
|
+
|
|
834
|
+
interface CustomPluginOptions {
|
|
835
|
+
[plugin: string]: any;
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
interface PluginContext extends MinimalPluginContext {
|
|
839
|
+
addWatchFile: (id: string) => void;
|
|
840
|
+
cache: PluginCache;
|
|
841
|
+
/** @deprecated Use `this.emitFile` instead */
|
|
842
|
+
emitAsset: EmitAsset;
|
|
843
|
+
/** @deprecated Use `this.emitFile` instead */
|
|
844
|
+
emitChunk: EmitChunk;
|
|
845
|
+
emitFile: EmitFile;
|
|
846
|
+
error: (err: RollupError | string, pos?: number | { column: number; line: number }) => never;
|
|
847
|
+
/** @deprecated Use `this.getFileName` instead */
|
|
848
|
+
getAssetFileName: (assetReferenceId: string) => string;
|
|
849
|
+
/** @deprecated Use `this.getFileName` instead */
|
|
850
|
+
getChunkFileName: (chunkReferenceId: string) => string;
|
|
851
|
+
getFileName: (fileReferenceId: string) => string;
|
|
852
|
+
getModuleIds: () => IterableIterator<string>;
|
|
853
|
+
getModuleInfo: GetModuleInfo;
|
|
854
|
+
getWatchFiles: () => string[];
|
|
855
|
+
/** @deprecated Use `this.resolve` instead */
|
|
856
|
+
isExternal: IsExternal;
|
|
857
|
+
load: (
|
|
858
|
+
options: { id: string; resolveDependencies?: boolean } & Partial<PartialNull<ModuleOptions>>
|
|
859
|
+
) => Promise<ModuleInfo>;
|
|
860
|
+
/** @deprecated Use `this.getModuleIds` instead */
|
|
861
|
+
moduleIds: IterableIterator<string>;
|
|
862
|
+
parse: (input: string, options?: any) => AcornNode;
|
|
863
|
+
resolve: (
|
|
864
|
+
source: string,
|
|
865
|
+
importer?: string,
|
|
866
|
+
options?: { custom?: CustomPluginOptions; isEntry?: boolean; skipSelf?: boolean }
|
|
867
|
+
) => Promise<ResolvedId | null>;
|
|
868
|
+
/** @deprecated Use `this.resolve` instead */
|
|
869
|
+
resolveId: (source: string, importer?: string) => Promise<string | null>;
|
|
870
|
+
setAssetSource: (assetReferenceId: string, source: string | Uint8Array) => void;
|
|
871
|
+
warn: (warning: RollupWarning | string, pos?: number | { column: number; line: number }) => void;
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
interface PluginContextMeta {
|
|
875
|
+
rollupVersion: string;
|
|
876
|
+
watchMode: boolean;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
interface ResolvedId extends ModuleOptions {
|
|
880
|
+
external: boolean | 'absolute';
|
|
881
|
+
id: string;
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
type IsExternal = (
|
|
885
|
+
source: string,
|
|
886
|
+
importer: string | undefined,
|
|
887
|
+
isResolved: boolean
|
|
888
|
+
) => boolean;
|
|
889
|
+
|
|
890
|
+
interface TransformPluginContext extends PluginContext {
|
|
891
|
+
getCombinedSourcemap: () => SourceMap;
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
type TransformResult = string | null | void | Partial<SourceDescription>;
|
|
895
|
+
type PreserveEntrySignaturesOption = false | 'strict' | 'allow-extension' | 'exports-only';
|
|
896
|
+
|
|
897
|
+
interface AcornNode {
|
|
898
|
+
end: number;
|
|
899
|
+
start: number;
|
|
900
|
+
type: string;
|
|
901
|
+
}
|
|
902
|
+
|
|
693
903
|
declare type Awaitable<T> = T | PromiseLike<T>;
|
|
694
904
|
declare type Nullable<T> = T | null | undefined;
|
|
695
905
|
declare type Arrayable<T> = T | Array<T>;
|
|
696
|
-
declare type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never;
|
|
906
|
+
declare type ArgumentsType$1<T> = T extends (...args: infer U) => any ? U : never;
|
|
697
907
|
declare type MergeInsertions<T> = T extends object ? {
|
|
698
908
|
[K in keyof T]: MergeInsertions<T[K]>;
|
|
699
909
|
} : T;
|
|
@@ -755,149 +965,18 @@ interface ModuleGraphData {
|
|
|
755
965
|
inlined: string[];
|
|
756
966
|
}
|
|
757
967
|
|
|
758
|
-
declare type
|
|
759
|
-
|
|
968
|
+
declare type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
|
|
969
|
+
declare type ReturnType$1<T> = T extends (...args: any) => infer R ? R : never;
|
|
970
|
+
declare type PromisifyFn<T> = ReturnType$1<T> extends Promise<any> ? T : (...args: ArgumentsType<T>) => Promise<Awaited<ReturnType$1<T>>>;
|
|
971
|
+
declare type BirpcFn<T> = PromisifyFn<T> & {
|
|
760
972
|
/**
|
|
761
|
-
*
|
|
762
|
-
*
|
|
763
|
-
* @default false
|
|
764
|
-
*/
|
|
765
|
-
enabled?: boolean;
|
|
766
|
-
/**
|
|
767
|
-
* Directory to write coverage report to
|
|
768
|
-
*/
|
|
769
|
-
reportsDirectory?: string;
|
|
770
|
-
/**
|
|
771
|
-
* Clean coverage before running tests
|
|
772
|
-
*
|
|
773
|
-
* @default true
|
|
774
|
-
*/
|
|
775
|
-
clean?: boolean;
|
|
776
|
-
/**
|
|
777
|
-
* Clean coverage report on watch rerun
|
|
778
|
-
*
|
|
779
|
-
* @default false
|
|
780
|
-
*/
|
|
781
|
-
cleanOnRerun?: boolean;
|
|
782
|
-
/**
|
|
783
|
-
* Check thresholds per file
|
|
784
|
-
*
|
|
785
|
-
* @default false
|
|
973
|
+
* Send event without asking for response
|
|
786
974
|
*/
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
*/
|
|
793
|
-
allowExternal?: any;
|
|
794
|
-
/**
|
|
795
|
-
* Reporters
|
|
796
|
-
*
|
|
797
|
-
* @default 'text'
|
|
798
|
-
*/
|
|
799
|
-
reporter?: Arrayable<CoverageReporter>;
|
|
800
|
-
/**
|
|
801
|
-
* Exclude coverage under /node_modules/
|
|
802
|
-
*
|
|
803
|
-
* @default true
|
|
804
|
-
*/
|
|
805
|
-
excludeNodeModules?: boolean;
|
|
806
|
-
exclude?: string[];
|
|
807
|
-
include?: string[];
|
|
808
|
-
skipFull?: boolean;
|
|
809
|
-
extension?: string | string[];
|
|
810
|
-
all?: boolean;
|
|
811
|
-
src?: string[];
|
|
812
|
-
100?: boolean;
|
|
813
|
-
lines?: number;
|
|
814
|
-
functions?: number;
|
|
815
|
-
branches?: number;
|
|
816
|
-
statements?: number;
|
|
817
|
-
}
|
|
818
|
-
interface ResolvedC8Options extends Required<C8Options> {
|
|
819
|
-
tempDirectory: string;
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
interface JSDOMOptions {
|
|
823
|
-
/**
|
|
824
|
-
* The html content for the test.
|
|
825
|
-
*
|
|
826
|
-
* @default '<!DOCTYPE html>'
|
|
827
|
-
*/
|
|
828
|
-
html?: string | Buffer | ArrayBufferLike;
|
|
829
|
-
/**
|
|
830
|
-
* referrer just affects the value read from document.referrer.
|
|
831
|
-
* It defaults to no referrer (which reflects as the empty string).
|
|
832
|
-
*/
|
|
833
|
-
referrer?: string;
|
|
834
|
-
/**
|
|
835
|
-
* userAgent affects the value read from navigator.userAgent, as well as the User-Agent header sent while fetching subresources.
|
|
836
|
-
*
|
|
837
|
-
* @default `Mozilla/5.0 (${process.platform}) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/${jsdomVersion}`
|
|
838
|
-
*/
|
|
839
|
-
userAgent?: string;
|
|
840
|
-
/**
|
|
841
|
-
* url sets the value returned by window.location, document.URL, and document.documentURI,
|
|
842
|
-
* and affects things like resolution of relative URLs within the document
|
|
843
|
-
* and the same-origin restrictions and referrer used while fetching subresources.
|
|
844
|
-
*
|
|
845
|
-
* @default 'http://localhost:3000'.
|
|
846
|
-
*/
|
|
847
|
-
url?: string;
|
|
848
|
-
/**
|
|
849
|
-
* contentType affects the value read from document.contentType, and how the document is parsed: as HTML or as XML.
|
|
850
|
-
* Values that are not "text/html" or an XML mime type will throw.
|
|
851
|
-
*
|
|
852
|
-
* @default 'text/html'.
|
|
853
|
-
*/
|
|
854
|
-
contentType?: string;
|
|
855
|
-
/**
|
|
856
|
-
* The maximum size in code units for the separate storage areas used by localStorage and sessionStorage.
|
|
857
|
-
* Attempts to store data larger than this limit will cause a DOMException to be thrown. By default, it is set
|
|
858
|
-
* to 5,000,000 code units per origin, as inspired by the HTML specification.
|
|
859
|
-
*
|
|
860
|
-
* @default 5_000_000
|
|
861
|
-
*/
|
|
862
|
-
storageQuota?: number;
|
|
863
|
-
/**
|
|
864
|
-
* Enable console?
|
|
865
|
-
*
|
|
866
|
-
* @default false
|
|
867
|
-
*/
|
|
868
|
-
console?: boolean;
|
|
869
|
-
/**
|
|
870
|
-
* jsdom does not have the capability to render visual content, and will act like a headless browser by default.
|
|
871
|
-
* It provides hints to web pages through APIs such as document.hidden that their content is not visible.
|
|
872
|
-
*
|
|
873
|
-
* When the `pretendToBeVisual` option is set to `true`, jsdom will pretend that it is rendering and displaying
|
|
874
|
-
* content.
|
|
875
|
-
*
|
|
876
|
-
* @default true
|
|
877
|
-
*/
|
|
878
|
-
pretendToBeVisual?: boolean;
|
|
879
|
-
/**
|
|
880
|
-
* `includeNodeLocations` preserves the location info produced by the HTML parser,
|
|
881
|
-
* allowing you to retrieve it with the nodeLocation() method (described below).
|
|
882
|
-
*
|
|
883
|
-
* It defaults to false to give the best performance,
|
|
884
|
-
* and cannot be used with an XML content type since our XML parser does not support location info.
|
|
885
|
-
*
|
|
886
|
-
* @default false
|
|
887
|
-
*/
|
|
888
|
-
includeNodeLocations?: boolean | undefined;
|
|
889
|
-
/**
|
|
890
|
-
* @default 'dangerously'
|
|
891
|
-
*/
|
|
892
|
-
runScripts?: 'dangerously' | 'outside-only';
|
|
893
|
-
/**
|
|
894
|
-
* Enable CookieJar
|
|
895
|
-
*
|
|
896
|
-
* @default false
|
|
897
|
-
*/
|
|
898
|
-
cookieJar?: boolean;
|
|
899
|
-
resources?: 'usable' | any;
|
|
900
|
-
}
|
|
975
|
+
asEvent(...args: ArgumentsType<T>): void;
|
|
976
|
+
};
|
|
977
|
+
declare type BirpcReturn<RemoteFunctions> = {
|
|
978
|
+
[K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]>;
|
|
979
|
+
};
|
|
901
980
|
|
|
902
981
|
declare type ChainableFunction<T extends string, Args extends any[], R = any, E = {}> = {
|
|
903
982
|
(...args: Args): R;
|
|
@@ -1034,19 +1113,6 @@ interface TestContext {
|
|
|
1034
1113
|
expect: Vi.ExpectStatic;
|
|
1035
1114
|
}
|
|
1036
1115
|
|
|
1037
|
-
interface Reporter {
|
|
1038
|
-
onInit?(ctx: Vitest): void;
|
|
1039
|
-
onPathsCollected?: (paths?: string[]) => Awaitable<void>;
|
|
1040
|
-
onCollected?: (files?: File[]) => Awaitable<void>;
|
|
1041
|
-
onFinished?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
|
|
1042
|
-
onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
|
|
1043
|
-
onTestRemoved?: (trigger?: string) => Awaitable<void>;
|
|
1044
|
-
onWatcherStart?: () => Awaitable<void>;
|
|
1045
|
-
onWatcherRerun?: (files: string[], trigger?: string) => Awaitable<void>;
|
|
1046
|
-
onServerRestart?: () => Awaitable<void>;
|
|
1047
|
-
onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
1116
|
declare type SnapshotData = Record<string, string>;
|
|
1051
1117
|
declare type SnapshotUpdateState = 'all' | 'new' | 'none';
|
|
1052
1118
|
interface SnapshotStateOptions {
|
|
@@ -1094,6 +1160,259 @@ interface SnapshotSummary {
|
|
|
1094
1160
|
updated: number;
|
|
1095
1161
|
}
|
|
1096
1162
|
|
|
1163
|
+
interface WorkerContext {
|
|
1164
|
+
workerId: number;
|
|
1165
|
+
port: MessagePort;
|
|
1166
|
+
config: ResolvedConfig;
|
|
1167
|
+
files: string[];
|
|
1168
|
+
invalidates?: string[];
|
|
1169
|
+
}
|
|
1170
|
+
declare type ResolveIdFunction = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
|
|
1171
|
+
interface AfterSuiteRunMeta {
|
|
1172
|
+
coverage?: unknown;
|
|
1173
|
+
}
|
|
1174
|
+
interface WorkerRPC {
|
|
1175
|
+
fetch: FetchFunction;
|
|
1176
|
+
resolveId: ResolveIdFunction;
|
|
1177
|
+
getSourceMap: (id: string, force?: boolean) => Promise<RawSourceMap | undefined>;
|
|
1178
|
+
onFinished: (files: File[], errors?: unknown[]) => void;
|
|
1179
|
+
onWorkerExit: (code?: number) => void;
|
|
1180
|
+
onPathsCollected: (paths: string[]) => void;
|
|
1181
|
+
onUserConsoleLog: (log: UserConsoleLog) => void;
|
|
1182
|
+
onUnhandledRejection: (err: unknown) => void;
|
|
1183
|
+
onCollected: (files: File[]) => void;
|
|
1184
|
+
onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void;
|
|
1185
|
+
onTaskUpdate: (pack: TaskResultPack[]) => void;
|
|
1186
|
+
snapshotSaved: (snapshot: SnapshotResult) => void;
|
|
1187
|
+
resolveSnapshotPath: (testPath: string) => string;
|
|
1188
|
+
}
|
|
1189
|
+
interface WorkerGlobalState {
|
|
1190
|
+
ctx: WorkerContext;
|
|
1191
|
+
config: ResolvedConfig;
|
|
1192
|
+
rpc: BirpcReturn<WorkerRPC>;
|
|
1193
|
+
current?: Test;
|
|
1194
|
+
filepath?: string;
|
|
1195
|
+
moduleCache: ModuleCacheMap;
|
|
1196
|
+
browserHashMap?: Map<string, string>;
|
|
1197
|
+
mockMap: MockMap;
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
interface CoverageProvider {
|
|
1201
|
+
name: string;
|
|
1202
|
+
initialize(ctx: Vitest): Promise<void> | void;
|
|
1203
|
+
resolveOptions(): ResolvedCoverageOptions;
|
|
1204
|
+
clean(clean?: boolean): void | Promise<void>;
|
|
1205
|
+
onBeforeFilesRun?(): void | Promise<void>;
|
|
1206
|
+
onAfterSuiteRun(meta: AfterSuiteRunMeta): void | Promise<void>;
|
|
1207
|
+
reportCoverage(): void | Promise<void>;
|
|
1208
|
+
onFileTransform?(sourceCode: string, id: string, pluginCtx: TransformPluginContext): TransformResult | Promise<TransformResult>;
|
|
1209
|
+
}
|
|
1210
|
+
interface CoverageProviderModule {
|
|
1211
|
+
/**
|
|
1212
|
+
* Factory for creating a new coverage provider
|
|
1213
|
+
*/
|
|
1214
|
+
getProvider(): CoverageProvider | Promise<CoverageProvider>;
|
|
1215
|
+
/**
|
|
1216
|
+
* Executed on after each run in the worker thread. Possible to return a payload passed to the provider
|
|
1217
|
+
*/
|
|
1218
|
+
takeCoverage?(): unknown | Promise<unknown>;
|
|
1219
|
+
}
|
|
1220
|
+
declare type CoverageReporter = 'clover' | 'cobertura' | 'html-spa' | 'html' | 'json-summary' | 'json' | 'lcov' | 'lcovonly' | 'none' | 'teamcity' | 'text-lcov' | 'text-summary' | 'text';
|
|
1221
|
+
declare type CoverageOptions = BaseCoverageOptions & {
|
|
1222
|
+
provider?: null | CoverageProviderModule;
|
|
1223
|
+
} | CoverageC8Options & {
|
|
1224
|
+
provider?: 'c8';
|
|
1225
|
+
} | CoverageIstanbulOptions & {
|
|
1226
|
+
provider?: 'istanbul';
|
|
1227
|
+
};
|
|
1228
|
+
declare type ResolvedCoverageOptions = {
|
|
1229
|
+
tempDirectory: string;
|
|
1230
|
+
} & Required<CoverageOptions>;
|
|
1231
|
+
interface BaseCoverageOptions {
|
|
1232
|
+
/**
|
|
1233
|
+
* Enable coverage, pass `--coverage` to enable
|
|
1234
|
+
*
|
|
1235
|
+
* @default false
|
|
1236
|
+
*/
|
|
1237
|
+
enabled?: boolean;
|
|
1238
|
+
/**
|
|
1239
|
+
* Clean coverage before running tests
|
|
1240
|
+
*
|
|
1241
|
+
* @default true
|
|
1242
|
+
*/
|
|
1243
|
+
clean?: boolean;
|
|
1244
|
+
/**
|
|
1245
|
+
* Clean coverage report on watch rerun
|
|
1246
|
+
*
|
|
1247
|
+
* @default false
|
|
1248
|
+
*/
|
|
1249
|
+
cleanOnRerun?: boolean;
|
|
1250
|
+
/**
|
|
1251
|
+
* Directory to write coverage report to
|
|
1252
|
+
*/
|
|
1253
|
+
reportsDirectory?: string;
|
|
1254
|
+
/**
|
|
1255
|
+
* Reporters
|
|
1256
|
+
*
|
|
1257
|
+
* @default 'text'
|
|
1258
|
+
*/
|
|
1259
|
+
reporter?: Arrayable<CoverageReporter>;
|
|
1260
|
+
/**
|
|
1261
|
+
* List of files excluded from coverage as glob patterns
|
|
1262
|
+
*/
|
|
1263
|
+
exclude?: string[];
|
|
1264
|
+
/**
|
|
1265
|
+
* Do not show files with 100% statement, branch, and function coverage
|
|
1266
|
+
*/
|
|
1267
|
+
skipFull?: boolean;
|
|
1268
|
+
/**
|
|
1269
|
+
* Check thresholds per file
|
|
1270
|
+
*
|
|
1271
|
+
* @default false
|
|
1272
|
+
*/
|
|
1273
|
+
perFile?: boolean;
|
|
1274
|
+
/**
|
|
1275
|
+
* Threshold for lines
|
|
1276
|
+
*/
|
|
1277
|
+
lines?: number;
|
|
1278
|
+
/**
|
|
1279
|
+
* Threshold for functions
|
|
1280
|
+
*/
|
|
1281
|
+
functions?: number;
|
|
1282
|
+
/**
|
|
1283
|
+
* Threshold for branches
|
|
1284
|
+
*/
|
|
1285
|
+
branches?: number;
|
|
1286
|
+
/**
|
|
1287
|
+
* Threshold for statements
|
|
1288
|
+
*/
|
|
1289
|
+
statements?: number;
|
|
1290
|
+
/**
|
|
1291
|
+
* Extensions for files to be included in coverage
|
|
1292
|
+
*/
|
|
1293
|
+
extension?: string | string[];
|
|
1294
|
+
}
|
|
1295
|
+
interface CoverageIstanbulOptions extends BaseCoverageOptions {
|
|
1296
|
+
ignoreClassMethods?: string[];
|
|
1297
|
+
watermarks?: {
|
|
1298
|
+
statements?: [number, number];
|
|
1299
|
+
functions?: [number, number];
|
|
1300
|
+
branches?: [number, number];
|
|
1301
|
+
lines?: [number, number];
|
|
1302
|
+
};
|
|
1303
|
+
}
|
|
1304
|
+
interface CoverageC8Options extends BaseCoverageOptions {
|
|
1305
|
+
/**
|
|
1306
|
+
* Allow files from outside of your cwd.
|
|
1307
|
+
*
|
|
1308
|
+
* @default false
|
|
1309
|
+
*/
|
|
1310
|
+
allowExternal?: any;
|
|
1311
|
+
/**
|
|
1312
|
+
* Exclude coverage under /node_modules/
|
|
1313
|
+
*
|
|
1314
|
+
* @default true
|
|
1315
|
+
*/
|
|
1316
|
+
excludeNodeModules?: boolean;
|
|
1317
|
+
include?: string[];
|
|
1318
|
+
all?: boolean;
|
|
1319
|
+
src?: string[];
|
|
1320
|
+
100?: boolean;
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
interface JSDOMOptions {
|
|
1324
|
+
/**
|
|
1325
|
+
* The html content for the test.
|
|
1326
|
+
*
|
|
1327
|
+
* @default '<!DOCTYPE html>'
|
|
1328
|
+
*/
|
|
1329
|
+
html?: string | Buffer | ArrayBufferLike;
|
|
1330
|
+
/**
|
|
1331
|
+
* referrer just affects the value read from document.referrer.
|
|
1332
|
+
* It defaults to no referrer (which reflects as the empty string).
|
|
1333
|
+
*/
|
|
1334
|
+
referrer?: string;
|
|
1335
|
+
/**
|
|
1336
|
+
* userAgent affects the value read from navigator.userAgent, as well as the User-Agent header sent while fetching subresources.
|
|
1337
|
+
*
|
|
1338
|
+
* @default `Mozilla/5.0 (${process.platform}) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/${jsdomVersion}`
|
|
1339
|
+
*/
|
|
1340
|
+
userAgent?: string;
|
|
1341
|
+
/**
|
|
1342
|
+
* url sets the value returned by window.location, document.URL, and document.documentURI,
|
|
1343
|
+
* and affects things like resolution of relative URLs within the document
|
|
1344
|
+
* and the same-origin restrictions and referrer used while fetching subresources.
|
|
1345
|
+
*
|
|
1346
|
+
* @default 'http://localhost:3000'.
|
|
1347
|
+
*/
|
|
1348
|
+
url?: string;
|
|
1349
|
+
/**
|
|
1350
|
+
* contentType affects the value read from document.contentType, and how the document is parsed: as HTML or as XML.
|
|
1351
|
+
* Values that are not "text/html" or an XML mime type will throw.
|
|
1352
|
+
*
|
|
1353
|
+
* @default 'text/html'.
|
|
1354
|
+
*/
|
|
1355
|
+
contentType?: string;
|
|
1356
|
+
/**
|
|
1357
|
+
* The maximum size in code units for the separate storage areas used by localStorage and sessionStorage.
|
|
1358
|
+
* Attempts to store data larger than this limit will cause a DOMException to be thrown. By default, it is set
|
|
1359
|
+
* to 5,000,000 code units per origin, as inspired by the HTML specification.
|
|
1360
|
+
*
|
|
1361
|
+
* @default 5_000_000
|
|
1362
|
+
*/
|
|
1363
|
+
storageQuota?: number;
|
|
1364
|
+
/**
|
|
1365
|
+
* Enable console?
|
|
1366
|
+
*
|
|
1367
|
+
* @default false
|
|
1368
|
+
*/
|
|
1369
|
+
console?: boolean;
|
|
1370
|
+
/**
|
|
1371
|
+
* jsdom does not have the capability to render visual content, and will act like a headless browser by default.
|
|
1372
|
+
* It provides hints to web pages through APIs such as document.hidden that their content is not visible.
|
|
1373
|
+
*
|
|
1374
|
+
* When the `pretendToBeVisual` option is set to `true`, jsdom will pretend that it is rendering and displaying
|
|
1375
|
+
* content.
|
|
1376
|
+
*
|
|
1377
|
+
* @default true
|
|
1378
|
+
*/
|
|
1379
|
+
pretendToBeVisual?: boolean;
|
|
1380
|
+
/**
|
|
1381
|
+
* `includeNodeLocations` preserves the location info produced by the HTML parser,
|
|
1382
|
+
* allowing you to retrieve it with the nodeLocation() method (described below).
|
|
1383
|
+
*
|
|
1384
|
+
* It defaults to false to give the best performance,
|
|
1385
|
+
* and cannot be used with an XML content type since our XML parser does not support location info.
|
|
1386
|
+
*
|
|
1387
|
+
* @default false
|
|
1388
|
+
*/
|
|
1389
|
+
includeNodeLocations?: boolean | undefined;
|
|
1390
|
+
/**
|
|
1391
|
+
* @default 'dangerously'
|
|
1392
|
+
*/
|
|
1393
|
+
runScripts?: 'dangerously' | 'outside-only';
|
|
1394
|
+
/**
|
|
1395
|
+
* Enable CookieJar
|
|
1396
|
+
*
|
|
1397
|
+
* @default false
|
|
1398
|
+
*/
|
|
1399
|
+
cookieJar?: boolean;
|
|
1400
|
+
resources?: 'usable' | any;
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
interface Reporter {
|
|
1404
|
+
onInit?(ctx: Vitest): void;
|
|
1405
|
+
onPathsCollected?: (paths?: string[]) => Awaitable<void>;
|
|
1406
|
+
onCollected?: (files?: File[]) => Awaitable<void>;
|
|
1407
|
+
onFinished?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
|
|
1408
|
+
onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
|
|
1409
|
+
onTestRemoved?: (trigger?: string) => Awaitable<void>;
|
|
1410
|
+
onWatcherStart?: () => Awaitable<void>;
|
|
1411
|
+
onWatcherRerun?: (files: string[], trigger?: string) => Awaitable<void>;
|
|
1412
|
+
onServerRestart?: () => Awaitable<void>;
|
|
1413
|
+
onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1097
1416
|
declare type BuiltinEnvironment = 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime';
|
|
1098
1417
|
declare type ApiConfig = Pick<CommonServerOptions, 'port' | 'strictPort' | 'host'>;
|
|
1099
1418
|
|
|
@@ -1293,7 +1612,7 @@ interface InlineConfig {
|
|
|
1293
1612
|
/**
|
|
1294
1613
|
* Coverage options
|
|
1295
1614
|
*/
|
|
1296
|
-
coverage?:
|
|
1615
|
+
coverage?: CoverageOptions;
|
|
1297
1616
|
/**
|
|
1298
1617
|
* run test names with the specified pattern
|
|
1299
1618
|
*/
|
|
@@ -1380,7 +1699,7 @@ interface InlineConfig {
|
|
|
1380
1699
|
*/
|
|
1381
1700
|
allowOnly?: boolean;
|
|
1382
1701
|
/**
|
|
1383
|
-
* Show heap usage after each test.
|
|
1702
|
+
* Show heap usage after each test. Useful for debugging memory leaks.
|
|
1384
1703
|
*/
|
|
1385
1704
|
logHeapUsage?: boolean;
|
|
1386
1705
|
/**
|
|
@@ -1497,7 +1816,7 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'
|
|
|
1497
1816
|
filters?: string[];
|
|
1498
1817
|
testNamePattern?: RegExp;
|
|
1499
1818
|
related?: string[];
|
|
1500
|
-
coverage:
|
|
1819
|
+
coverage: ResolvedCoverageOptions;
|
|
1501
1820
|
snapshotOptions: SnapshotStateOptions;
|
|
1502
1821
|
reporters: (Reporter | BuiltinReporters)[];
|
|
1503
1822
|
defines: Record<string, any>;
|
|
@@ -1776,4 +2095,4 @@ declare global {
|
|
|
1776
2095
|
}
|
|
1777
2096
|
}
|
|
1778
2097
|
|
|
1779
|
-
export {
|
|
2098
|
+
export { Environment as $, ApiConfig as A, BuiltinEnvironment as B, WorkerRPC as C, DoneCallback as D, EnvironmentOptions as E, FakeTimerInstallOpts as F, WorkerGlobalState as G, HookListener as H, InlineConfig as I, JSDOMOptions as J, Awaitable as K, Arrayable as L, ModuleGraphData as M, Nullable as N, ArgumentsType$1 as O, MergeInsertions as P, DeepMerge as Q, ResolvedConfig as R, Suite as S, TaskResultPack as T, UserConfig as U, Vitest as V, WorkerContext as W, MutableArray as X, Constructable as Y, ModuleCache as Z, EnvironmentReturn as _, File as a, UserConsoleLog as a0, Position as a1, ParsedStack as a2, ErrorWithDiff as a3, CoverageProvider as a4, CoverageProviderModule as a5, CoverageReporter as a6, CoverageOptions as a7, ResolvedCoverageOptions as a8, BaseCoverageOptions as a9, CoverageIstanbulOptions as aa, CoverageC8Options as ab, ModuleCacheMap as ac, ViteNodeRunnerOptions as ad, MockMap as ae, ViteNodeRunner as af, TestSequencer as ag, startVitest as ah, TestSequencerConstructor as ai, Reporter as b, RunMode as c, TaskState as d, TaskBase as e, TaskResult as f, Test as g, Task as h, TestFunction as i, TestAPI as j, SuiteAPI as k, HookCleanupCallback as l, SuiteHooks as m, SuiteCollector as n, SuiteFactory as o, RuntimeContext as p, TestContext as q, SnapshotData as r, SnapshotUpdateState as s, SnapshotStateOptions as t, SnapshotMatchOptions as u, SnapshotResult as v, UncheckedSnapshot as w, SnapshotSummary as x, ResolveIdFunction as y, AfterSuiteRunMeta as z };
|