1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245 |
- import { ViteDevServer, TransformResult as TransformResult$1, UserConfig as UserConfig$1, CommonServerOptions, AliasOptions } from 'vite';
- import { Task as Task$1, Options, TaskResult as TaskResult$1, Bench } from 'tinybench';
- import { Stats } from 'fs';
- import { MessagePort } from 'worker_threads';
- /**
- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
- declare type Colors = {
- comment: {
- close: string;
- open: string;
- };
- content: {
- close: string;
- open: string;
- };
- prop: {
- close: string;
- open: string;
- };
- tag: {
- close: string;
- open: string;
- };
- value: {
- close: string;
- open: string;
- };
- };
- declare type Indent = (arg0: string) => string;
- declare type Refs = Array<unknown>;
- declare type Print = (arg0: unknown) => string;
- declare type ThemeReceived = {
- comment?: string;
- content?: string;
- prop?: string;
- tag?: string;
- value?: string;
- };
- declare type CompareKeys = ((a: string, b: string) => number) | undefined;
- interface PrettyFormatOptions {
- callToJSON?: boolean;
- compareKeys?: CompareKeys;
- escapeRegex?: boolean;
- escapeString?: boolean;
- highlight?: boolean;
- indent?: number;
- maxDepth?: number;
- min?: boolean;
- plugins?: Plugins;
- printBasicPrototype?: boolean;
- printFunctionName?: boolean;
- theme?: ThemeReceived;
- }
- declare type OptionsReceived = PrettyFormatOptions;
- declare type Config = {
- callToJSON: boolean;
- compareKeys: CompareKeys;
- colors: Colors;
- escapeRegex: boolean;
- escapeString: boolean;
- indent: string;
- maxDepth: number;
- min: boolean;
- plugins: Plugins;
- printBasicPrototype: boolean;
- printFunctionName: boolean;
- spacingInner: string;
- spacingOuter: string;
- };
- declare type Printer = (val: unknown, config: Config, indentation: string, depth: number, refs: Refs, hasCalledToJSON?: boolean) => string;
- declare type Test$1 = (arg0: any) => boolean;
- declare type NewPlugin = {
- serialize: (val: any, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer) => string;
- test: Test$1;
- };
- declare type PluginOptions = {
- edgeSpacing: string;
- min: boolean;
- spacing: string;
- };
- declare type OldPlugin = {
- print: (val: unknown, print: Print, indent: Indent, options: PluginOptions, colors: Colors) => string;
- test: Test$1;
- };
- declare type Plugin = NewPlugin | OldPlugin;
- declare type Plugins = Array<Plugin>;
- // Type definitions for @sinonjs/fake-timers 8.1
- // Project: https://github.com/sinonjs/fake-timers
- // Definitions by: Wim Looman <https://github.com/Nemo157>
- // Rogier Schouten <https://github.com/rogierschouten>
- // Yishai Zehavi <https://github.com/zyishai>
- // Remco Haszing <https://github.com/remcohaszing>
- // Jaden Simon <https://github.com/JadenSimon>
- // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
- // TypeScript Version: 2.3
- /**
- * Names of clock methods that may be faked by install.
- */
- type FakeMethod =
- | 'setTimeout'
- | 'clearTimeout'
- | 'setImmediate'
- | 'clearImmediate'
- | 'setInterval'
- | 'clearInterval'
- | 'Date'
- | 'nextTick'
- | 'hrtime'
- | 'requestAnimationFrame'
- | 'cancelAnimationFrame'
- | 'requestIdleCallback'
- | 'cancelIdleCallback'
- | 'performance'
- | 'queueMicrotask';
- interface FakeTimerInstallOpts {
- /**
- * Installs fake timers with the specified unix epoch (default: 0)
- */
- now?: number | Date | undefined;
- /**
- * An array with names of global methods and APIs to fake. By default, `@sinonjs/fake-timers` does not replace `nextTick()` and `queueMicrotask()`.
- * For instance, `FakeTimers.install({ toFake: ['setTimeout', 'nextTick'] })` will fake only `setTimeout()` and `nextTick()`
- */
- toFake?: FakeMethod[] | undefined;
- /**
- * The maximum number of timers that will be run when calling runAll() (default: 1000)
- */
- loopLimit?: number | undefined;
- /**
- * Tells @sinonjs/fake-timers to increment mocked time automatically based on the real system time shift (e.g. the mocked time will be incremented by
- * 20ms for every 20ms change in the real system time) (default: false)
- */
- shouldAdvanceTime?: boolean | undefined;
- /**
- * Relevant only when using with shouldAdvanceTime: true. increment mocked time by advanceTimeDelta ms every advanceTimeDelta ms change
- * in the real system time (default: 20)
- */
- advanceTimeDelta?: number | undefined;
- /**
- * Tells FakeTimers to clear 'native' (i.e. not fake) timers by delegating to their respective handlers. These are not cleared by
- * default, leading to potentially unexpected behavior if timers existed prior to installing FakeTimers. (default: false)
- */
- shouldClearNativeTimers?: boolean | undefined;
- }
- interface UpdatePayload {
- type: 'update'
- updates: Update[]
- }
- interface Update {
- type: 'js-update' | 'css-update'
- path: string
- acceptedPath: string
- timestamp: number
- /**
- * @experimental internal
- */
- explicitImportRequired?: boolean | undefined
- }
- interface PrunePayload {
- type: 'prune'
- paths: string[]
- }
- interface FullReloadPayload {
- type: 'full-reload'
- path?: string
- }
- interface ErrorPayload {
- type: 'error'
- err: {
- [name: string]: any
- message: string
- stack: string
- id?: string
- frame?: string
- plugin?: string
- pluginCode?: string
- loc?: {
- file?: string
- line: number
- column: number
- }
- }
- }
- interface CustomEventMap {
- 'vite:beforeUpdate': UpdatePayload
- 'vite:beforePrune': PrunePayload
- 'vite:beforeFullReload': FullReloadPayload
- 'vite:error': ErrorPayload
- }
- type InferCustomEventPayload<T extends string> =
- T extends keyof CustomEventMap ? CustomEventMap[T] : any
- type ModuleNamespace = Record<string, any> & {
- [Symbol.toStringTag]: 'Module'
- }
- interface ViteHotContext {
- readonly data: any
- accept(): void
- accept(cb: (mod: ModuleNamespace | undefined) => void): void
- accept(dep: string, cb: (mod: ModuleNamespace | undefined) => void): void
- accept(
- deps: readonly string[],
- cb: (mods: Array<ModuleNamespace | undefined>) => void
- ): void
- acceptExports(exportNames: string | readonly string[]): void
- acceptExports(
- exportNames: string | readonly string[],
- cb: (mod: ModuleNamespace | undefined) => void
- ): void
- dispose(cb: (data: any) => void): void
- decline(): void
- invalidate(): void
- on<T extends string>(
- event: T,
- cb: (payload: InferCustomEventPayload<T>) => void
- ): void
- send<T extends string>(event: T, data?: InferCustomEventPayload<T>): void
- }
- declare class ModuleCacheMap extends Map<string, ModuleCache$1> {
- normalizePath(fsPath: string): string;
- /**
- * Assign partial data to the map
- */
- update(fsPath: string, mod: Partial<ModuleCache$1>): this;
- set(fsPath: string, mod: ModuleCache$1): this;
- get(fsPath: string): ModuleCache$1;
- delete(fsPath: string): boolean;
- /**
- * Invalidate modules that dependent on the given modules, up to the main entry
- */
- invalidateDepTree(ids: string[] | Set<string>, invalidated?: Set<string>): Set<string>;
- /**
- * Invalidate dependency modules of the given modules, down to the bottom-level dependencies
- */
- invalidateSubDepTree(ids: string[] | Set<string>, invalidated?: Set<string>): Set<string>;
- }
- declare class ViteNodeRunner {
- options: ViteNodeRunnerOptions;
- root: string;
- debug: boolean;
- /**
- * Holds the cache of modules
- * Keys of the map are filepaths, or plain package names
- */
- moduleCache: ModuleCacheMap;
- constructor(options: ViteNodeRunnerOptions);
- executeFile(file: string): Promise<any>;
- executeId(id: string): Promise<any>;
- /** @internal */
- cachedRequest(rawId: string, callstack: string[]): Promise<any>;
- /** @internal */
- directRequest(id: string, fsPath: string, _callstack: string[]): Promise<any>;
- prepareContext(context: Record<string, any>): Record<string, any>;
- shouldResolveId(dep: string): boolean;
- /**
- * Define if a module should be interop-ed
- * This function mostly for the ability to override by subclass
- */
- shouldInterop(path: string, mod: any): boolean;
- /**
- * Import a module and interop it
- */
- interopedImport(path: string): Promise<any>;
- hasNestedDefault(target: any): any;
- }
- interface DepsHandlingOptions {
- external?: (string | RegExp)[];
- inline?: (string | RegExp)[] | true;
- /**
- * Try to guess the CJS version of a package when it's invalid ESM
- * @default false
- */
- fallbackCJS?: boolean;
- }
- interface StartOfSourceMap {
- file?: string;
- sourceRoot?: string;
- }
- interface RawSourceMap extends StartOfSourceMap {
- version: string;
- sources: string[];
- names: string[];
- sourcesContent?: string[];
- mappings: string;
- }
- interface FetchResult {
- code?: string;
- externalize?: string;
- map?: RawSourceMap;
- }
- declare type HotContext = Omit<ViteHotContext, 'acceptDeps' | 'decline'>;
- declare type FetchFunction = (id: string) => Promise<FetchResult>;
- declare type ResolveIdFunction$1 = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
- declare type CreateHotContextFunction = (runner: ViteNodeRunner, url: string) => HotContext;
- interface ModuleCache$1 {
- promise?: Promise<any>;
- exports?: any;
- code?: string;
- /**
- * Module ids that imports this module
- */
- importers?: Set<string>;
- }
- interface ViteNodeRunnerOptions {
- root: string;
- fetchModule: FetchFunction;
- resolveId?: ResolveIdFunction$1;
- createHotContext?: CreateHotContextFunction;
- base?: string;
- moduleCache?: ModuleCacheMap;
- interopDefault?: boolean;
- requestStubs?: Record<string, any>;
- debug?: boolean;
- }
- interface ViteNodeResolveId {
- external?: boolean | 'absolute' | 'relative';
- id: string;
- meta?: Record<string, any> | null;
- moduleSideEffects?: boolean | 'no-treeshake' | null;
- syntheticNamedExports?: boolean | string | null;
- }
- interface ViteNodeServerOptions {
- /**
- * Inject inline sourcemap to modules
- * @default 'inline'
- */
- sourcemap?: 'inline' | boolean;
- /**
- * Deps handling
- */
- deps?: DepsHandlingOptions;
- /**
- * Transform method for modules
- */
- transformMode?: {
- ssr?: RegExp[];
- web?: RegExp[];
- };
- debug?: DebuggerOptions;
- }
- interface DebuggerOptions {
- /**
- * Dump the transformed module to filesystem
- * Passing a string will dump to the specified path
- */
- dumpModules?: boolean | string;
- /**
- * Read dumpped module from filesystem whenever exists.
- * Useful for debugging by modifying the dump result from the filesystem.
- */
- loadDumppedModules?: boolean;
- }
- declare class Debugger {
- options: DebuggerOptions;
- dumpDir: string | undefined;
- initPromise: Promise<void> | undefined;
- externalizeMap: Map<string, string>;
- constructor(root: string, options: DebuggerOptions);
- clearDump(): Promise<void>;
- encodeId(id: string): string;
- recordExternalize(id: string, path: string): Promise<void>;
- dumpFile(id: string, result: TransformResult$1 | null): Promise<void>;
- loadDump(id: string): Promise<TransformResult$1 | null>;
- writeInfo(): Promise<void>;
- }
- declare class ViteNodeServer {
- server: ViteDevServer;
- options: ViteNodeServerOptions;
- private fetchPromiseMap;
- private transformPromiseMap;
- fetchCache: Map<string, {
- duration?: number | undefined;
- timestamp: number;
- result: FetchResult;
- }>;
- externalizeCache: Map<string, Promise<string | false>>;
- debugger?: Debugger;
- constructor(server: ViteDevServer, options?: ViteNodeServerOptions);
- shouldExternalize(id: string): Promise<string | false>;
- resolveId(id: string, importer?: string): Promise<ViteNodeResolveId | null>;
- fetchModule(id: string): Promise<FetchResult>;
- transformRequest(id: string): Promise<TransformResult$1 | null | undefined>;
- getTransformMode(id: string): "web" | "ssr";
- private _fetchModule;
- private _transformRequest;
- }
- declare class SnapshotManager {
- options: SnapshotStateOptions;
- summary: SnapshotSummary;
- extension: string;
- constructor(options: SnapshotStateOptions);
- clear(): void;
- add(result: SnapshotResult): void;
- resolvePath(testPath: string): string;
- }
- declare type RunWithFiles = (files: string[], invalidates?: string[]) => Promise<void>;
- interface WorkerPool {
- runTests: RunWithFiles;
- close: () => Promise<void>;
- }
- interface CollectingPromise {
- promise: Promise<void>;
- resolve: () => void;
- }
- declare class StateManager {
- filesMap: Map<string, File>;
- pathsSet: Set<string>;
- collectingPromise: CollectingPromise | undefined;
- idMap: Map<string, Task>;
- taskFileMap: WeakMap<Task, File>;
- errorsSet: Set<unknown>;
- catchError(err: unknown, type: string): void;
- clearErrors(): void;
- getUnhandledErrors(): unknown[];
- startCollectingPaths(): void;
- finishCollectingPaths(): void;
- getPaths(): Promise<string[]>;
- getFiles(keys?: string[]): File[];
- getFilepaths(): string[];
- getFailedFilepaths(): string[];
- collectPaths(paths?: string[]): void;
- collectFiles(files?: File[]): void;
- clearFiles(paths?: string[]): void;
- updateId(task: Task): void;
- updateTasks(packs: TaskResultPack[]): void;
- updateUserLog(log: UserConsoleLog): void;
- }
- declare class Logger {
- ctx: Vitest;
- console: Console;
- outputStream: NodeJS.WriteStream & {
- fd: 1;
- };
- errorStream: NodeJS.WriteStream & {
- fd: 2;
- };
- logUpdate: ((...text: string[]) => void) & {
- clear(): void;
- done(): void;
- };
- private _clearScreenPending;
- constructor(ctx: Vitest, console?: Console);
- log(...args: any[]): void;
- error(...args: any[]): void;
- warn(...args: any[]): void;
- clearScreen(message: string, force?: boolean): void;
- private _clearScreen;
- printError(err: unknown, fullStack?: boolean, type?: string): Promise<void>;
- printNoTestFound(filters?: string[]): void;
- printBanner(): void;
- printUnhandledErrors(errors: unknown[]): Promise<void>;
- }
- interface SuiteResultCache {
- failed: boolean;
- duration: number;
- }
- declare class ResultsCache {
- private cache;
- private cachePath;
- private version;
- private root;
- getCachePath(): string | null;
- setConfig(root: string, config: ResolvedConfig['cache']): void;
- getResults(fsPath: string): SuiteResultCache | undefined;
- readFromCache(): Promise<void>;
- updateResults(files: File[]): void;
- removeFromCache(filepath: string): void;
- writeToCache(): Promise<void>;
- }
- interface CliOptions extends UserConfig {
- /**
- * Override the watch mode
- */
- run?: boolean;
- }
- declare function startVitest(mode: VitestRunMode, cliFilters: string[], options: CliOptions, viteOverrides?: UserConfig$1): Promise<boolean>;
- declare type FileStatsCache = Pick<Stats, 'size'>;
- declare class FilesStatsCache {
- cache: Map<string, FileStatsCache>;
- getStats(fsPath: string): FileStatsCache | undefined;
- updateStats(fsPath: string): Promise<void>;
- removeStats(fsPath: string): void;
- }
- declare class VitestCache {
- results: ResultsCache;
- stats: FilesStatsCache;
- getFileTestResults(id: string): SuiteResultCache | undefined;
- getFileStats(id: string): {
- size: number;
- } | undefined;
- static resolveCacheDir(root: string, dir: string | undefined): string;
- static clearCache(options: CliOptions): Promise<{
- dir: string;
- cleared: boolean;
- }>;
- }
- declare class Vitest {
- readonly mode: VitestRunMode;
- config: ResolvedConfig;
- configOverride: Partial<ResolvedConfig> | undefined;
- server: ViteDevServer;
- state: StateManager;
- snapshot: SnapshotManager;
- cache: VitestCache;
- reporters: Reporter[];
- coverageProvider: CoverageProvider | null | undefined;
- logger: Logger;
- pool: WorkerPool | undefined;
- vitenode: ViteNodeServer;
- invalidates: Set<string>;
- changedTests: Set<string>;
- runningPromise?: Promise<void>;
- closingPromise?: Promise<void>;
- isFirstRun: boolean;
- restartsCount: number;
- runner: ViteNodeRunner;
- constructor(mode: VitestRunMode);
- private _onRestartListeners;
- setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
- initCoverageProvider(): Promise<CoverageProvider | null | undefined>;
- getSerializableConfig(): ResolvedConfig;
- start(filters?: string[]): Promise<void>;
- private getTestDependencies;
- filterTestsBySource(tests: string[]): Promise<string[]>;
- runFiles(paths: string[]): Promise<void>;
- rerunFiles(files?: string[], trigger?: string): Promise<void>;
- changeNamePattern(pattern: string, files?: string[], trigger?: string): Promise<void>;
- changeFilenamePattern(pattern: string): Promise<void>;
- rerunFailed(): Promise<void>;
- updateSnapshot(files?: string[]): Promise<void>;
- private _rerunTimer;
- private scheduleRerun;
- private unregisterWatcher;
- private registerWatcher;
- /**
- * @returns A value indicating whether rerun is needed (changedTests was mutated)
- */
- private handleFileChanged;
- close(): Promise<void>;
- exit(force?: boolean): Promise<void>;
- report<T extends keyof Reporter>(name: T, ...args: ArgumentsType$1<Reporter[T]>): Promise<void>;
- globTestFiles(filters?: string[]): Promise<string[]>;
- isTargetFile(id: string, source?: string): Promise<boolean>;
- isInSourceTestFile(code: string): boolean;
- onServerRestart(fn: OnServerRestartHandler): void;
- }
- declare type MockMap = Map<string, Record<string, string | null | (() => unknown)>>;
- interface TestSequencer {
- /**
- * Slicing tests into shards. Will be run before `sort`.
- * Only run, if `shard` is defined.
- */
- shard(files: string[]): Awaitable<string[]>;
- sort(files: string[]): Awaitable<string[]>;
- }
- interface TestSequencerConstructor {
- new (ctx: Vitest): TestSequencer;
- }
- declare abstract class BaseReporter implements Reporter {
- start: number;
- end: number;
- watchFilters?: string[];
- isTTY: false;
- ctx: Vitest;
- private _filesInWatchMode;
- private _lastRunTimeout;
- private _lastRunTimer;
- private _lastRunCount;
- private _timeStart;
- constructor();
- get mode(): VitestRunMode;
- onInit(ctx: Vitest): void;
- relative(path: string): string;
- onFinished(files?: File[], errors?: unknown[]): Promise<void>;
- onTaskUpdate(packs: TaskResultPack[]): void;
- onWatcherStart(): Promise<void>;
- private resetLastRunLog;
- onWatcherRerun(files: string[], trigger?: string): Promise<void>;
- onUserConsoleLog(log: UserConsoleLog): void;
- shouldLog(log: UserConsoleLog): boolean;
- onServerRestart(reason?: string): void;
- reportSummary(files: File[]): Promise<void>;
- reportTestSummary(files: File[]): Promise<void>;
- private printErrorsSummary;
- reportBenchmarkSummary(files: File[]): Promise<void>;
- private printTaskErrors;
- registerUnhandledRejection(): void;
- }
- interface ListRendererOptions {
- renderSucceed?: boolean;
- logger: Logger;
- showHeap: boolean;
- }
- declare const createListRenderer: (_tasks: Task[], options: ListRendererOptions) => {
- start(): any;
- update(_tasks: Task[]): any;
- stop(): Promise<any>;
- clear(): void;
- };
- declare class DefaultReporter extends BaseReporter {
- renderer?: ReturnType<typeof createListRenderer>;
- rendererOptions: ListRendererOptions;
- onTestRemoved(trigger?: string): Promise<void>;
- onCollected(): void;
- onFinished(files?: File[], errors?: unknown[]): Promise<void>;
- onWatcherStart(): Promise<void>;
- stopListRender(): Promise<void>;
- onWatcherRerun(files: string[], trigger?: string): Promise<void>;
- onUserConsoleLog(log: UserConsoleLog): void;
- }
- declare class DotReporter extends BaseReporter {
- renderer?: ReturnType<typeof createListRenderer>;
- onCollected(): void;
- onFinished(files?: File[], errors?: unknown[]): Promise<void>;
- onWatcherStart(): Promise<void>;
- stopListRender(): Promise<void>;
- onWatcherRerun(files: string[], trigger?: string): Promise<void>;
- onUserConsoleLog(log: UserConsoleLog): void;
- }
- interface Callsite {
- line: number;
- column: number;
- }
- declare class JsonReporter$1 implements Reporter {
- start: number;
- ctx: Vitest;
- onInit(ctx: Vitest): void;
- protected logTasks(files: File[]): Promise<void>;
- onFinished(files?: File[]): Promise<void>;
- /**
- * Writes the report to an output file if specified in the config,
- * or logs it to the console otherwise.
- * @param report
- */
- writeReport(report: string): Promise<void>;
- protected getFailureLocation(test: Task): Promise<Callsite | undefined>;
- }
- declare class VerboseReporter extends DefaultReporter {
- constructor();
- onTaskUpdate(packs: TaskResultPack[]): void;
- }
- declare class TapReporter implements Reporter {
- protected ctx: Vitest;
- private logger;
- onInit(ctx: Vitest): void;
- static getComment(task: Task): string;
- private logErrorDetails;
- protected logTasks(tasks: Task[]): void;
- onFinished(files?: File[]): Promise<void>;
- }
- declare class JUnitReporter implements Reporter {
- private ctx;
- private reportFile?;
- private baseLog;
- private logger;
- onInit(ctx: Vitest): Promise<void>;
- writeElement(name: string, attrs: Record<string, any>, children: () => Promise<void>): Promise<void>;
- writeErrorDetails(error: ErrorWithDiff): Promise<void>;
- writeLogs(task: Task, type: 'err' | 'out'): Promise<void>;
- writeTasks(tasks: Task[], filename: string): Promise<void>;
- onFinished(files?: File[]): Promise<void>;
- }
- declare class TapFlatReporter extends TapReporter {
- onInit(ctx: Vitest): void;
- onFinished(files?: File[]): Promise<void>;
- }
- declare class JsonReporter implements Reporter {
- start: number;
- ctx: Vitest;
- onInit(ctx: Vitest): void;
- protected logTasks(files: File[]): Promise<void>;
- onFinished(files?: File[]): Promise<void>;
- /**
- * Writes the report to an output file if specified in the config,
- * or logs it to the console otherwise.
- * @param report
- */
- writeReport(report: string): Promise<void>;
- }
- declare const BenchmarkReportsMap: {
- default: typeof VerboseReporter;
- json: typeof JsonReporter;
- };
- declare type BenchmarkBuiltinReporters = keyof typeof BenchmarkReportsMap;
- declare const ReportersMap: {
- default: typeof DefaultReporter;
- verbose: typeof VerboseReporter;
- dot: typeof DotReporter;
- json: typeof JsonReporter$1;
- tap: typeof TapReporter;
- 'tap-flat': typeof TapFlatReporter;
- junit: typeof JUnitReporter;
- };
- declare type BuiltinReporters = keyof typeof ReportersMap;
- interface RollupError extends RollupLogProps {
- parserError?: Error;
- stack?: string;
- watchFiles?: string[];
- }
- interface RollupWarning extends RollupLogProps {
- chunkName?: string;
- cycle?: string[];
- exportName?: string;
- exporter?: string;
- guess?: string;
- importer?: string;
- missing?: string;
- modules?: string[];
- names?: string[];
- reexporter?: string;
- source?: string;
- sources?: string[];
- }
- interface RollupLogProps {
- code?: string;
- frame?: string;
- hook?: string;
- id?: string;
- loc?: {
- column: number;
- file?: string;
- line: number;
- };
- message: string;
- name?: string;
- plugin?: string;
- pluginCode?: string;
- pos?: number;
- url?: string;
- }
- interface ExistingRawSourceMap {
- file?: string;
- mappings: string;
- names: string[];
- sourceRoot?: string;
- sources: string[];
- sourcesContent?: string[];
- version: number;
- }
- interface SourceMap {
- file: string;
- mappings: string;
- names: string[];
- sources: string[];
- sourcesContent: string[];
- version: number;
- toString(): string;
- toUrl(): string;
- }
- type SourceMapInput = ExistingRawSourceMap | string | null | { mappings: '' };
- type PartialNull<T> = {
- [P in keyof T]: T[P] | null;
- };
- interface ModuleOptions {
- meta: CustomPluginOptions;
- moduleSideEffects: boolean | 'no-treeshake';
- syntheticNamedExports: boolean | string;
- }
- interface SourceDescription extends Partial<PartialNull<ModuleOptions>> {
- ast?: AcornNode;
- code: string;
- map?: SourceMapInput;
- }
- interface PluginCache {
- delete(id: string): boolean;
- get<T = any>(id: string): T;
- has(id: string): boolean;
- set<T = any>(id: string, value: T): void;
- }
- interface MinimalPluginContext {
- meta: PluginContextMeta;
- }
- interface EmittedAsset {
- fileName?: string;
- name?: string;
- source?: string | Uint8Array;
- type: 'asset';
- }
- interface EmittedChunk {
- fileName?: string;
- id: string;
- implicitlyLoadedAfterOneOf?: string[];
- importer?: string;
- name?: string;
- preserveSignature?: PreserveEntrySignaturesOption;
- type: 'chunk';
- }
- type EmittedFile = EmittedAsset | EmittedChunk;
- type EmitAsset = (name: string, source?: string | Uint8Array) => string;
- type EmitChunk = (id: string, options?: { name?: string }) => string;
- type EmitFile = (emittedFile: EmittedFile) => string;
- interface ModuleInfo extends ModuleOptions {
- ast: AcornNode | null;
- code: string | null;
- dynamicImporters: readonly string[];
- dynamicallyImportedIdResolutions: readonly ResolvedId[];
- dynamicallyImportedIds: readonly string[];
- hasDefaultExport: boolean | null;
- /** @deprecated Use `moduleSideEffects` instead */
- hasModuleSideEffects: boolean | 'no-treeshake';
- id: string;
- implicitlyLoadedAfterOneOf: readonly string[];
- implicitlyLoadedBefore: readonly string[];
- importedIdResolutions: readonly ResolvedId[];
- importedIds: readonly string[];
- importers: readonly string[];
- isEntry: boolean;
- isExternal: boolean;
- isIncluded: boolean | null;
- }
- type GetModuleInfo = (moduleId: string) => ModuleInfo | null;
- interface CustomPluginOptions {
- [plugin: string]: any;
- }
- interface PluginContext extends MinimalPluginContext {
- addWatchFile: (id: string) => void;
- cache: PluginCache;
- /** @deprecated Use `this.emitFile` instead */
- emitAsset: EmitAsset;
- /** @deprecated Use `this.emitFile` instead */
- emitChunk: EmitChunk;
- emitFile: EmitFile;
- error: (err: RollupError | string, pos?: number | { column: number; line: number }) => never;
- /** @deprecated Use `this.getFileName` instead */
- getAssetFileName: (assetReferenceId: string) => string;
- /** @deprecated Use `this.getFileName` instead */
- getChunkFileName: (chunkReferenceId: string) => string;
- getFileName: (fileReferenceId: string) => string;
- getModuleIds: () => IterableIterator<string>;
- getModuleInfo: GetModuleInfo;
- getWatchFiles: () => string[];
- /** @deprecated Use `this.resolve` instead */
- isExternal: IsExternal;
- load: (
- options: { id: string; resolveDependencies?: boolean } & Partial<PartialNull<ModuleOptions>>
- ) => Promise<ModuleInfo>;
- /** @deprecated Use `this.getModuleIds` instead */
- moduleIds: IterableIterator<string>;
- parse: (input: string, options?: any) => AcornNode;
- resolve: (
- source: string,
- importer?: string,
- options?: { custom?: CustomPluginOptions; isEntry?: boolean; skipSelf?: boolean }
- ) => Promise<ResolvedId | null>;
- /** @deprecated Use `this.resolve` instead */
- resolveId: (source: string, importer?: string) => Promise<string | null>;
- setAssetSource: (assetReferenceId: string, source: string | Uint8Array) => void;
- warn: (warning: RollupWarning | string, pos?: number | { column: number; line: number }) => void;
- }
- interface PluginContextMeta {
- rollupVersion: string;
- watchMode: boolean;
- }
- interface ResolvedId extends ModuleOptions {
- external: boolean | 'absolute';
- id: string;
- }
- type IsExternal = (
- source: string,
- importer: string | undefined,
- isResolved: boolean
- ) => boolean;
- interface TransformPluginContext extends PluginContext {
- getCombinedSourcemap: () => SourceMap;
- }
- type TransformResult = string | null | void | Partial<SourceDescription>;
- type PreserveEntrySignaturesOption = false | 'strict' | 'allow-extension' | 'exports-only';
- interface AcornNode {
- end: number;
- start: number;
- type: string;
- }
- declare type Awaitable<T> = T | PromiseLike<T>;
- declare type Nullable<T> = T | null | undefined;
- declare type Arrayable<T> = T | Array<T>;
- declare type ArgumentsType$1<T> = T extends (...args: infer U) => any ? U : never;
- declare type MergeInsertions<T> = T extends object ? {
- [K in keyof T]: MergeInsertions<T[K]>;
- } : T;
- declare type DeepMerge<F, S> = MergeInsertions<{
- [K in keyof F | keyof S]: K extends keyof S & keyof F ? DeepMerge<F[K], S[K]> : K extends keyof S ? S[K] : K extends keyof F ? F[K] : never;
- }>;
- declare type MutableArray<T extends readonly any[]> = {
- -readonly [k in keyof T]: T[k];
- };
- interface Constructable {
- new (...args: any[]): any;
- }
- interface ModuleCache {
- promise?: Promise<any>;
- exports?: any;
- code?: string;
- }
- interface EnvironmentReturn {
- teardown: (global: any) => Awaitable<void>;
- }
- interface Environment {
- name: string;
- setup(global: any, options: Record<string, any>): Awaitable<EnvironmentReturn>;
- }
- interface UserConsoleLog {
- content: string;
- type: 'stdout' | 'stderr';
- taskId?: string;
- time: number;
- size: number;
- }
- interface Position {
- source?: string;
- line: number;
- column: number;
- }
- interface ParsedStack {
- method: string;
- file: string;
- line: number;
- column: number;
- sourcePos?: Position;
- }
- interface ErrorWithDiff extends Error {
- name: string;
- nameStr?: string;
- stack?: string;
- stackStr?: string;
- stacks?: ParsedStack[];
- showDiff?: boolean;
- actual?: any;
- expected?: any;
- operator?: string;
- type?: string;
- }
- interface ModuleGraphData {
- graph: Record<string, string[]>;
- externalized: string[];
- inlined: string[];
- }
- declare type OnServerRestartHandler = (reason?: string) => Promise<void> | void;
- declare type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
- declare type ReturnType$1<T> = T extends (...args: any) => infer R ? R : never;
- declare type PromisifyFn<T> = ReturnType$1<T> extends Promise<any> ? T : (...args: ArgumentsType<T>) => Promise<Awaited<ReturnType$1<T>>>;
- declare type BirpcFn<T> = PromisifyFn<T> & {
- /**
- * Send event without asking for response
- */
- asEvent(...args: ArgumentsType<T>): void;
- };
- declare type BirpcReturn<RemoteFunctions> = {
- [K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]>;
- };
- declare type ChainableFunction<T extends string, Args extends any[], R = any, E = {}> = {
- (...args: Args): R;
- } & {
- [x in T]: ChainableFunction<T, Args, R, E>;
- } & {
- fn: (this: Record<T, boolean | undefined>, ...args: Args) => R;
- } & E;
- interface BenchmarkUserOptions {
- /**
- * Include globs for benchmark test files
- *
- * @default ['**\/*.{bench,benchmark}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}']
- */
- include?: string[];
- /**
- * Exclude globs for benchmark test files
- * @default ['node_modules', 'dist', '.idea', '.git', '.cache']
- */
- exclude?: string[];
- /**
- * Include globs for in-source benchmark test files
- *
- * @default []
- */
- includeSource?: string[];
- /**
- * Custom reporter for output. Can contain one or more built-in report names, reporter instances,
- * and/or paths to custom reporters
- */
- reporters?: Arrayable<BenchmarkBuiltinReporters | Reporter>;
- /**
- * Write test results to a file when the `--reporter=json` option is also specified.
- * Also definable individually per reporter by using an object instead.
- */
- outputFile?: string | (Partial<Record<BenchmarkBuiltinReporters, string>> & Record<string, string>);
- }
- interface Benchmark extends TaskBase {
- type: 'benchmark';
- suite: Suite;
- result?: TaskResult;
- fails?: boolean;
- task?: Task$1;
- options: Options;
- }
- interface BenchmarkResult extends TaskResult$1 {
- name: string;
- rank: number;
- }
- declare type BenchFunction = (this: Bench) => Promise<void> | void;
- declare type BenchmarkAPI = ChainableFunction<'skip' | 'only', [
- name: string,
- fn: BenchFunction,
- options?: Options
- ], void> & {
- skipIf(condition: any): BenchmarkAPI;
- runIf(condition: any): BenchmarkAPI;
- };
- declare type RunMode = 'run' | 'skip' | 'only' | 'todo';
- declare type TaskState = RunMode | 'pass' | 'fail';
- interface TaskBase {
- id: string;
- name: string;
- mode: RunMode;
- concurrent?: boolean;
- shuffle?: boolean;
- suite?: Suite;
- file?: File;
- result?: TaskResult;
- retry?: number;
- logs?: UserConsoleLog[];
- }
- interface TaskResult {
- state: TaskState;
- duration?: number;
- startTime?: number;
- heap?: number;
- error?: ErrorWithDiff;
- htmlError?: string;
- hooks?: Partial<Record<keyof SuiteHooks, TaskState>>;
- benchmark?: BenchmarkResult;
- retryCount?: number;
- }
- declare type TaskResultPack = [id: string, result: TaskResult | undefined];
- interface Suite extends TaskBase {
- type: 'suite';
- tasks: Task[];
- filepath?: string;
- benchmark?: Bench;
- }
- interface File extends Suite {
- filepath: string;
- collectDuration?: number;
- setupDuration?: number;
- }
- interface Test<ExtraContext = {}> extends TaskBase {
- type: 'test';
- suite: Suite;
- result?: TaskResult;
- fails?: boolean;
- context: TestContext & ExtraContext;
- }
- declare type Task = Test | Suite | File | Benchmark;
- declare type DoneCallback = (error?: any) => void;
- declare type TestFunction<ExtraContext = {}> = (context: TestContext & ExtraContext) => Awaitable<any> | void;
- declare type ExtractEachCallbackArgs<T extends ReadonlyArray<any>> = {
- 1: [T[0]];
- 2: [T[0], T[1]];
- 3: [T[0], T[1], T[2]];
- 4: [T[0], T[1], T[2], T[3]];
- 5: [T[0], T[1], T[2], T[3], T[4]];
- 6: [T[0], T[1], T[2], T[3], T[4], T[5]];
- 7: [T[0], T[1], T[2], T[3], T[4], T[5], T[6]];
- 8: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7]];
- 9: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7], T[8]];
- 10: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7], T[8], T[9]];
- fallback: Array<T extends ReadonlyArray<infer U> ? U : any>;
- }[T extends Readonly<[any]> ? 1 : T extends Readonly<[any, any]> ? 2 : T extends Readonly<[any, any, any]> ? 3 : T extends Readonly<[any, any, any, any]> ? 4 : T extends Readonly<[any, any, any, any, any]> ? 5 : T extends Readonly<[any, any, any, any, any, any]> ? 6 : T extends Readonly<[any, any, any, any, any, any, any]> ? 7 : T extends Readonly<[any, any, any, any, any, any, any, any]> ? 8 : T extends Readonly<[any, any, any, any, any, any, any, any, any]> ? 9 : T extends Readonly<[any, any, any, any, any, any, any, any, any, any]> ? 10 : 'fallback'];
- interface SuiteEachFunction {
- <T extends any[] | [any]>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T) => Awaitable<void>) => void;
- <T extends ReadonlyArray<any>>(cases: ReadonlyArray<T>): (name: string, fn: (...args: ExtractEachCallbackArgs<T>) => Awaitable<void>) => void;
- <T>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T[]) => Awaitable<void>) => void;
- }
- interface TestEachFunction {
- <T extends any[] | [any]>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T) => Awaitable<void>, options?: number | TestOptions) => void;
- <T extends ReadonlyArray<any>>(cases: ReadonlyArray<T>): (name: string, fn: (...args: ExtractEachCallbackArgs<T>) => Awaitable<void>, options?: number | TestOptions) => void;
- <T>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T[]) => Awaitable<void>, options?: number | TestOptions) => void;
- }
- declare type ChainableTestAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo' | 'fails', [
- name: string,
- fn?: TestFunction<ExtraContext>,
- options?: number | TestOptions
- ], void, {
- each: TestEachFunction;
- <T extends ExtraContext>(name: string, fn?: TestFunction<T>, options?: number | TestOptions): void;
- }>;
- interface TestOptions {
- /**
- * Test timeout.
- */
- timeout?: number;
- /**
- * Times to retry the test if fails. Useful for making flaky tests more stable.
- * When retries is up, the last test error will be thrown.
- *
- * @default 1
- */
- retry?: number;
- }
- declare type TestAPI<ExtraContext = {}> = ChainableTestAPI<ExtraContext> & {
- each: TestEachFunction;
- skipIf(condition: any): ChainableTestAPI<ExtraContext>;
- runIf(condition: any): ChainableTestAPI<ExtraContext>;
- };
- declare type ChainableSuiteAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo' | 'shuffle', [
- name: string,
- factory?: SuiteFactory<ExtraContext>,
- options?: number | TestOptions
- ], SuiteCollector<ExtraContext>, {
- each: TestEachFunction;
- <T extends ExtraContext>(name: string, factory?: SuiteFactory<T>): SuiteCollector<T>;
- }>;
- declare type SuiteAPI<ExtraContext = {}> = ChainableSuiteAPI<ExtraContext> & {
- each: SuiteEachFunction;
- skipIf(condition: any): ChainableSuiteAPI<ExtraContext>;
- runIf(condition: any): ChainableSuiteAPI<ExtraContext>;
- };
- declare type HookListener<T extends any[], Return = void> = (...args: T) => Awaitable<Return>;
- declare type HookCleanupCallback = (() => Awaitable<unknown>) | void;
- interface SuiteHooks<ExtraContext = {}> {
- beforeAll: HookListener<[Suite | File], HookCleanupCallback>[];
- afterAll: HookListener<[Suite | File]>[];
- beforeEach: HookListener<[TestContext & ExtraContext, Suite], HookCleanupCallback>[];
- afterEach: HookListener<[TestContext & ExtraContext, Suite]>[];
- }
- interface SuiteCollector<ExtraContext = {}> {
- readonly name: string;
- readonly mode: RunMode;
- type: 'collector';
- test: TestAPI<ExtraContext>;
- benchmark: BenchmarkAPI;
- tasks: (Suite | Test | Benchmark | SuiteCollector<ExtraContext>)[];
- collect: (file?: File) => Promise<Suite>;
- clear: () => void;
- on: <T extends keyof SuiteHooks<ExtraContext>>(name: T, ...fn: SuiteHooks<ExtraContext>[T]) => void;
- }
- declare type SuiteFactory<ExtraContext = {}> = (test: (name: string, fn: TestFunction<ExtraContext>) => void) => Awaitable<void>;
- interface RuntimeContext {
- tasks: (SuiteCollector | Test)[];
- currentSuite: SuiteCollector | null;
- }
- interface TestContext {
- /**
- * @deprecated Use promise instead
- */
- (error?: any): void;
- /**
- * Metadata of the current test
- */
- meta: Readonly<Test>;
- /**
- * A expect instance bound to the test
- */
- expect: Vi.ExpectStatic;
- }
- declare type SnapshotData = Record<string, string>;
- declare type SnapshotUpdateState = 'all' | 'new' | 'none';
- interface SnapshotStateOptions {
- updateSnapshot: SnapshotUpdateState;
- expand?: boolean;
- snapshotFormat?: OptionsReceived;
- resolveSnapshotPath?: (path: string, extension: string) => string;
- }
- interface SnapshotMatchOptions {
- testName: string;
- received: unknown;
- key?: string;
- inlineSnapshot?: string;
- isInline: boolean;
- error?: Error;
- }
- interface SnapshotResult {
- filepath: string;
- added: number;
- fileDeleted: boolean;
- matched: number;
- unchecked: number;
- uncheckedKeys: Array<string>;
- unmatched: number;
- updated: number;
- }
- interface UncheckedSnapshot {
- filePath: string;
- keys: Array<string>;
- }
- interface SnapshotSummary {
- added: number;
- didUpdate: boolean;
- failure: boolean;
- filesAdded: number;
- filesRemoved: number;
- filesRemovedList: Array<string>;
- filesUnmatched: number;
- filesUpdated: number;
- matched: number;
- total: number;
- unchecked: number;
- uncheckedKeysByFile: Array<UncheckedSnapshot>;
- unmatched: number;
- updated: number;
- }
- interface WorkerContext {
- workerId: number;
- port: MessagePort;
- config: ResolvedConfig;
- files: string[];
- invalidates?: string[];
- }
- declare type ResolveIdFunction = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
- interface AfterSuiteRunMeta {
- coverage?: unknown;
- }
- interface WorkerRPC {
- fetch: FetchFunction;
- resolveId: ResolveIdFunction;
- getSourceMap: (id: string, force?: boolean) => Promise<RawSourceMap | undefined>;
- onFinished: (files: File[], errors?: unknown[]) => void;
- onWorkerExit: (code?: number) => void;
- onPathsCollected: (paths: string[]) => void;
- onUserConsoleLog: (log: UserConsoleLog) => void;
- onUnhandledRejection: (err: unknown) => void;
- onCollected: (files: File[]) => void;
- onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void;
- onTaskUpdate: (pack: TaskResultPack[]) => void;
- snapshotSaved: (snapshot: SnapshotResult) => void;
- resolveSnapshotPath: (testPath: string) => string;
- }
- interface WorkerGlobalState {
- ctx: WorkerContext;
- config: ResolvedConfig;
- rpc: BirpcReturn<WorkerRPC>;
- current?: Test;
- filepath?: string;
- moduleCache: ModuleCacheMap;
- browserHashMap?: Map<string, string>;
- mockMap: MockMap;
- }
- interface CoverageProvider {
- name: string;
- initialize(ctx: Vitest): Promise<void> | void;
- resolveOptions(): ResolvedCoverageOptions;
- clean(clean?: boolean): void | Promise<void>;
- onBeforeFilesRun?(): void | Promise<void>;
- onAfterSuiteRun(meta: AfterSuiteRunMeta): void | Promise<void>;
- reportCoverage(): void | Promise<void>;
- onFileTransform?(sourceCode: string, id: string, pluginCtx: TransformPluginContext): TransformResult | Promise<TransformResult>;
- }
- interface CoverageProviderModule {
- /**
- * Factory for creating a new coverage provider
- */
- getProvider(): CoverageProvider | Promise<CoverageProvider>;
- /**
- * Executed on after each run in the worker thread. Possible to return a payload passed to the provider
- */
- takeCoverage?(): unknown | Promise<unknown>;
- }
- declare type CoverageReporter = 'clover' | 'cobertura' | 'html-spa' | 'html' | 'json-summary' | 'json' | 'lcov' | 'lcovonly' | 'none' | 'teamcity' | 'text-lcov' | 'text-summary' | 'text';
- declare type CoverageOptions = BaseCoverageOptions & {
- provider?: null | CoverageProviderModule;
- } | CoverageC8Options & {
- provider?: 'c8';
- } | CoverageIstanbulOptions & {
- provider?: 'istanbul';
- };
- declare type ResolvedCoverageOptions = {
- tempDirectory: string;
- } & Required<CoverageOptions>;
- interface BaseCoverageOptions {
- /**
- * Enable coverage, pass `--coverage` to enable
- *
- * @default false
- */
- enabled?: boolean;
- /**
- * Clean coverage before running tests
- *
- * @default true
- */
- clean?: boolean;
- /**
- * Clean coverage report on watch rerun
- *
- * @default false
- */
- cleanOnRerun?: boolean;
- /**
- * Directory to write coverage report to
- */
- reportsDirectory?: string;
- /**
- * Reporters
- *
- * @default 'text'
- */
- reporter?: Arrayable<CoverageReporter>;
- /**
- * List of files included in coverage as glob patterns
- */
- include?: string[];
- /**
- * List of files excluded from coverage as glob patterns
- */
- exclude?: string[];
- /**
- * Do not show files with 100% statement, branch, and function coverage
- */
- skipFull?: boolean;
- /**
- * Check thresholds per file
- *
- * @default false
- */
- perFile?: boolean;
- /**
- * Threshold for lines
- */
- lines?: number;
- /**
- * Threshold for functions
- */
- functions?: number;
- /**
- * Threshold for branches
- */
- branches?: number;
- /**
- * Threshold for statements
- */
- statements?: number;
- /**
- * Extensions for files to be included in coverage
- */
- extension?: string | string[];
- /**
- * Whether to include all files, including the untested ones into report
- */
- all?: boolean;
- }
- interface CoverageIstanbulOptions extends BaseCoverageOptions {
- ignoreClassMethods?: string[];
- watermarks?: {
- statements?: [number, number];
- functions?: [number, number];
- branches?: [number, number];
- lines?: [number, number];
- };
- }
- interface CoverageC8Options extends BaseCoverageOptions {
- /**
- * Allow files from outside of your cwd.
- *
- * @default false
- */
- allowExternal?: any;
- /**
- * Exclude coverage under /node_modules/
- *
- * @default true
- */
- excludeNodeModules?: boolean;
- src?: string[];
- 100?: boolean;
- }
- interface JSDOMOptions {
- /**
- * The html content for the test.
- *
- * @default '<!DOCTYPE html>'
- */
- html?: string | Buffer | ArrayBufferLike;
- /**
- * referrer just affects the value read from document.referrer.
- * It defaults to no referrer (which reflects as the empty string).
- */
- referrer?: string;
- /**
- * userAgent affects the value read from navigator.userAgent, as well as the User-Agent header sent while fetching subresources.
- *
- * @default `Mozilla/5.0 (${process.platform}) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/${jsdomVersion}`
- */
- userAgent?: string;
- /**
- * url sets the value returned by window.location, document.URL, and document.documentURI,
- * and affects things like resolution of relative URLs within the document
- * and the same-origin restrictions and referrer used while fetching subresources.
- *
- * @default 'http://localhost:3000'.
- */
- url?: string;
- /**
- * contentType affects the value read from document.contentType, and how the document is parsed: as HTML or as XML.
- * Values that are not "text/html" or an XML mime type will throw.
- *
- * @default 'text/html'.
- */
- contentType?: string;
- /**
- * The maximum size in code units for the separate storage areas used by localStorage and sessionStorage.
- * Attempts to store data larger than this limit will cause a DOMException to be thrown. By default, it is set
- * to 5,000,000 code units per origin, as inspired by the HTML specification.
- *
- * @default 5_000_000
- */
- storageQuota?: number;
- /**
- * Enable console?
- *
- * @default false
- */
- console?: boolean;
- /**
- * jsdom does not have the capability to render visual content, and will act like a headless browser by default.
- * It provides hints to web pages through APIs such as document.hidden that their content is not visible.
- *
- * When the `pretendToBeVisual` option is set to `true`, jsdom will pretend that it is rendering and displaying
- * content.
- *
- * @default true
- */
- pretendToBeVisual?: boolean;
- /**
- * `includeNodeLocations` preserves the location info produced by the HTML parser,
- * allowing you to retrieve it with the nodeLocation() method (described below).
- *
- * It defaults to false to give the best performance,
- * and cannot be used with an XML content type since our XML parser does not support location info.
- *
- * @default false
- */
- includeNodeLocations?: boolean | undefined;
- /**
- * @default 'dangerously'
- */
- runScripts?: 'dangerously' | 'outside-only';
- /**
- * Enable CookieJar
- *
- * @default false
- */
- cookieJar?: boolean;
- resources?: 'usable' | any;
- }
- interface Reporter {
- onInit?(ctx: Vitest): void;
- onPathsCollected?: (paths?: string[]) => Awaitable<void>;
- onCollected?: (files?: File[]) => Awaitable<void>;
- onFinished?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
- onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
- onTestRemoved?: (trigger?: string) => Awaitable<void>;
- onWatcherStart?: () => Awaitable<void>;
- onWatcherRerun?: (files: string[], trigger?: string) => Awaitable<void>;
- onServerRestart?: (reason?: string) => Awaitable<void>;
- onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
- }
- declare type BuiltinEnvironment = 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime';
- declare type VitestEnvironment = BuiltinEnvironment | (string & Record<never, never>);
- declare type CSSModuleScopeStrategy = 'stable' | 'scoped' | 'non-scoped';
- declare type ApiConfig = Pick<CommonServerOptions, 'port' | 'strictPort' | 'host'>;
- interface EnvironmentOptions {
- /**
- * jsdom options.
- */
- jsdom?: JSDOMOptions;
- [x: string]: unknown;
- }
- declare type VitestRunMode = 'test' | 'benchmark';
- interface InlineConfig {
- /**
- * Benchmark options.
- *
- * @default {}
- */
- benchmark?: BenchmarkUserOptions;
- /**
- * Include globs for test files
- *
- * @default ['**\/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}']
- */
- include?: string[];
- /**
- * Exclude globs for test files
- * @default ['node_modules', 'dist', '.idea', '.git', '.cache']
- */
- exclude?: string[];
- /**
- * Include globs for in-source test files
- *
- * @default []
- */
- includeSource?: string[];
- /**
- * Handling for dependencies inlining or externalizing
- */
- deps?: {
- /**
- * Externalize means that Vite will bypass the package to native Node.
- *
- * Externalized dependencies will not be applied Vite's transformers and resolvers.
- * And does not support HMR on reload.
- *
- * Typically, packages under `node_modules` are externalized.
- */
- external?: (string | RegExp)[];
- /**
- * Vite will process inlined modules.
- *
- * This could be helpful to handle packages that ship `.js` in ESM format (that Node can't handle).
- *
- * If `true`, every dependency will be inlined
- */
- inline?: (string | RegExp)[] | true;
- /**
- * Interpret CJS module's default as named exports
- *
- * @default true
- */
- interopDefault?: boolean;
- /**
- * When a dependency is a valid ESM package, try to guess the cjs version based on the path.
- * This will significantly improve the performance in huge repo, but might potentially
- * cause some misalignment if a package have different logic in ESM and CJS mode.
- *
- * @default false
- */
- fallbackCJS?: boolean;
- /**
- * Use experimental Node loader to resolve imports inside node_modules using Vite resolve algorithm.
- * @default false
- */
- registerNodeLoader?: boolean;
- };
- /**
- * Base directory to scan for the test files
- *
- * @default `config.root`
- */
- dir?: string;
- /**
- * Register apis globally
- *
- * @default false
- */
- globals?: boolean;
- /**
- * Running environment
- *
- * Supports 'node', 'jsdom', 'happy-dom', 'edge-runtime'
- *
- * If used unsupported string, will try to load the package `vitest-environment-${env}`
- *
- * @default 'node'
- */
- environment?: VitestEnvironment;
- /**
- * Environment options.
- */
- environmentOptions?: EnvironmentOptions;
- /**
- * Update snapshot
- *
- * @default false
- */
- update?: boolean;
- /**
- * Watch mode
- *
- * @default true
- */
- watch?: boolean;
- /**
- * Project root
- *
- * @default process.cwd()
- */
- root?: string;
- /**
- * Custom reporter for output. Can contain one or more built-in report names, reporter instances,
- * and/or paths to custom reporters
- */
- reporters?: Arrayable<BuiltinReporters | Reporter | Omit<string, BuiltinReporters>>;
- /**
- * diff output length
- */
- outputTruncateLength?: number;
- /**
- * number of diff output lines
- */
- outputDiffLines?: number;
- /**
- * Write test results to a file when the --reporter=json` or `--reporter=junit` option is also specified.
- * Also definable individually per reporter by using an object instead.
- */
- outputFile?: string | (Partial<Record<BuiltinReporters, string>> & Record<string, string>);
- /**
- * Enable multi-threading
- *
- * @default true
- */
- threads?: boolean;
- /**
- * Maximum number of threads
- *
- * @default available CPUs
- */
- maxThreads?: number;
- /**
- * Minimum number of threads
- *
- * @default available CPUs
- */
- minThreads?: number;
- /**
- * Default timeout of a test in milliseconds
- *
- * @default 5000
- */
- testTimeout?: number;
- /**
- * Default timeout of a hook in milliseconds
- *
- * @default 10000
- */
- hookTimeout?: number;
- /**
- * Default timeout to wait for close when Vitest shuts down, in milliseconds
- *
- * @default 1000
- */
- teardownTimeout?: number;
- /**
- * Silent mode
- *
- * @default false
- */
- silent?: boolean;
- /**
- * Path to setup files
- */
- setupFiles?: string | string[];
- /**
- * Path to global setup files
- */
- globalSetup?: string | string[];
- /**
- * Glob pattern of file paths to be ignore from triggering watch rerun
- */
- watchExclude?: string[];
- /**
- * Glob patter of file paths that will trigger the whole suite rerun
- *
- * Useful if you are testing calling CLI commands
- *
- * @default []
- */
- forceRerunTriggers?: string[];
- /**
- * Isolate environment for each test file
- *
- * @default true
- */
- isolate?: boolean;
- /**
- * Coverage options
- */
- coverage?: CoverageOptions;
- /**
- * run test names with the specified pattern
- */
- testNamePattern?: string | RegExp;
- /**
- * Will call `.mockClear()` on all spies before each test
- * @default false
- */
- clearMocks?: boolean;
- /**
- * Will call `.mockReset()` on all spies before each test
- * @default false
- */
- mockReset?: boolean;
- /**
- * Will call `.mockRestore()` on all spies before each test
- * @default false
- */
- restoreMocks?: boolean;
- /**
- * Serve API options.
- *
- * When set to true, the default port is 51204.
- *
- * @default false
- */
- api?: boolean | number | ApiConfig;
- /**
- * Enable Vitest UI
- * @internal WIP
- */
- ui?: boolean;
- /**
- * Use in browser environment
- * @experimental
- */
- browser?: boolean;
- /**
- * Open UI automatically.
- *
- * @default true
- */
- open?: boolean;
- /**
- * Base url for the UI
- *
- * @default '/__vitest__/'
- */
- uiBase?: string;
- /**
- * Determine the transform method of modules
- */
- transformMode?: {
- /**
- * Use SSR transform pipeline for the specified files.
- * Vite plugins will receive `ssr: true` flag when processing those files.
- *
- * @default [/\.([cm]?[jt]sx?|json)$/]
- */
- ssr?: RegExp[];
- /**
- * First do a normal transform pipeline (targeting browser),
- * then then do a SSR rewrite to run the code in Node.
- * Vite plugins will receive `ssr: false` flag when processing those files.
- *
- * @default other than `ssr`
- */
- web?: RegExp[];
- };
- /**
- * Format options for snapshot testing.
- */
- snapshotFormat?: PrettyFormatOptions;
- /**
- * Resolve custom snapshot path
- */
- resolveSnapshotPath?: (path: string, extension: string) => string;
- /**
- * Pass with no tests
- */
- passWithNoTests?: boolean;
- /**
- * Allow tests and suites that are marked as only
- */
- allowOnly?: boolean;
- /**
- * Show heap usage after each test. Useful for debugging memory leaks.
- */
- logHeapUsage?: boolean;
- /**
- * Custom environment variables assigned to `process.env` before running tests.
- */
- env?: Record<string, string>;
- /**
- * Options for @sinon/fake-timers
- */
- fakeTimers?: FakeTimerInstallOpts;
- /**
- * Custom handler for console.log in tests.
- *
- * Return `false` to ignore the log.
- */
- onConsoleLog?: (log: string, type: 'stdout' | 'stderr') => false | void;
- /**
- * Indicates if CSS files should be processed.
- *
- * When excluded, the CSS files will be replaced with empty strings to bypass the subsequent processing.
- *
- * @default { include: [], modules: { classNameStrategy: false } }
- */
- css?: boolean | {
- include?: RegExp | RegExp[];
- exclude?: RegExp | RegExp[];
- modules?: {
- classNameStrategy?: CSSModuleScopeStrategy;
- };
- };
- /**
- * A number of tests that are allowed to run at the same time marked with `test.concurrent`.
- * @default 5
- */
- maxConcurrency?: number;
- /**
- * Options for configuring cache policy.
- * @default { dir: 'node_modules/.vitest' }
- */
- cache?: false | {
- dir?: string;
- };
- /**
- * Options for configuring the order of running tests.
- */
- sequence?: {
- /**
- * Class that handles sorting and sharding algorithm.
- * If you only need to change sorting, you can extend
- * your custom sequencer from `BaseSequencer` from `vitest/node`.
- * @default BaseSequencer
- */
- sequencer?: TestSequencerConstructor;
- /**
- * Should tests run in random order.
- * @default false
- */
- shuffle?: boolean;
- /**
- * Seed for the random number generator.
- * @default Date.now()
- */
- seed?: number;
- };
- /**
- * Specifies an `Object`, or an `Array` of `Object`,
- * which defines aliases used to replace values in `import` or `require` statements.
- * Will be merged with the default aliases inside `resolve.alias`.
- */
- alias?: AliasOptions;
- /**
- * Ignore any unhandled errors that occur
- */
- dangerouslyIgnoreUnhandledErrors?: boolean;
- }
- interface UserConfig extends InlineConfig {
- /**
- * Path to the config file.
- *
- * Default resolving to one of:
- * - `vitest.config.js`
- * - `vitest.config.ts`
- * - `vite.config.js`
- * - `vite.config.ts`
- */
- config?: string | undefined;
- /**
- * Use happy-dom
- */
- dom?: boolean;
- /**
- * Run tests that cover a list of source files
- */
- related?: string[] | string;
- /**
- * Overrides Vite mode
- * @default 'test'
- */
- mode?: string;
- /**
- * Runs tests that are affected by the changes in the repository, or between specified branch or commit hash
- * Requires initialized git repository
- * @default false
- */
- changed?: boolean | string;
- /**
- * Test suite shard to execute in a format of <index>/<count>.
- * Will divide tests into a `count` numbers, and run only the `indexed` part.
- * Cannot be used with enabled watch.
- * @example --shard=2/3
- */
- shard?: string;
- }
- interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'benchmark' | 'shard' | 'cache' | 'sequence'> {
- mode: VitestRunMode;
- base?: string;
- config?: string;
- filters?: string[];
- testNamePattern?: RegExp;
- related?: string[];
- coverage: ResolvedCoverageOptions;
- snapshotOptions: SnapshotStateOptions;
- reporters: (Reporter | BuiltinReporters)[];
- defines: Record<string, any>;
- api?: ApiConfig;
- benchmark?: Required<Omit<BenchmarkUserOptions, 'outputFile'>> & {
- outputFile?: BenchmarkUserOptions['outputFile'];
- };
- shard?: {
- index: number;
- count: number;
- };
- cache: {
- dir: string;
- } | false;
- sequence: {
- sequencer: TestSequencerConstructor;
- shuffle?: boolean;
- seed?: number;
- };
- }
- declare type VitestInlineConfig = InlineConfig;
- declare module 'vite' {
- interface UserConfig {
- /**
- * Options for Vitest
- */
- test?: VitestInlineConfig;
- }
- }
- declare type Formatter = (input: string | number | null | undefined) => string;
- interface MatcherHintOptions {
- comment?: string;
- expectedColor?: Formatter;
- isDirectExpectCall?: boolean;
- isNot?: boolean;
- promise?: string;
- receivedColor?: Formatter;
- secondArgument?: string;
- secondArgumentColor?: Formatter;
- }
- interface DiffOptions {
- aAnnotation?: string;
- aColor?: Formatter;
- aIndicator?: string;
- bAnnotation?: string;
- bColor?: Formatter;
- bIndicator?: string;
- changeColor?: Formatter;
- changeLineTrailingSpaceColor?: Formatter;
- commonColor?: Formatter;
- commonIndicator?: string;
- commonLineTrailingSpaceColor?: Formatter;
- contextLines?: number;
- emptyFirstOrLastLinePlaceholder?: string;
- expand?: boolean;
- includeChangeCounts?: boolean;
- omitAnnotationLines?: boolean;
- patchColor?: Formatter;
- compareKeys?: any;
- }
- declare const EXPECTED_COLOR: Formatter;
- declare const RECEIVED_COLOR: Formatter;
- declare const INVERTED_COLOR: Formatter;
- declare const BOLD_WEIGHT: Formatter;
- declare const DIM_COLOR: Formatter;
- declare function matcherHint(matcherName: string, received?: string, expected?: string, options?: MatcherHintOptions): string;
- declare function stringify(object: unknown, maxDepth?: number, options?: PrettyFormatOptions): string;
- declare const printReceived: (object: unknown) => string;
- declare const printExpected: (value: unknown) => string;
- declare function diff(a: any, b: any, options?: DiffOptions): string;
- declare const jestMatcherUtils_EXPECTED_COLOR: typeof EXPECTED_COLOR;
- declare const jestMatcherUtils_RECEIVED_COLOR: typeof RECEIVED_COLOR;
- declare const jestMatcherUtils_INVERTED_COLOR: typeof INVERTED_COLOR;
- declare const jestMatcherUtils_BOLD_WEIGHT: typeof BOLD_WEIGHT;
- declare const jestMatcherUtils_DIM_COLOR: typeof DIM_COLOR;
- declare const jestMatcherUtils_matcherHint: typeof matcherHint;
- declare const jestMatcherUtils_stringify: typeof stringify;
- declare const jestMatcherUtils_printReceived: typeof printReceived;
- declare const jestMatcherUtils_printExpected: typeof printExpected;
- declare const jestMatcherUtils_diff: typeof diff;
- declare namespace jestMatcherUtils {
- export {
- jestMatcherUtils_EXPECTED_COLOR as EXPECTED_COLOR,
- jestMatcherUtils_RECEIVED_COLOR as RECEIVED_COLOR,
- jestMatcherUtils_INVERTED_COLOR as INVERTED_COLOR,
- jestMatcherUtils_BOLD_WEIGHT as BOLD_WEIGHT,
- jestMatcherUtils_DIM_COLOR as DIM_COLOR,
- jestMatcherUtils_matcherHint as matcherHint,
- jestMatcherUtils_stringify as stringify,
- jestMatcherUtils_printReceived as printReceived,
- jestMatcherUtils_printExpected as printExpected,
- jestMatcherUtils_diff as diff,
- };
- }
- /**
- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
- interface SnapshotReturnOptions {
- actual: string;
- count: number;
- expected?: string;
- key: string;
- pass: boolean;
- }
- interface SaveStatus {
- deleted: boolean;
- saved: boolean;
- }
- declare class SnapshotState {
- testFilePath: string;
- snapshotPath: string;
- private _counters;
- private _dirty;
- private _updateSnapshot;
- private _snapshotData;
- private _initialData;
- private _inlineSnapshots;
- private _uncheckedKeys;
- private _snapshotFormat;
- added: number;
- expand: boolean;
- matched: number;
- unmatched: number;
- updated: number;
- constructor(testFilePath: string, snapshotPath: string, options: SnapshotStateOptions);
- markSnapshotsAsCheckedForTest(testName: string): void;
- private _inferInlineSnapshotStack;
- private _addSnapshot;
- clear(): void;
- save(): Promise<SaveStatus>;
- getUncheckedCount(): number;
- getUncheckedKeys(): Array<string>;
- removeUncheckedKeys(): void;
- match({ testName, received, key, inlineSnapshot, isInline, error, }: SnapshotMatchOptions): SnapshotReturnOptions;
- pack(): Promise<SnapshotResult>;
- }
- declare type Tester = (a: any, b: any) => boolean | undefined;
- interface MatcherState {
- assertionCalls: number;
- currentTestName?: string;
- dontThrow?: () => void;
- error?: Error;
- equals: (a: unknown, b: unknown, customTesters?: Array<Tester>, strictCheck?: boolean) => boolean;
- expand?: boolean;
- expectedAssertionsNumber?: number | null;
- expectedAssertionsNumberErrorGen?: (() => Error) | null;
- isExpectingAssertions?: boolean;
- isExpectingAssertionsError?: Error | null;
- isNot: boolean;
- environment: VitestEnvironment;
- promise: string;
- snapshotState: SnapshotState;
- suppressedErrors: Array<Error>;
- testPath?: string;
- utils: typeof jestMatcherUtils & {
- iterableEquality: Tester;
- subsetEquality: Tester;
- };
- }
- interface SyncExpectationResult {
- pass: boolean;
- message: () => string;
- actual?: any;
- expected?: any;
- }
- declare type AsyncExpectationResult = Promise<SyncExpectationResult>;
- declare type ExpectationResult = SyncExpectationResult | AsyncExpectationResult;
- interface RawMatcherFn<T extends MatcherState = MatcherState> {
- (this: T, received: any, expected: any, options?: any): ExpectationResult;
- }
- declare type MatchersObject<T extends MatcherState = MatcherState> = Record<string, RawMatcherFn<T>>;
- declare type Promisify<O> = {
- [K in keyof O]: O[K] extends (...args: infer A) => infer R ? O extends R ? Promisify<O[K]> : (...args: A) => Promise<R> : O[K];
- };
- declare global {
- namespace jest {
- interface Matchers<R, T = {}> {
- }
- }
- namespace Vi {
- interface ExpectStatic extends Chai.ExpectStatic, AsymmetricMatchersContaining {
- <T>(actual: T, message?: string): Vi.Assertion<T>;
- extend(expects: MatchersObject): void;
- assertions(expected: number): void;
- hasAssertions(): void;
- anything(): any;
- any(constructor: unknown): any;
- addSnapshotSerializer(plugin: Plugin): void;
- getState(): MatcherState;
- setState(state: Partial<MatcherState>): void;
- not: AsymmetricMatchersContaining;
- }
- interface AsymmetricMatchersContaining {
- stringContaining(expected: string): any;
- objectContaining(expected: any): any;
- arrayContaining<T = unknown>(expected: Array<T>): any;
- stringMatching(expected: string | RegExp): any;
- }
- interface JestAssertion<T = any> extends jest.Matchers<void, T> {
- toMatchSnapshot<U extends {
- [P in keyof T]: any;
- }>(snapshot: Partial<U>, message?: string): void;
- toMatchSnapshot(message?: string): void;
- matchSnapshot<U extends {
- [P in keyof T]: any;
- }>(snapshot: Partial<U>, message?: string): void;
- matchSnapshot(message?: string): void;
- toMatchInlineSnapshot<U extends {
- [P in keyof T]: any;
- }>(properties: Partial<U>, snapshot?: string, message?: string): void;
- toMatchInlineSnapshot(snapshot?: string, message?: string): void;
- toThrowErrorMatchingSnapshot(message?: string): void;
- toThrowErrorMatchingInlineSnapshot(snapshot?: string, message?: string): void;
- toEqual<E>(expected: E): void;
- toStrictEqual<E>(expected: E): void;
- toBe<E>(expected: E): void;
- toMatch(expected: string | RegExp): void;
- toMatchObject<E extends {} | any[]>(expected: E): void;
- toContain<E>(item: E): void;
- toContainEqual<E>(item: E): void;
- toBeTruthy(): void;
- toBeFalsy(): void;
- toBeGreaterThan(num: number | bigint): void;
- toBeGreaterThanOrEqual(num: number | bigint): void;
- toBeLessThan(num: number | bigint): void;
- toBeLessThanOrEqual(num: number | bigint): void;
- toBeNaN(): void;
- toBeUndefined(): void;
- toBeNull(): void;
- toBeDefined(): void;
- toBeTypeOf(expected: 'bigint' | 'boolean' | 'function' | 'number' | 'object' | 'string' | 'symbol' | 'undefined'): void;
- toBeInstanceOf<E>(expected: E): void;
- toBeCalledTimes(times: number): void;
- toHaveLength(length: number): void;
- toHaveProperty<E>(property: string | string[], value?: E): void;
- toBeCloseTo(number: number, numDigits?: number): void;
- toHaveBeenCalledTimes(times: number): void;
- toHaveBeenCalledOnce(): void;
- toHaveBeenCalled(): void;
- toBeCalled(): void;
- toHaveBeenCalledWith<E extends any[]>(...args: E): void;
- toBeCalledWith<E extends any[]>(...args: E): void;
- toHaveBeenNthCalledWith<E extends any[]>(n: number, ...args: E): void;
- nthCalledWith<E extends any[]>(nthCall: number, ...args: E): void;
- toHaveBeenLastCalledWith<E extends any[]>(...args: E): void;
- lastCalledWith<E extends any[]>(...args: E): void;
- toThrow(expected?: string | Constructable | RegExp | Error): void;
- toThrowError(expected?: string | Constructable | RegExp | Error): void;
- toReturn(): void;
- toHaveReturned(): void;
- toReturnTimes(times: number): void;
- toHaveReturnedTimes(times: number): void;
- toReturnWith<E>(value: E): void;
- toHaveReturnedWith<E>(value: E): void;
- toHaveLastReturnedWith<E>(value: E): void;
- lastReturnedWith<E>(value: E): void;
- toHaveNthReturnedWith<E>(nthCall: number, value: E): void;
- nthReturnedWith<E>(nthCall: number, value: E): void;
- toSatisfy<E>(matcher: (value: E) => boolean, message?: string): void;
- }
- type VitestAssertion<A, T> = {
- [K in keyof A]: A[K] extends Chai.Assertion ? Assertion<T> : A[K] extends (...args: any[]) => any ? A[K] : VitestAssertion<A[K], T>;
- } & ((type: string, message?: string) => Assertion);
- interface Assertion<T = any> extends VitestAssertion<Chai.Assertion, T>, JestAssertion<T> {
- resolves: Promisify<Assertion<T>>;
- rejects: Promisify<Assertion<T>>;
- }
- }
- }
- 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 };
|