vitest 0.21.1 → 0.23.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 +61 -33
- package/dist/browser.d.ts +5 -5
- package/dist/browser.mjs +12 -10
- package/dist/{chunk-api-setup.7a6ba7fb.mjs → chunk-api-setup.5fc06d1d.mjs} +94 -91
- package/dist/chunk-constants.6196597b.mjs +284 -0
- package/dist/chunk-env-node.ceb43f1c.mjs +403 -0
- package/dist/{chunk-install-pkg.6c6dc0c2.mjs → chunk-install-pkg.e081fc1b.mjs} +2 -1
- package/dist/chunk-integrations-coverage.99c020eb.mjs +166 -0
- package/dist/{chunk-integrations-globals.44a8f047.mjs → chunk-integrations-globals.ef598c23.mjs} +8 -9
- package/dist/{chunk-magic-string.efe26975.mjs → chunk-magic-string.56b2b543.mjs} +30 -10
- package/dist/chunk-mock-date.0d86eaa5.mjs +332 -0
- package/dist/chunk-node-git.6f289b0a.mjs +84 -0
- package/dist/{chunk-runtime-chain.98d42d89.mjs → chunk-runtime-chain.2af36ddf.mjs} +507 -172
- package/dist/{chunk-runtime-error.87a2b5a2.mjs → chunk-runtime-error.ed9b4f70.mjs} +208 -76
- package/dist/{chunk-runtime-hooks.453f8858.mjs → chunk-runtime-hooks.75ce0575.mjs} +18 -12
- package/dist/{chunk-runtime-mocker.23b62bfa.mjs → chunk-runtime-mocker.fc76f21d.mjs} +18 -11
- package/dist/{chunk-runtime-rpc.b50ab560.mjs → chunk-runtime-rpc.3fe371e9.mjs} +1 -2
- package/dist/{chunk-utils-source-map.94107ee8.mjs → chunk-utils-source-map.70ee97e1.mjs} +11 -4
- package/dist/{chunk-vite-node-client.fdd9592c.mjs → chunk-vite-node-client.74ebe3d5.mjs} +97 -31
- package/dist/{chunk-vite-node-debug.09afb76f.mjs → chunk-vite-node-debug.2d8a1dc3.mjs} +3 -3
- package/dist/{chunk-vite-node-externalize.27aee038.mjs → chunk-vite-node-externalize.41bf722e.mjs} +644 -222
- package/dist/{chunk-vite-node-utils.f34df9d3.mjs → chunk-vite-node-utils.68573626.mjs} +60 -42
- package/dist/cli-wrapper.mjs +128 -0
- package/dist/cli.mjs +29 -20
- package/dist/config.cjs +5 -2
- package/dist/config.d.ts +8 -4
- package/dist/config.mjs +4 -3
- package/dist/entry.mjs +20 -15
- package/dist/environments.d.ts +23 -0
- package/dist/environments.mjs +3 -0
- package/dist/{global-60f880c6.d.ts → global-ea084c9f.d.ts} +627 -178
- package/dist/{index-4a906fa4.d.ts → index-5f09f4d0.d.ts} +3 -50
- package/dist/index.d.ts +6 -6
- package/dist/index.mjs +7 -6
- package/dist/loader.mjs +3 -3
- package/dist/node.d.ts +5 -4
- package/dist/node.mjs +19 -16
- package/dist/suite.mjs +6 -5
- package/dist/vendor-index.0557b03a.mjs +147 -0
- package/dist/vendor-index.13e3bda3.mjs +61 -0
- package/dist/{chunk-node-git.c2be9c49.mjs → vendor-index.4aeeb598.mjs} +4 -72
- package/dist/{vendor-index.61438b77.mjs → vendor-index.731a22f2.mjs} +1 -61
- package/dist/worker.mjs +20 -18
- package/package.json +19 -16
- package/vitest.mjs +1 -1
- package/dist/chunk-constants.26dc9f85.mjs +0 -38
- package/dist/chunk-defaults.02abff90.mjs +0 -680
- package/dist/chunk-mock-date.bc81a3ac.mjs +0 -555
- package/dist/chunk-utils-global.fa20c2f6.mjs +0 -5
- package/dist/mocker-5e2a8e41.d.ts +0 -3
|
@@ -1,5 +1,7 @@
|
|
|
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 { Options, TaskResult as TaskResult$1, Bench } from 'tinybench';
|
|
2
3
|
import { Stats } from 'fs';
|
|
4
|
+
import { MessagePort } from 'worker_threads';
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
@@ -237,9 +239,21 @@ interface ViteHotContext {
|
|
|
237
239
|
}
|
|
238
240
|
declare class ModuleCacheMap extends Map<string, ModuleCache$1> {
|
|
239
241
|
normalizePath(fsPath: string): string;
|
|
240
|
-
|
|
241
|
-
|
|
242
|
+
/**
|
|
243
|
+
* Assign partial data to the map
|
|
244
|
+
*/
|
|
245
|
+
update(fsPath: string, mod: Partial<ModuleCache$1>): this;
|
|
246
|
+
set(fsPath: string, mod: ModuleCache$1): this;
|
|
247
|
+
get(fsPath: string): ModuleCache$1;
|
|
242
248
|
delete(fsPath: string): boolean;
|
|
249
|
+
/**
|
|
250
|
+
* Invalidate modules that dependent on the given modules, up to the main entry
|
|
251
|
+
*/
|
|
252
|
+
invalidateDepTree(ids: string[] | Set<string>, invalidated?: Set<string>): Set<string>;
|
|
253
|
+
/**
|
|
254
|
+
* Invalidate dependency modules of the given modules, down to the bottom-level dependencies
|
|
255
|
+
*/
|
|
256
|
+
invalidateSubDepTree(ids: string[] | Set<string>, invalidated?: Set<string>): Set<string>;
|
|
243
257
|
}
|
|
244
258
|
declare class ViteNodeRunner {
|
|
245
259
|
options: ViteNodeRunnerOptions;
|
|
@@ -297,17 +311,21 @@ interface FetchResult {
|
|
|
297
311
|
}
|
|
298
312
|
declare type HotContext = Omit<ViteHotContext, 'acceptDeps' | 'decline'>;
|
|
299
313
|
declare type FetchFunction = (id: string) => Promise<FetchResult>;
|
|
300
|
-
declare type ResolveIdFunction = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
|
|
314
|
+
declare type ResolveIdFunction$1 = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
|
|
301
315
|
declare type CreateHotContextFunction = (runner: ViteNodeRunner, url: string) => HotContext;
|
|
302
316
|
interface ModuleCache$1 {
|
|
303
317
|
promise?: Promise<any>;
|
|
304
318
|
exports?: any;
|
|
305
319
|
code?: string;
|
|
320
|
+
/**
|
|
321
|
+
* Module ids that imports this module
|
|
322
|
+
*/
|
|
323
|
+
importers?: Set<string>;
|
|
306
324
|
}
|
|
307
325
|
interface ViteNodeRunnerOptions {
|
|
308
326
|
root: string;
|
|
309
327
|
fetchModule: FetchFunction;
|
|
310
|
-
resolveId?: ResolveIdFunction;
|
|
328
|
+
resolveId?: ResolveIdFunction$1;
|
|
311
329
|
createHotContext?: CreateHotContextFunction;
|
|
312
330
|
base?: string;
|
|
313
331
|
moduleCache?: ModuleCacheMap;
|
|
@@ -363,8 +381,8 @@ declare class Debugger {
|
|
|
363
381
|
clearDump(): Promise<void>;
|
|
364
382
|
encodeId(id: string): string;
|
|
365
383
|
recordExternalize(id: string, path: string): Promise<void>;
|
|
366
|
-
dumpFile(id: string, result: TransformResult | null): Promise<void>;
|
|
367
|
-
loadDump(id: string): Promise<TransformResult | null>;
|
|
384
|
+
dumpFile(id: string, result: TransformResult$1 | null): Promise<void>;
|
|
385
|
+
loadDump(id: string): Promise<TransformResult$1 | null>;
|
|
368
386
|
writeInfo(): Promise<void>;
|
|
369
387
|
}
|
|
370
388
|
|
|
@@ -374,6 +392,7 @@ declare class ViteNodeServer {
|
|
|
374
392
|
private fetchPromiseMap;
|
|
375
393
|
private transformPromiseMap;
|
|
376
394
|
fetchCache: Map<string, {
|
|
395
|
+
duration?: number | undefined;
|
|
377
396
|
timestamp: number;
|
|
378
397
|
result: FetchResult;
|
|
379
398
|
}>;
|
|
@@ -383,7 +402,7 @@ declare class ViteNodeServer {
|
|
|
383
402
|
shouldExternalize(id: string): Promise<string | false>;
|
|
384
403
|
resolveId(id: string, importer?: string): Promise<ViteNodeResolveId | null>;
|
|
385
404
|
fetchModule(id: string): Promise<FetchResult>;
|
|
386
|
-
transformRequest(id: string): Promise<TransformResult | null | undefined>;
|
|
405
|
+
transformRequest(id: string): Promise<TransformResult$1 | null | undefined>;
|
|
387
406
|
getTransformMode(id: string): "web" | "ssr";
|
|
388
407
|
private _fetchModule;
|
|
389
408
|
private _transformRequest;
|
|
@@ -483,7 +502,7 @@ interface CliOptions extends UserConfig {
|
|
|
483
502
|
*/
|
|
484
503
|
run?: boolean;
|
|
485
504
|
}
|
|
486
|
-
declare function startVitest(cliFilters: string[], options: CliOptions, viteOverrides?: UserConfig$1): Promise<boolean>;
|
|
505
|
+
declare function startVitest(mode: VitestRunMode, cliFilters: string[], options: CliOptions, viteOverrides?: UserConfig$1): Promise<boolean>;
|
|
487
506
|
|
|
488
507
|
declare type FileStatsCache = Pick<Stats, 'size'>;
|
|
489
508
|
declare class FilesStatsCache {
|
|
@@ -508,6 +527,7 @@ declare class VitestCache {
|
|
|
508
527
|
}
|
|
509
528
|
|
|
510
529
|
declare class Vitest {
|
|
530
|
+
readonly mode: VitestRunMode;
|
|
511
531
|
config: ResolvedConfig;
|
|
512
532
|
configOverride: Partial<ResolvedConfig> | undefined;
|
|
513
533
|
server: ViteDevServer;
|
|
@@ -515,6 +535,7 @@ declare class Vitest {
|
|
|
515
535
|
snapshot: SnapshotManager;
|
|
516
536
|
cache: VitestCache;
|
|
517
537
|
reporters: Reporter[];
|
|
538
|
+
coverageProvider: CoverageProvider | null | undefined;
|
|
518
539
|
logger: Logger;
|
|
519
540
|
pool: WorkerPool | undefined;
|
|
520
541
|
vitenode: ViteNodeServer;
|
|
@@ -525,9 +546,10 @@ declare class Vitest {
|
|
|
525
546
|
isFirstRun: boolean;
|
|
526
547
|
restartsCount: number;
|
|
527
548
|
runner: ViteNodeRunner;
|
|
528
|
-
constructor();
|
|
549
|
+
constructor(mode: VitestRunMode);
|
|
529
550
|
private _onRestartListeners;
|
|
530
551
|
setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
|
|
552
|
+
initCoverageProvider(): Promise<CoverageProvider | null | undefined>;
|
|
531
553
|
getSerializableConfig(): ResolvedConfig;
|
|
532
554
|
start(filters?: string[]): Promise<void>;
|
|
533
555
|
private getTestDependencies;
|
|
@@ -535,6 +557,7 @@ declare class Vitest {
|
|
|
535
557
|
runFiles(paths: string[]): Promise<void>;
|
|
536
558
|
rerunFiles(files?: string[], trigger?: string): Promise<void>;
|
|
537
559
|
changeNamePattern(pattern: string, files?: string[], trigger?: string): Promise<void>;
|
|
560
|
+
changeFilenamePattern(pattern: string): Promise<void>;
|
|
538
561
|
rerunFailed(): Promise<void>;
|
|
539
562
|
updateSnapshot(files?: string[]): Promise<void>;
|
|
540
563
|
private _rerunTimer;
|
|
@@ -547,13 +570,15 @@ declare class Vitest {
|
|
|
547
570
|
private handleFileChanged;
|
|
548
571
|
close(): Promise<void>;
|
|
549
572
|
exit(force?: boolean): Promise<void>;
|
|
550
|
-
report<T extends keyof Reporter>(name: T, ...args: ArgumentsType<Reporter[T]>): Promise<void>;
|
|
573
|
+
report<T extends keyof Reporter>(name: T, ...args: ArgumentsType$1<Reporter[T]>): Promise<void>;
|
|
551
574
|
globTestFiles(filters?: string[]): Promise<string[]>;
|
|
552
575
|
isTargetFile(id: string, source?: string): Promise<boolean>;
|
|
553
576
|
isInSourceTestFile(code: string): boolean;
|
|
554
|
-
|
|
577
|
+
onServerRestart(fn: OnServerRestartHandler): void;
|
|
555
578
|
}
|
|
556
579
|
|
|
580
|
+
declare type MockMap = Map<string, Record<string, string | null | (() => unknown)>>;
|
|
581
|
+
|
|
557
582
|
interface TestSequencer {
|
|
558
583
|
/**
|
|
559
584
|
* Slicing tests into shards. Will be run before `sort`.
|
|
@@ -587,7 +612,7 @@ declare abstract class BaseReporter implements Reporter {
|
|
|
587
612
|
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
588
613
|
onUserConsoleLog(log: UserConsoleLog): void;
|
|
589
614
|
shouldLog(log: UserConsoleLog): boolean;
|
|
590
|
-
onServerRestart(): void;
|
|
615
|
+
onServerRestart(reason?: string): void;
|
|
591
616
|
reportSummary(files: File[]): Promise<void>;
|
|
592
617
|
private printTaskErrors;
|
|
593
618
|
registerUnhandledRejection(): void;
|
|
@@ -631,7 +656,7 @@ interface Callsite {
|
|
|
631
656
|
line: number;
|
|
632
657
|
column: number;
|
|
633
658
|
}
|
|
634
|
-
declare class JsonReporter implements Reporter {
|
|
659
|
+
declare class JsonReporter$1 implements Reporter {
|
|
635
660
|
start: number;
|
|
636
661
|
ctx: Vitest;
|
|
637
662
|
onInit(ctx: Vitest): void;
|
|
@@ -643,7 +668,7 @@ declare class JsonReporter implements Reporter {
|
|
|
643
668
|
* @param report
|
|
644
669
|
*/
|
|
645
670
|
writeReport(report: string): Promise<void>;
|
|
646
|
-
protected getFailureLocation(test:
|
|
671
|
+
protected getFailureLocation(test: Task): Promise<Callsite | undefined>;
|
|
647
672
|
}
|
|
648
673
|
|
|
649
674
|
declare class VerboseReporter extends DefaultReporter {
|
|
@@ -679,21 +704,246 @@ declare class TapFlatReporter extends TapReporter {
|
|
|
679
704
|
onFinished(files?: File[]): Promise<void>;
|
|
680
705
|
}
|
|
681
706
|
|
|
707
|
+
declare class JsonReporter implements Reporter {
|
|
708
|
+
start: number;
|
|
709
|
+
ctx: Vitest;
|
|
710
|
+
onInit(ctx: Vitest): void;
|
|
711
|
+
protected logTasks(files: File[]): Promise<void>;
|
|
712
|
+
onFinished(files?: File[]): Promise<void>;
|
|
713
|
+
/**
|
|
714
|
+
* Writes the report to an output file if specified in the config,
|
|
715
|
+
* or logs it to the console otherwise.
|
|
716
|
+
* @param report
|
|
717
|
+
*/
|
|
718
|
+
writeReport(report: string): Promise<void>;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
declare const BenchmarkReportsMap: {
|
|
722
|
+
default: typeof VerboseReporter;
|
|
723
|
+
json: typeof JsonReporter;
|
|
724
|
+
};
|
|
725
|
+
declare type BenchmarkBuiltinReporters = keyof typeof BenchmarkReportsMap;
|
|
726
|
+
|
|
682
727
|
declare const ReportersMap: {
|
|
683
728
|
default: typeof DefaultReporter;
|
|
684
729
|
verbose: typeof VerboseReporter;
|
|
685
730
|
dot: typeof DotReporter;
|
|
686
|
-
json: typeof JsonReporter;
|
|
731
|
+
json: typeof JsonReporter$1;
|
|
687
732
|
tap: typeof TapReporter;
|
|
688
733
|
'tap-flat': typeof TapFlatReporter;
|
|
689
734
|
junit: typeof JUnitReporter;
|
|
690
735
|
};
|
|
691
736
|
declare type BuiltinReporters = keyof typeof ReportersMap;
|
|
692
737
|
|
|
738
|
+
interface RollupError extends RollupLogProps {
|
|
739
|
+
parserError?: Error;
|
|
740
|
+
stack?: string;
|
|
741
|
+
watchFiles?: string[];
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
interface RollupWarning extends RollupLogProps {
|
|
745
|
+
chunkName?: string;
|
|
746
|
+
cycle?: string[];
|
|
747
|
+
exportName?: string;
|
|
748
|
+
exporter?: string;
|
|
749
|
+
guess?: string;
|
|
750
|
+
importer?: string;
|
|
751
|
+
missing?: string;
|
|
752
|
+
modules?: string[];
|
|
753
|
+
names?: string[];
|
|
754
|
+
reexporter?: string;
|
|
755
|
+
source?: string;
|
|
756
|
+
sources?: string[];
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
interface RollupLogProps {
|
|
760
|
+
code?: string;
|
|
761
|
+
frame?: string;
|
|
762
|
+
hook?: string;
|
|
763
|
+
id?: string;
|
|
764
|
+
loc?: {
|
|
765
|
+
column: number;
|
|
766
|
+
file?: string;
|
|
767
|
+
line: number;
|
|
768
|
+
};
|
|
769
|
+
message: string;
|
|
770
|
+
name?: string;
|
|
771
|
+
plugin?: string;
|
|
772
|
+
pluginCode?: string;
|
|
773
|
+
pos?: number;
|
|
774
|
+
url?: string;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
interface ExistingRawSourceMap {
|
|
778
|
+
file?: string;
|
|
779
|
+
mappings: string;
|
|
780
|
+
names: string[];
|
|
781
|
+
sourceRoot?: string;
|
|
782
|
+
sources: string[];
|
|
783
|
+
sourcesContent?: string[];
|
|
784
|
+
version: number;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
interface SourceMap {
|
|
788
|
+
file: string;
|
|
789
|
+
mappings: string;
|
|
790
|
+
names: string[];
|
|
791
|
+
sources: string[];
|
|
792
|
+
sourcesContent: string[];
|
|
793
|
+
version: number;
|
|
794
|
+
toString(): string;
|
|
795
|
+
toUrl(): string;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
type SourceMapInput = ExistingRawSourceMap | string | null | { mappings: '' };
|
|
799
|
+
|
|
800
|
+
type PartialNull<T> = {
|
|
801
|
+
[P in keyof T]: T[P] | null;
|
|
802
|
+
};
|
|
803
|
+
|
|
804
|
+
interface ModuleOptions {
|
|
805
|
+
meta: CustomPluginOptions;
|
|
806
|
+
moduleSideEffects: boolean | 'no-treeshake';
|
|
807
|
+
syntheticNamedExports: boolean | string;
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
interface SourceDescription extends Partial<PartialNull<ModuleOptions>> {
|
|
811
|
+
ast?: AcornNode;
|
|
812
|
+
code: string;
|
|
813
|
+
map?: SourceMapInput;
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
interface PluginCache {
|
|
817
|
+
delete(id: string): boolean;
|
|
818
|
+
get<T = any>(id: string): T;
|
|
819
|
+
has(id: string): boolean;
|
|
820
|
+
set<T = any>(id: string, value: T): void;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
interface MinimalPluginContext {
|
|
824
|
+
meta: PluginContextMeta;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
interface EmittedAsset {
|
|
828
|
+
fileName?: string;
|
|
829
|
+
name?: string;
|
|
830
|
+
source?: string | Uint8Array;
|
|
831
|
+
type: 'asset';
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
interface EmittedChunk {
|
|
835
|
+
fileName?: string;
|
|
836
|
+
id: string;
|
|
837
|
+
implicitlyLoadedAfterOneOf?: string[];
|
|
838
|
+
importer?: string;
|
|
839
|
+
name?: string;
|
|
840
|
+
preserveSignature?: PreserveEntrySignaturesOption;
|
|
841
|
+
type: 'chunk';
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
type EmittedFile = EmittedAsset | EmittedChunk;
|
|
845
|
+
|
|
846
|
+
type EmitAsset = (name: string, source?: string | Uint8Array) => string;
|
|
847
|
+
|
|
848
|
+
type EmitChunk = (id: string, options?: { name?: string }) => string;
|
|
849
|
+
|
|
850
|
+
type EmitFile = (emittedFile: EmittedFile) => string;
|
|
851
|
+
|
|
852
|
+
interface ModuleInfo extends ModuleOptions {
|
|
853
|
+
ast: AcornNode | null;
|
|
854
|
+
code: string | null;
|
|
855
|
+
dynamicImporters: readonly string[];
|
|
856
|
+
dynamicallyImportedIdResolutions: readonly ResolvedId[];
|
|
857
|
+
dynamicallyImportedIds: readonly string[];
|
|
858
|
+
hasDefaultExport: boolean | null;
|
|
859
|
+
/** @deprecated Use `moduleSideEffects` instead */
|
|
860
|
+
hasModuleSideEffects: boolean | 'no-treeshake';
|
|
861
|
+
id: string;
|
|
862
|
+
implicitlyLoadedAfterOneOf: readonly string[];
|
|
863
|
+
implicitlyLoadedBefore: readonly string[];
|
|
864
|
+
importedIdResolutions: readonly ResolvedId[];
|
|
865
|
+
importedIds: readonly string[];
|
|
866
|
+
importers: readonly string[];
|
|
867
|
+
isEntry: boolean;
|
|
868
|
+
isExternal: boolean;
|
|
869
|
+
isIncluded: boolean | null;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
type GetModuleInfo = (moduleId: string) => ModuleInfo | null;
|
|
873
|
+
|
|
874
|
+
interface CustomPluginOptions {
|
|
875
|
+
[plugin: string]: any;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
interface PluginContext extends MinimalPluginContext {
|
|
879
|
+
addWatchFile: (id: string) => void;
|
|
880
|
+
cache: PluginCache;
|
|
881
|
+
/** @deprecated Use `this.emitFile` instead */
|
|
882
|
+
emitAsset: EmitAsset;
|
|
883
|
+
/** @deprecated Use `this.emitFile` instead */
|
|
884
|
+
emitChunk: EmitChunk;
|
|
885
|
+
emitFile: EmitFile;
|
|
886
|
+
error: (err: RollupError | string, pos?: number | { column: number; line: number }) => never;
|
|
887
|
+
/** @deprecated Use `this.getFileName` instead */
|
|
888
|
+
getAssetFileName: (assetReferenceId: string) => string;
|
|
889
|
+
/** @deprecated Use `this.getFileName` instead */
|
|
890
|
+
getChunkFileName: (chunkReferenceId: string) => string;
|
|
891
|
+
getFileName: (fileReferenceId: string) => string;
|
|
892
|
+
getModuleIds: () => IterableIterator<string>;
|
|
893
|
+
getModuleInfo: GetModuleInfo;
|
|
894
|
+
getWatchFiles: () => string[];
|
|
895
|
+
/** @deprecated Use `this.resolve` instead */
|
|
896
|
+
isExternal: IsExternal;
|
|
897
|
+
load: (
|
|
898
|
+
options: { id: string; resolveDependencies?: boolean } & Partial<PartialNull<ModuleOptions>>
|
|
899
|
+
) => Promise<ModuleInfo>;
|
|
900
|
+
/** @deprecated Use `this.getModuleIds` instead */
|
|
901
|
+
moduleIds: IterableIterator<string>;
|
|
902
|
+
parse: (input: string, options?: any) => AcornNode;
|
|
903
|
+
resolve: (
|
|
904
|
+
source: string,
|
|
905
|
+
importer?: string,
|
|
906
|
+
options?: { custom?: CustomPluginOptions; isEntry?: boolean; skipSelf?: boolean }
|
|
907
|
+
) => Promise<ResolvedId | null>;
|
|
908
|
+
/** @deprecated Use `this.resolve` instead */
|
|
909
|
+
resolveId: (source: string, importer?: string) => Promise<string | null>;
|
|
910
|
+
setAssetSource: (assetReferenceId: string, source: string | Uint8Array) => void;
|
|
911
|
+
warn: (warning: RollupWarning | string, pos?: number | { column: number; line: number }) => void;
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
interface PluginContextMeta {
|
|
915
|
+
rollupVersion: string;
|
|
916
|
+
watchMode: boolean;
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
interface ResolvedId extends ModuleOptions {
|
|
920
|
+
external: boolean | 'absolute';
|
|
921
|
+
id: string;
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
type IsExternal = (
|
|
925
|
+
source: string,
|
|
926
|
+
importer: string | undefined,
|
|
927
|
+
isResolved: boolean
|
|
928
|
+
) => boolean;
|
|
929
|
+
|
|
930
|
+
interface TransformPluginContext extends PluginContext {
|
|
931
|
+
getCombinedSourcemap: () => SourceMap;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
type TransformResult = string | null | void | Partial<SourceDescription>;
|
|
935
|
+
type PreserveEntrySignaturesOption = false | 'strict' | 'allow-extension' | 'exports-only';
|
|
936
|
+
|
|
937
|
+
interface AcornNode {
|
|
938
|
+
end: number;
|
|
939
|
+
start: number;
|
|
940
|
+
type: string;
|
|
941
|
+
}
|
|
942
|
+
|
|
693
943
|
declare type Awaitable<T> = T | PromiseLike<T>;
|
|
694
944
|
declare type Nullable<T> = T | null | undefined;
|
|
695
945
|
declare type Arrayable<T> = T | Array<T>;
|
|
696
|
-
declare type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never;
|
|
946
|
+
declare type ArgumentsType$1<T> = T extends (...args: infer U) => any ? U : never;
|
|
697
947
|
declare type MergeInsertions<T> = T extends object ? {
|
|
698
948
|
[K in keyof T]: MergeInsertions<T[K]>;
|
|
699
949
|
} : T;
|
|
@@ -754,156 +1004,73 @@ interface ModuleGraphData {
|
|
|
754
1004
|
externalized: string[];
|
|
755
1005
|
inlined: string[];
|
|
756
1006
|
}
|
|
1007
|
+
declare type OnServerRestartHandler = (reason?: string) => Promise<void> | void;
|
|
757
1008
|
|
|
758
|
-
declare type
|
|
759
|
-
|
|
1009
|
+
declare type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
|
|
1010
|
+
declare type ReturnType$1<T> = T extends (...args: any) => infer R ? R : never;
|
|
1011
|
+
declare type PromisifyFn<T> = ReturnType$1<T> extends Promise<any> ? T : (...args: ArgumentsType<T>) => Promise<Awaited<ReturnType$1<T>>>;
|
|
1012
|
+
declare type BirpcFn<T> = PromisifyFn<T> & {
|
|
760
1013
|
/**
|
|
761
|
-
*
|
|
762
|
-
*
|
|
763
|
-
* @default false
|
|
764
|
-
*/
|
|
765
|
-
enabled?: boolean;
|
|
766
|
-
/**
|
|
767
|
-
* Directory to write coverage report to
|
|
1014
|
+
* Send event without asking for response
|
|
768
1015
|
*/
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
1016
|
+
asEvent(...args: ArgumentsType<T>): void;
|
|
1017
|
+
};
|
|
1018
|
+
declare type BirpcReturn<RemoteFunctions> = {
|
|
1019
|
+
[K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]>;
|
|
1020
|
+
};
|
|
1021
|
+
|
|
1022
|
+
declare type ChainableFunction<T extends string, Args extends any[], R = any, E = {}> = {
|
|
1023
|
+
(...args: Args): R;
|
|
1024
|
+
} & {
|
|
1025
|
+
[x in T]: ChainableFunction<T, Args, R, E>;
|
|
1026
|
+
} & {
|
|
1027
|
+
fn: (this: Record<T, boolean | undefined>, ...args: Args) => R;
|
|
1028
|
+
} & E;
|
|
1029
|
+
|
|
1030
|
+
interface BenchmarkUserOptions {
|
|
782
1031
|
/**
|
|
783
|
-
*
|
|
1032
|
+
* Include globs for benchmark test files
|
|
784
1033
|
*
|
|
785
|
-
* @default
|
|
1034
|
+
* @default ['**\/*.{bench,benchmark}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}']
|
|
786
1035
|
*/
|
|
787
|
-
|
|
1036
|
+
include?: string[];
|
|
788
1037
|
/**
|
|
789
|
-
*
|
|
790
|
-
*
|
|
791
|
-
* @default false
|
|
1038
|
+
* Exclude globs for benchmark test files
|
|
1039
|
+
* @default ['node_modules', 'dist', '.idea', '.git', '.cache']
|
|
792
1040
|
*/
|
|
793
|
-
|
|
1041
|
+
exclude?: string[];
|
|
794
1042
|
/**
|
|
795
|
-
*
|
|
1043
|
+
* Include globs for in-source test files
|
|
796
1044
|
*
|
|
797
|
-
* @default
|
|
1045
|
+
* @default []
|
|
798
1046
|
*/
|
|
799
|
-
|
|
1047
|
+
includeSource?: string[];
|
|
800
1048
|
/**
|
|
801
|
-
*
|
|
802
|
-
*
|
|
803
|
-
* @default true
|
|
1049
|
+
* Custom reporter for output. Can contain one or more built-in report names, reporter instances,
|
|
1050
|
+
* and/or paths to custom reporters
|
|
804
1051
|
*/
|
|
805
|
-
|
|
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;
|
|
1052
|
+
reporters?: Arrayable<BenchmarkBuiltinReporters | Reporter>;
|
|
817
1053
|
}
|
|
818
|
-
interface
|
|
819
|
-
|
|
1054
|
+
interface Benchmark extends TaskBase {
|
|
1055
|
+
type: 'benchmark';
|
|
1056
|
+
suite: Suite;
|
|
1057
|
+
result?: TaskResult;
|
|
1058
|
+
fails?: boolean;
|
|
1059
|
+
options: Options;
|
|
820
1060
|
}
|
|
821
|
-
|
|
822
|
-
|
|
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;
|
|
1061
|
+
interface BenchmarkResult extends TaskResult$1 {
|
|
1062
|
+
name: string;
|
|
1063
|
+
rank: number;
|
|
900
1064
|
}
|
|
901
|
-
|
|
902
|
-
declare type ChainableFunction<
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
1065
|
+
declare type BenchFunction = (this: Bench) => Promise<void> | void;
|
|
1066
|
+
declare type BenchmarkAPI = ChainableFunction<'skip', [
|
|
1067
|
+
name: string,
|
|
1068
|
+
fn: BenchFunction,
|
|
1069
|
+
options?: Options
|
|
1070
|
+
], void> & {
|
|
1071
|
+
skipIf(condition: any): BenchmarkAPI;
|
|
1072
|
+
runIf(condition: any): BenchmarkAPI;
|
|
1073
|
+
};
|
|
907
1074
|
|
|
908
1075
|
declare type RunMode = 'run' | 'skip' | 'only' | 'todo';
|
|
909
1076
|
declare type TaskState = RunMode | 'pass' | 'fail';
|
|
@@ -916,6 +1083,7 @@ interface TaskBase {
|
|
|
916
1083
|
suite?: Suite;
|
|
917
1084
|
file?: File;
|
|
918
1085
|
result?: TaskResult;
|
|
1086
|
+
retry?: number;
|
|
919
1087
|
logs?: UserConsoleLog[];
|
|
920
1088
|
}
|
|
921
1089
|
interface TaskResult {
|
|
@@ -926,12 +1094,15 @@ interface TaskResult {
|
|
|
926
1094
|
error?: ErrorWithDiff;
|
|
927
1095
|
htmlError?: string;
|
|
928
1096
|
hooks?: Partial<Record<keyof SuiteHooks, TaskState>>;
|
|
1097
|
+
benchmark?: BenchmarkResult;
|
|
1098
|
+
retryCount?: number;
|
|
929
1099
|
}
|
|
930
1100
|
declare type TaskResultPack = [id: string, result: TaskResult | undefined];
|
|
931
1101
|
interface Suite extends TaskBase {
|
|
932
1102
|
type: 'suite';
|
|
933
1103
|
tasks: Task[];
|
|
934
1104
|
filepath?: string;
|
|
1105
|
+
benchmark?: Bench;
|
|
935
1106
|
}
|
|
936
1107
|
interface File extends Suite {
|
|
937
1108
|
filepath: string;
|
|
@@ -945,7 +1116,7 @@ interface Test<ExtraContext = {}> extends TaskBase {
|
|
|
945
1116
|
fails?: boolean;
|
|
946
1117
|
context: TestContext & ExtraContext;
|
|
947
1118
|
}
|
|
948
|
-
declare type Task = Test | Suite | File;
|
|
1119
|
+
declare type Task = Test | Suite | File | Benchmark;
|
|
949
1120
|
declare type DoneCallback = (error?: any) => void;
|
|
950
1121
|
declare type TestFunction<ExtraContext = {}> = (context: TestContext & ExtraContext) => Awaitable<any> | void;
|
|
951
1122
|
declare type ExtractEachCallbackArgs<T extends ReadonlyArray<any>> = {
|
|
@@ -967,18 +1138,31 @@ interface SuiteEachFunction {
|
|
|
967
1138
|
<T>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T[]) => Awaitable<void>) => void;
|
|
968
1139
|
}
|
|
969
1140
|
interface TestEachFunction {
|
|
970
|
-
<T extends any[] | [any]>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T) => Awaitable<void>,
|
|
971
|
-
<T extends ReadonlyArray<any>>(cases: ReadonlyArray<T>): (name: string, fn: (...args: ExtractEachCallbackArgs<T>) => Awaitable<void>,
|
|
972
|
-
<T>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T[]) => Awaitable<void>,
|
|
1141
|
+
<T extends any[] | [any]>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T) => Awaitable<void>, options?: number | TestOptions) => void;
|
|
1142
|
+
<T extends ReadonlyArray<any>>(cases: ReadonlyArray<T>): (name: string, fn: (...args: ExtractEachCallbackArgs<T>) => Awaitable<void>, options?: number | TestOptions) => void;
|
|
1143
|
+
<T>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T[]) => Awaitable<void>, options?: number | TestOptions) => void;
|
|
973
1144
|
}
|
|
974
1145
|
declare type ChainableTestAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo' | 'fails', [
|
|
975
1146
|
name: string,
|
|
976
1147
|
fn?: TestFunction<ExtraContext>,
|
|
977
|
-
|
|
1148
|
+
options?: number | TestOptions
|
|
978
1149
|
], void, {
|
|
979
1150
|
each: TestEachFunction;
|
|
980
|
-
<T extends ExtraContext>(name: string, fn?: TestFunction<T>,
|
|
1151
|
+
<T extends ExtraContext>(name: string, fn?: TestFunction<T>, options?: number | TestOptions): void;
|
|
981
1152
|
}>;
|
|
1153
|
+
interface TestOptions {
|
|
1154
|
+
/**
|
|
1155
|
+
* Test timeout.
|
|
1156
|
+
*/
|
|
1157
|
+
timeout?: number;
|
|
1158
|
+
/**
|
|
1159
|
+
* Times to retry the test if fails. Useful for making flaky tests more stable.
|
|
1160
|
+
* When retries is up, the last test error will be thrown.
|
|
1161
|
+
*
|
|
1162
|
+
* @default 1
|
|
1163
|
+
*/
|
|
1164
|
+
retry?: number;
|
|
1165
|
+
}
|
|
982
1166
|
declare type TestAPI<ExtraContext = {}> = ChainableTestAPI<ExtraContext> & {
|
|
983
1167
|
each: TestEachFunction;
|
|
984
1168
|
skipIf(condition: any): ChainableTestAPI<ExtraContext>;
|
|
@@ -1009,7 +1193,8 @@ interface SuiteCollector<ExtraContext = {}> {
|
|
|
1009
1193
|
readonly mode: RunMode;
|
|
1010
1194
|
type: 'collector';
|
|
1011
1195
|
test: TestAPI<ExtraContext>;
|
|
1012
|
-
|
|
1196
|
+
benchmark: BenchmarkAPI;
|
|
1197
|
+
tasks: (Suite | Test | Benchmark | SuiteCollector<ExtraContext>)[];
|
|
1013
1198
|
collect: (file?: File) => Promise<Suite>;
|
|
1014
1199
|
clear: () => void;
|
|
1015
1200
|
on: <T extends keyof SuiteHooks<ExtraContext>>(name: T, ...fn: SuiteHooks<ExtraContext>[T]) => void;
|
|
@@ -1034,19 +1219,6 @@ interface TestContext {
|
|
|
1034
1219
|
expect: Vi.ExpectStatic;
|
|
1035
1220
|
}
|
|
1036
1221
|
|
|
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
1222
|
declare type SnapshotData = Record<string, string>;
|
|
1051
1223
|
declare type SnapshotUpdateState = 'all' | 'new' | 'none';
|
|
1052
1224
|
interface SnapshotStateOptions {
|
|
@@ -1094,7 +1266,268 @@ interface SnapshotSummary {
|
|
|
1094
1266
|
updated: number;
|
|
1095
1267
|
}
|
|
1096
1268
|
|
|
1269
|
+
interface WorkerContext {
|
|
1270
|
+
workerId: number;
|
|
1271
|
+
port: MessagePort;
|
|
1272
|
+
config: ResolvedConfig;
|
|
1273
|
+
files: string[];
|
|
1274
|
+
invalidates?: string[];
|
|
1275
|
+
}
|
|
1276
|
+
declare type ResolveIdFunction = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
|
|
1277
|
+
interface AfterSuiteRunMeta {
|
|
1278
|
+
coverage?: unknown;
|
|
1279
|
+
}
|
|
1280
|
+
interface WorkerRPC {
|
|
1281
|
+
fetch: FetchFunction;
|
|
1282
|
+
resolveId: ResolveIdFunction;
|
|
1283
|
+
getSourceMap: (id: string, force?: boolean) => Promise<RawSourceMap | undefined>;
|
|
1284
|
+
onFinished: (files: File[], errors?: unknown[]) => void;
|
|
1285
|
+
onWorkerExit: (code?: number) => void;
|
|
1286
|
+
onPathsCollected: (paths: string[]) => void;
|
|
1287
|
+
onUserConsoleLog: (log: UserConsoleLog) => void;
|
|
1288
|
+
onUnhandledRejection: (err: unknown) => void;
|
|
1289
|
+
onCollected: (files: File[]) => void;
|
|
1290
|
+
onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void;
|
|
1291
|
+
onTaskUpdate: (pack: TaskResultPack[]) => void;
|
|
1292
|
+
snapshotSaved: (snapshot: SnapshotResult) => void;
|
|
1293
|
+
resolveSnapshotPath: (testPath: string) => string;
|
|
1294
|
+
}
|
|
1295
|
+
interface WorkerGlobalState {
|
|
1296
|
+
ctx: WorkerContext;
|
|
1297
|
+
config: ResolvedConfig;
|
|
1298
|
+
rpc: BirpcReturn<WorkerRPC>;
|
|
1299
|
+
current?: Test;
|
|
1300
|
+
filepath?: string;
|
|
1301
|
+
moduleCache: ModuleCacheMap;
|
|
1302
|
+
browserHashMap?: Map<string, string>;
|
|
1303
|
+
mockMap: MockMap;
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
interface CoverageProvider {
|
|
1307
|
+
name: string;
|
|
1308
|
+
initialize(ctx: Vitest): Promise<void> | void;
|
|
1309
|
+
resolveOptions(): ResolvedCoverageOptions;
|
|
1310
|
+
clean(clean?: boolean): void | Promise<void>;
|
|
1311
|
+
onBeforeFilesRun?(): void | Promise<void>;
|
|
1312
|
+
onAfterSuiteRun(meta: AfterSuiteRunMeta): void | Promise<void>;
|
|
1313
|
+
reportCoverage(): void | Promise<void>;
|
|
1314
|
+
onFileTransform?(sourceCode: string, id: string, pluginCtx: TransformPluginContext): TransformResult | Promise<TransformResult>;
|
|
1315
|
+
}
|
|
1316
|
+
interface CoverageProviderModule {
|
|
1317
|
+
/**
|
|
1318
|
+
* Factory for creating a new coverage provider
|
|
1319
|
+
*/
|
|
1320
|
+
getProvider(): CoverageProvider | Promise<CoverageProvider>;
|
|
1321
|
+
/**
|
|
1322
|
+
* Executed on after each run in the worker thread. Possible to return a payload passed to the provider
|
|
1323
|
+
*/
|
|
1324
|
+
takeCoverage?(): unknown | Promise<unknown>;
|
|
1325
|
+
}
|
|
1326
|
+
declare type CoverageReporter = 'clover' | 'cobertura' | 'html-spa' | 'html' | 'json-summary' | 'json' | 'lcov' | 'lcovonly' | 'none' | 'teamcity' | 'text-lcov' | 'text-summary' | 'text';
|
|
1327
|
+
declare type CoverageOptions = BaseCoverageOptions & {
|
|
1328
|
+
provider?: null | CoverageProviderModule;
|
|
1329
|
+
} | CoverageC8Options & {
|
|
1330
|
+
provider?: 'c8';
|
|
1331
|
+
} | CoverageIstanbulOptions & {
|
|
1332
|
+
provider?: 'istanbul';
|
|
1333
|
+
};
|
|
1334
|
+
declare type ResolvedCoverageOptions = {
|
|
1335
|
+
tempDirectory: string;
|
|
1336
|
+
} & Required<CoverageOptions>;
|
|
1337
|
+
interface BaseCoverageOptions {
|
|
1338
|
+
/**
|
|
1339
|
+
* Enable coverage, pass `--coverage` to enable
|
|
1340
|
+
*
|
|
1341
|
+
* @default false
|
|
1342
|
+
*/
|
|
1343
|
+
enabled?: boolean;
|
|
1344
|
+
/**
|
|
1345
|
+
* Clean coverage before running tests
|
|
1346
|
+
*
|
|
1347
|
+
* @default true
|
|
1348
|
+
*/
|
|
1349
|
+
clean?: boolean;
|
|
1350
|
+
/**
|
|
1351
|
+
* Clean coverage report on watch rerun
|
|
1352
|
+
*
|
|
1353
|
+
* @default false
|
|
1354
|
+
*/
|
|
1355
|
+
cleanOnRerun?: boolean;
|
|
1356
|
+
/**
|
|
1357
|
+
* Directory to write coverage report to
|
|
1358
|
+
*/
|
|
1359
|
+
reportsDirectory?: string;
|
|
1360
|
+
/**
|
|
1361
|
+
* Reporters
|
|
1362
|
+
*
|
|
1363
|
+
* @default 'text'
|
|
1364
|
+
*/
|
|
1365
|
+
reporter?: Arrayable<CoverageReporter>;
|
|
1366
|
+
/**
|
|
1367
|
+
* List of files included in coverage as glob patterns
|
|
1368
|
+
*/
|
|
1369
|
+
include?: string[];
|
|
1370
|
+
/**
|
|
1371
|
+
* List of files excluded from coverage as glob patterns
|
|
1372
|
+
*/
|
|
1373
|
+
exclude?: string[];
|
|
1374
|
+
/**
|
|
1375
|
+
* Do not show files with 100% statement, branch, and function coverage
|
|
1376
|
+
*/
|
|
1377
|
+
skipFull?: boolean;
|
|
1378
|
+
/**
|
|
1379
|
+
* Check thresholds per file
|
|
1380
|
+
*
|
|
1381
|
+
* @default false
|
|
1382
|
+
*/
|
|
1383
|
+
perFile?: boolean;
|
|
1384
|
+
/**
|
|
1385
|
+
* Threshold for lines
|
|
1386
|
+
*/
|
|
1387
|
+
lines?: number;
|
|
1388
|
+
/**
|
|
1389
|
+
* Threshold for functions
|
|
1390
|
+
*/
|
|
1391
|
+
functions?: number;
|
|
1392
|
+
/**
|
|
1393
|
+
* Threshold for branches
|
|
1394
|
+
*/
|
|
1395
|
+
branches?: number;
|
|
1396
|
+
/**
|
|
1397
|
+
* Threshold for statements
|
|
1398
|
+
*/
|
|
1399
|
+
statements?: number;
|
|
1400
|
+
/**
|
|
1401
|
+
* Extensions for files to be included in coverage
|
|
1402
|
+
*/
|
|
1403
|
+
extension?: string | string[];
|
|
1404
|
+
/**
|
|
1405
|
+
* Whether to include all files, including the untested ones into report
|
|
1406
|
+
*/
|
|
1407
|
+
all?: boolean;
|
|
1408
|
+
}
|
|
1409
|
+
interface CoverageIstanbulOptions extends BaseCoverageOptions {
|
|
1410
|
+
ignoreClassMethods?: string[];
|
|
1411
|
+
watermarks?: {
|
|
1412
|
+
statements?: [number, number];
|
|
1413
|
+
functions?: [number, number];
|
|
1414
|
+
branches?: [number, number];
|
|
1415
|
+
lines?: [number, number];
|
|
1416
|
+
};
|
|
1417
|
+
}
|
|
1418
|
+
interface CoverageC8Options extends BaseCoverageOptions {
|
|
1419
|
+
/**
|
|
1420
|
+
* Allow files from outside of your cwd.
|
|
1421
|
+
*
|
|
1422
|
+
* @default false
|
|
1423
|
+
*/
|
|
1424
|
+
allowExternal?: any;
|
|
1425
|
+
/**
|
|
1426
|
+
* Exclude coverage under /node_modules/
|
|
1427
|
+
*
|
|
1428
|
+
* @default true
|
|
1429
|
+
*/
|
|
1430
|
+
excludeNodeModules?: boolean;
|
|
1431
|
+
src?: string[];
|
|
1432
|
+
100?: boolean;
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
interface JSDOMOptions {
|
|
1436
|
+
/**
|
|
1437
|
+
* The html content for the test.
|
|
1438
|
+
*
|
|
1439
|
+
* @default '<!DOCTYPE html>'
|
|
1440
|
+
*/
|
|
1441
|
+
html?: string | Buffer | ArrayBufferLike;
|
|
1442
|
+
/**
|
|
1443
|
+
* referrer just affects the value read from document.referrer.
|
|
1444
|
+
* It defaults to no referrer (which reflects as the empty string).
|
|
1445
|
+
*/
|
|
1446
|
+
referrer?: string;
|
|
1447
|
+
/**
|
|
1448
|
+
* userAgent affects the value read from navigator.userAgent, as well as the User-Agent header sent while fetching subresources.
|
|
1449
|
+
*
|
|
1450
|
+
* @default `Mozilla/5.0 (${process.platform}) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/${jsdomVersion}`
|
|
1451
|
+
*/
|
|
1452
|
+
userAgent?: string;
|
|
1453
|
+
/**
|
|
1454
|
+
* url sets the value returned by window.location, document.URL, and document.documentURI,
|
|
1455
|
+
* and affects things like resolution of relative URLs within the document
|
|
1456
|
+
* and the same-origin restrictions and referrer used while fetching subresources.
|
|
1457
|
+
*
|
|
1458
|
+
* @default 'http://localhost:3000'.
|
|
1459
|
+
*/
|
|
1460
|
+
url?: string;
|
|
1461
|
+
/**
|
|
1462
|
+
* contentType affects the value read from document.contentType, and how the document is parsed: as HTML or as XML.
|
|
1463
|
+
* Values that are not "text/html" or an XML mime type will throw.
|
|
1464
|
+
*
|
|
1465
|
+
* @default 'text/html'.
|
|
1466
|
+
*/
|
|
1467
|
+
contentType?: string;
|
|
1468
|
+
/**
|
|
1469
|
+
* The maximum size in code units for the separate storage areas used by localStorage and sessionStorage.
|
|
1470
|
+
* Attempts to store data larger than this limit will cause a DOMException to be thrown. By default, it is set
|
|
1471
|
+
* to 5,000,000 code units per origin, as inspired by the HTML specification.
|
|
1472
|
+
*
|
|
1473
|
+
* @default 5_000_000
|
|
1474
|
+
*/
|
|
1475
|
+
storageQuota?: number;
|
|
1476
|
+
/**
|
|
1477
|
+
* Enable console?
|
|
1478
|
+
*
|
|
1479
|
+
* @default false
|
|
1480
|
+
*/
|
|
1481
|
+
console?: boolean;
|
|
1482
|
+
/**
|
|
1483
|
+
* jsdom does not have the capability to render visual content, and will act like a headless browser by default.
|
|
1484
|
+
* It provides hints to web pages through APIs such as document.hidden that their content is not visible.
|
|
1485
|
+
*
|
|
1486
|
+
* When the `pretendToBeVisual` option is set to `true`, jsdom will pretend that it is rendering and displaying
|
|
1487
|
+
* content.
|
|
1488
|
+
*
|
|
1489
|
+
* @default true
|
|
1490
|
+
*/
|
|
1491
|
+
pretendToBeVisual?: boolean;
|
|
1492
|
+
/**
|
|
1493
|
+
* `includeNodeLocations` preserves the location info produced by the HTML parser,
|
|
1494
|
+
* allowing you to retrieve it with the nodeLocation() method (described below).
|
|
1495
|
+
*
|
|
1496
|
+
* It defaults to false to give the best performance,
|
|
1497
|
+
* and cannot be used with an XML content type since our XML parser does not support location info.
|
|
1498
|
+
*
|
|
1499
|
+
* @default false
|
|
1500
|
+
*/
|
|
1501
|
+
includeNodeLocations?: boolean | undefined;
|
|
1502
|
+
/**
|
|
1503
|
+
* @default 'dangerously'
|
|
1504
|
+
*/
|
|
1505
|
+
runScripts?: 'dangerously' | 'outside-only';
|
|
1506
|
+
/**
|
|
1507
|
+
* Enable CookieJar
|
|
1508
|
+
*
|
|
1509
|
+
* @default false
|
|
1510
|
+
*/
|
|
1511
|
+
cookieJar?: boolean;
|
|
1512
|
+
resources?: 'usable' | any;
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
interface Reporter {
|
|
1516
|
+
onInit?(ctx: Vitest): void;
|
|
1517
|
+
onPathsCollected?: (paths?: string[]) => Awaitable<void>;
|
|
1518
|
+
onCollected?: (files?: File[]) => Awaitable<void>;
|
|
1519
|
+
onFinished?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
|
|
1520
|
+
onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
|
|
1521
|
+
onTestRemoved?: (trigger?: string) => Awaitable<void>;
|
|
1522
|
+
onWatcherStart?: () => Awaitable<void>;
|
|
1523
|
+
onWatcherRerun?: (files: string[], trigger?: string) => Awaitable<void>;
|
|
1524
|
+
onServerRestart?: (reason?: string) => Awaitable<void>;
|
|
1525
|
+
onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1097
1528
|
declare type BuiltinEnvironment = 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime';
|
|
1529
|
+
declare type VitestEnvironment = BuiltinEnvironment | (string & Record<never, never>);
|
|
1530
|
+
declare type CSSModuleScopeStrategy = 'stable' | 'scoped' | 'non-scoped';
|
|
1098
1531
|
declare type ApiConfig = Pick<CommonServerOptions, 'port' | 'strictPort' | 'host'>;
|
|
1099
1532
|
|
|
1100
1533
|
interface EnvironmentOptions {
|
|
@@ -1102,8 +1535,16 @@ interface EnvironmentOptions {
|
|
|
1102
1535
|
* jsdom options.
|
|
1103
1536
|
*/
|
|
1104
1537
|
jsdom?: JSDOMOptions;
|
|
1538
|
+
[x: string]: unknown;
|
|
1105
1539
|
}
|
|
1540
|
+
declare type VitestRunMode = 'test' | 'benchmark';
|
|
1106
1541
|
interface InlineConfig {
|
|
1542
|
+
/**
|
|
1543
|
+
* Benchmark options.
|
|
1544
|
+
*
|
|
1545
|
+
* @default {}
|
|
1546
|
+
*/
|
|
1547
|
+
benchmark?: BenchmarkUserOptions;
|
|
1107
1548
|
/**
|
|
1108
1549
|
* Include globs for test files
|
|
1109
1550
|
*
|
|
@@ -1179,9 +1620,11 @@ interface InlineConfig {
|
|
|
1179
1620
|
*
|
|
1180
1621
|
* Supports 'node', 'jsdom', 'happy-dom', 'edge-runtime'
|
|
1181
1622
|
*
|
|
1623
|
+
* If used unsupported string, will try to load the package `vitest-environment-${env}`
|
|
1624
|
+
*
|
|
1182
1625
|
* @default 'node'
|
|
1183
1626
|
*/
|
|
1184
|
-
environment?:
|
|
1627
|
+
environment?: VitestEnvironment;
|
|
1185
1628
|
/**
|
|
1186
1629
|
* Environment options.
|
|
1187
1630
|
*/
|
|
@@ -1293,7 +1736,7 @@ interface InlineConfig {
|
|
|
1293
1736
|
/**
|
|
1294
1737
|
* Coverage options
|
|
1295
1738
|
*/
|
|
1296
|
-
coverage?:
|
|
1739
|
+
coverage?: CoverageOptions;
|
|
1297
1740
|
/**
|
|
1298
1741
|
* run test names with the specified pattern
|
|
1299
1742
|
*/
|
|
@@ -1380,7 +1823,7 @@ interface InlineConfig {
|
|
|
1380
1823
|
*/
|
|
1381
1824
|
allowOnly?: boolean;
|
|
1382
1825
|
/**
|
|
1383
|
-
* Show heap usage after each test.
|
|
1826
|
+
* Show heap usage after each test. Useful for debugging memory leaks.
|
|
1384
1827
|
*/
|
|
1385
1828
|
logHeapUsage?: boolean;
|
|
1386
1829
|
/**
|
|
@@ -1402,11 +1845,14 @@ interface InlineConfig {
|
|
|
1402
1845
|
*
|
|
1403
1846
|
* When excluded, the CSS files will be replaced with empty strings to bypass the subsequent processing.
|
|
1404
1847
|
*
|
|
1405
|
-
* @default { include: [
|
|
1848
|
+
* @default { include: [], modules: { classNameStrategy: false } }
|
|
1406
1849
|
*/
|
|
1407
1850
|
css?: boolean | {
|
|
1408
1851
|
include?: RegExp | RegExp[];
|
|
1409
1852
|
exclude?: RegExp | RegExp[];
|
|
1853
|
+
modules?: {
|
|
1854
|
+
classNameStrategy?: CSSModuleScopeStrategy;
|
|
1855
|
+
};
|
|
1410
1856
|
};
|
|
1411
1857
|
/**
|
|
1412
1858
|
* A number of tests that are allowed to run at the same time marked with `test.concurrent`.
|
|
@@ -1491,17 +1937,19 @@ interface UserConfig extends InlineConfig {
|
|
|
1491
1937
|
*/
|
|
1492
1938
|
shard?: string;
|
|
1493
1939
|
}
|
|
1494
|
-
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'shard' | 'cache' | 'sequence'> {
|
|
1940
|
+
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'benchmark' | 'shard' | 'cache' | 'sequence'> {
|
|
1941
|
+
mode: VitestRunMode;
|
|
1495
1942
|
base?: string;
|
|
1496
1943
|
config?: string;
|
|
1497
1944
|
filters?: string[];
|
|
1498
1945
|
testNamePattern?: RegExp;
|
|
1499
1946
|
related?: string[];
|
|
1500
|
-
coverage:
|
|
1947
|
+
coverage: ResolvedCoverageOptions;
|
|
1501
1948
|
snapshotOptions: SnapshotStateOptions;
|
|
1502
1949
|
reporters: (Reporter | BuiltinReporters)[];
|
|
1503
1950
|
defines: Record<string, any>;
|
|
1504
1951
|
api?: ApiConfig;
|
|
1952
|
+
benchmark?: Required<BenchmarkUserOptions>;
|
|
1505
1953
|
shard?: {
|
|
1506
1954
|
index: number;
|
|
1507
1955
|
count: number;
|
|
@@ -1655,6 +2103,7 @@ interface MatcherState {
|
|
|
1655
2103
|
isExpectingAssertions?: boolean;
|
|
1656
2104
|
isExpectingAssertionsError?: Error | null;
|
|
1657
2105
|
isNot: boolean;
|
|
2106
|
+
environment: VitestEnvironment;
|
|
1658
2107
|
promise: string;
|
|
1659
2108
|
snapshotState: SnapshotState;
|
|
1660
2109
|
suppressedErrors: Array<Error>;
|
|
@@ -1776,4 +2225,4 @@ declare global {
|
|
|
1776
2225
|
}
|
|
1777
2226
|
}
|
|
1778
2227
|
|
|
1779
|
-
export {
|
|
2228
|
+
export { MutableArray as $, ApiConfig as A, BuiltinEnvironment as B, CSSModuleScopeStrategy as C, DoneCallback as D, EnvironmentOptions as E, FakeTimerInstallOpts as F, SnapshotSummary as G, HookListener as H, InlineConfig as I, JSDOMOptions as J, ResolveIdFunction as K, AfterSuiteRunMeta as L, ModuleGraphData as M, WorkerRPC as N, WorkerGlobalState as O, Awaitable as P, Nullable as Q, ResolvedConfig as R, Suite as S, TaskResultPack as T, UserConfig as U, VitestEnvironment as V, WorkerContext as W, Arrayable as X, ArgumentsType$1 as Y, MergeInsertions as Z, DeepMerge as _, File as a, Constructable as a0, ModuleCache as a1, EnvironmentReturn as a2, Environment as a3, UserConsoleLog as a4, Position as a5, ParsedStack as a6, ErrorWithDiff as a7, OnServerRestartHandler as a8, CoverageProvider as a9, CoverageProviderModule as aa, CoverageReporter as ab, CoverageOptions as ac, ResolvedCoverageOptions as ad, BaseCoverageOptions as ae, CoverageIstanbulOptions as af, CoverageC8Options as ag, BenchmarkUserOptions as ah, Benchmark as ai, BenchmarkResult as aj, BenchFunction as ak, BenchmarkAPI as al, ModuleCacheMap as am, ViteNodeRunnerOptions as an, MockMap as ao, ViteNodeRunner as ap, TestSequencer as aq, startVitest as ar, TestSequencerConstructor as as, Reporter as b, VitestRunMode as c, RunMode as d, TaskState as e, TaskBase as f, TaskResult as g, Test as h, Task as i, TestFunction as j, TestOptions as k, TestAPI as l, SuiteAPI as m, HookCleanupCallback as n, SuiteHooks as o, SuiteCollector as p, SuiteFactory as q, RuntimeContext as r, TestContext as s, Vitest as t, SnapshotData as u, SnapshotUpdateState as v, SnapshotStateOptions as w, SnapshotMatchOptions as x, SnapshotResult as y, UncheckedSnapshot as z };
|