terrier-engine 4.13.1 → 4.13.3
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/package.json +1 -1
- package/terrier/vitest-types.ts +1945 -0
|
@@ -0,0 +1,1945 @@
|
|
|
1
|
+
import { SnapshotResult, SnapshotStateOptions, SnapshotState } from '@vitest/snapshot';
|
|
2
|
+
import { ExpectStatic } from '@vitest/expect';
|
|
3
|
+
import { ViteDevServer, UserConfig as UserConfig$1, TransformResult as TransformResult$1, CommonServerOptions, AliasOptions, DepOptimizationConfig } from 'vite';
|
|
4
|
+
import * as _vitest_runner from '@vitest/runner';
|
|
5
|
+
import { CancelReason, Task as Task$1, Test as Test$2, TaskCustom, SequenceHooks, SequenceSetupFiles } from '@vitest/runner';
|
|
6
|
+
import { File, Test as Test$1, Suite, TaskResultPack, Task } from '@vitest/runner/types';
|
|
7
|
+
import { ParsedStack, ErrorWithDiff, ChainableFunction } from '@vitest/runner/utils';
|
|
8
|
+
import { Awaitable as Awaitable$1, Arrayable as Arrayable$1 } from '@vitest/utils';
|
|
9
|
+
import { Task as Task$2, TaskResult, Bench, Options } from 'tinybench';
|
|
10
|
+
import { ViteNodeRunner } from 'vite-node/client';
|
|
11
|
+
import { SnapshotManager } from '@vitest/snapshot/manager';
|
|
12
|
+
import { ViteNodeServer } from 'vite-node/server';
|
|
13
|
+
import { MessagePort } from 'node:worker_threads';
|
|
14
|
+
import { RawSourceMap, FetchResult, ViteNodeResolveId, ModuleCacheMap } from 'vite-node';
|
|
15
|
+
import { Stats } from 'node:fs';
|
|
16
|
+
import * as chai from 'chai';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
20
|
+
*
|
|
21
|
+
* This source code is licensed under the MIT license found in the
|
|
22
|
+
* LICENSE file in the root directory of this source tree.
|
|
23
|
+
*/
|
|
24
|
+
declare type Colors = {
|
|
25
|
+
comment: {
|
|
26
|
+
close: string;
|
|
27
|
+
open: string;
|
|
28
|
+
};
|
|
29
|
+
content: {
|
|
30
|
+
close: string;
|
|
31
|
+
open: string;
|
|
32
|
+
};
|
|
33
|
+
prop: {
|
|
34
|
+
close: string;
|
|
35
|
+
open: string;
|
|
36
|
+
};
|
|
37
|
+
tag: {
|
|
38
|
+
close: string;
|
|
39
|
+
open: string;
|
|
40
|
+
};
|
|
41
|
+
value: {
|
|
42
|
+
close: string;
|
|
43
|
+
open: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
declare type Indent = (arg0: string) => string;
|
|
47
|
+
declare type Refs = Array<unknown>;
|
|
48
|
+
declare type Print = (arg0: unknown) => string;
|
|
49
|
+
declare type ThemeReceived = {
|
|
50
|
+
comment?: string;
|
|
51
|
+
content?: string;
|
|
52
|
+
prop?: string;
|
|
53
|
+
tag?: string;
|
|
54
|
+
value?: string;
|
|
55
|
+
};
|
|
56
|
+
declare type CompareKeys = ((a: string, b: string) => number) | undefined;
|
|
57
|
+
interface PrettyFormatOptions {
|
|
58
|
+
callToJSON?: boolean;
|
|
59
|
+
compareKeys?: CompareKeys;
|
|
60
|
+
escapeRegex?: boolean;
|
|
61
|
+
escapeString?: boolean;
|
|
62
|
+
highlight?: boolean;
|
|
63
|
+
indent?: number;
|
|
64
|
+
maxDepth?: number;
|
|
65
|
+
min?: boolean;
|
|
66
|
+
plugins?: Plugins;
|
|
67
|
+
printBasicPrototype?: boolean;
|
|
68
|
+
printFunctionName?: boolean;
|
|
69
|
+
theme?: ThemeReceived;
|
|
70
|
+
}
|
|
71
|
+
declare type Config = {
|
|
72
|
+
callToJSON: boolean;
|
|
73
|
+
compareKeys: CompareKeys;
|
|
74
|
+
colors: Colors;
|
|
75
|
+
escapeRegex: boolean;
|
|
76
|
+
escapeString: boolean;
|
|
77
|
+
indent: string;
|
|
78
|
+
maxDepth: number;
|
|
79
|
+
min: boolean;
|
|
80
|
+
plugins: Plugins;
|
|
81
|
+
printBasicPrototype: boolean;
|
|
82
|
+
printFunctionName: boolean;
|
|
83
|
+
spacingInner: string;
|
|
84
|
+
spacingOuter: string;
|
|
85
|
+
};
|
|
86
|
+
declare type Printer = (val: unknown, config: Config, indentation: string, depth: number, refs: Refs, hasCalledToJSON?: boolean) => string;
|
|
87
|
+
declare type Test = (arg0: any) => boolean;
|
|
88
|
+
declare type NewPlugin = {
|
|
89
|
+
serialize: (val: any, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer) => string;
|
|
90
|
+
test: Test;
|
|
91
|
+
};
|
|
92
|
+
declare type PluginOptions = {
|
|
93
|
+
edgeSpacing: string;
|
|
94
|
+
min: boolean;
|
|
95
|
+
spacing: string;
|
|
96
|
+
};
|
|
97
|
+
declare type OldPlugin = {
|
|
98
|
+
print: (val: unknown, print: Print, indent: Indent, options: PluginOptions, colors: Colors) => string;
|
|
99
|
+
test: Test;
|
|
100
|
+
};
|
|
101
|
+
declare type Plugin = NewPlugin | OldPlugin;
|
|
102
|
+
declare type Plugins = Array<Plugin>;
|
|
103
|
+
|
|
104
|
+
// Type definitions for @sinonjs/fake-timers 8.1
|
|
105
|
+
// Project: https://github.com/sinonjs/fake-timers
|
|
106
|
+
// Definitions by: Wim Looman <https://github.com/Nemo157>
|
|
107
|
+
// Rogier Schouten <https://github.com/rogierschouten>
|
|
108
|
+
// Yishai Zehavi <https://github.com/zyishai>
|
|
109
|
+
// Remco Haszing <https://github.com/remcohaszing>
|
|
110
|
+
// Jaden Simon <https://github.com/JadenSimon>
|
|
111
|
+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
112
|
+
// TypeScript Version: 2.3
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Names of clock methods that may be faked by install.
|
|
116
|
+
*/
|
|
117
|
+
type FakeMethod =
|
|
118
|
+
| 'setTimeout'
|
|
119
|
+
| 'clearTimeout'
|
|
120
|
+
| 'setImmediate'
|
|
121
|
+
| 'clearImmediate'
|
|
122
|
+
| 'setInterval'
|
|
123
|
+
| 'clearInterval'
|
|
124
|
+
| 'Date'
|
|
125
|
+
| 'nextTick'
|
|
126
|
+
| 'hrtime'
|
|
127
|
+
| 'requestAnimationFrame'
|
|
128
|
+
| 'cancelAnimationFrame'
|
|
129
|
+
| 'requestIdleCallback'
|
|
130
|
+
| 'cancelIdleCallback'
|
|
131
|
+
| 'performance'
|
|
132
|
+
| 'queueMicrotask';
|
|
133
|
+
|
|
134
|
+
interface FakeTimerInstallOpts {
|
|
135
|
+
/**
|
|
136
|
+
* Installs fake timers with the specified unix epoch (default: 0)
|
|
137
|
+
*/
|
|
138
|
+
now?: number | Date | undefined;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* An array with names of global methods and APIs to fake. By default, `@sinonjs/fake-timers` does not replace `nextTick()` and `queueMicrotask()`.
|
|
142
|
+
* For instance, `FakeTimers.install({ toFake: ['setTimeout', 'nextTick'] })` will fake only `setTimeout()` and `nextTick()`
|
|
143
|
+
*/
|
|
144
|
+
toFake?: FakeMethod[] | undefined;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* The maximum number of timers that will be run when calling runAll() (default: 1000)
|
|
148
|
+
*/
|
|
149
|
+
loopLimit?: number | undefined;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* 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
|
|
153
|
+
* 20ms for every 20ms change in the real system time) (default: false)
|
|
154
|
+
*/
|
|
155
|
+
shouldAdvanceTime?: boolean | undefined;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Relevant only when using with shouldAdvanceTime: true. increment mocked time by advanceTimeDelta ms every advanceTimeDelta ms change
|
|
159
|
+
* in the real system time (default: 20)
|
|
160
|
+
*/
|
|
161
|
+
advanceTimeDelta?: number | undefined;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Tells FakeTimers to clear 'native' (i.e. not fake) timers by delegating to their respective handlers. These are not cleared by
|
|
165
|
+
* default, leading to potentially unexpected behavior if timers existed prior to installing FakeTimers. (default: false)
|
|
166
|
+
*/
|
|
167
|
+
shouldClearNativeTimers?: boolean | undefined;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
interface ParsedFile extends File {
|
|
171
|
+
start: number;
|
|
172
|
+
end: number;
|
|
173
|
+
}
|
|
174
|
+
interface ParsedTest extends Test$1 {
|
|
175
|
+
start: number;
|
|
176
|
+
end: number;
|
|
177
|
+
}
|
|
178
|
+
interface ParsedSuite extends Suite {
|
|
179
|
+
start: number;
|
|
180
|
+
end: number;
|
|
181
|
+
}
|
|
182
|
+
interface LocalCallDefinition {
|
|
183
|
+
start: number;
|
|
184
|
+
end: number;
|
|
185
|
+
name: string;
|
|
186
|
+
type: 'suite' | 'test';
|
|
187
|
+
mode: 'run' | 'skip' | 'only' | 'todo';
|
|
188
|
+
task: ParsedSuite | ParsedFile | ParsedTest;
|
|
189
|
+
}
|
|
190
|
+
interface FileInformation {
|
|
191
|
+
file: File;
|
|
192
|
+
filepath: string;
|
|
193
|
+
parsed: string;
|
|
194
|
+
map: RawSourceMap | null;
|
|
195
|
+
definitions: LocalCallDefinition[];
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
declare class TypeCheckError extends Error {
|
|
199
|
+
message: string;
|
|
200
|
+
stacks: ParsedStack[];
|
|
201
|
+
name: string;
|
|
202
|
+
constructor(message: string, stacks: ParsedStack[]);
|
|
203
|
+
}
|
|
204
|
+
interface ErrorsCache {
|
|
205
|
+
files: File[];
|
|
206
|
+
sourceErrors: TypeCheckError[];
|
|
207
|
+
}
|
|
208
|
+
type Callback<Args extends Array<any> = []> = (...args: Args) => Awaitable<void>;
|
|
209
|
+
declare class Typechecker {
|
|
210
|
+
protected ctx: WorkspaceProject;
|
|
211
|
+
protected files: string[];
|
|
212
|
+
private _onParseStart?;
|
|
213
|
+
private _onParseEnd?;
|
|
214
|
+
private _onWatcherRerun?;
|
|
215
|
+
private _result;
|
|
216
|
+
private _tests;
|
|
217
|
+
private tempConfigPath?;
|
|
218
|
+
private allowJs?;
|
|
219
|
+
private process;
|
|
220
|
+
constructor(ctx: WorkspaceProject, files: string[]);
|
|
221
|
+
onParseStart(fn: Callback): void;
|
|
222
|
+
onParseEnd(fn: Callback<[ErrorsCache]>): void;
|
|
223
|
+
onWatcherRerun(fn: Callback): void;
|
|
224
|
+
protected collectFileTests(filepath: string): Promise<FileInformation | null>;
|
|
225
|
+
protected getFiles(): string[];
|
|
226
|
+
collectTests(): Promise<Record<string, FileInformation>>;
|
|
227
|
+
protected markPassed(file: File): void;
|
|
228
|
+
protected prepareResults(output: string): Promise<{
|
|
229
|
+
files: File[];
|
|
230
|
+
sourceErrors: TypeCheckError[];
|
|
231
|
+
}>;
|
|
232
|
+
protected parseTscLikeOutput(output: string): Promise<Map<string, {
|
|
233
|
+
error: TypeCheckError;
|
|
234
|
+
originalError: TscErrorInfo;
|
|
235
|
+
}[]>>;
|
|
236
|
+
clear(): Promise<void>;
|
|
237
|
+
stop(): Promise<void>;
|
|
238
|
+
protected ensurePackageInstalled(root: string, checker: string): Promise<void>;
|
|
239
|
+
prepare(): Promise<void>;
|
|
240
|
+
start(): Promise<void>;
|
|
241
|
+
getResult(): ErrorsCache;
|
|
242
|
+
getTestFiles(): File[];
|
|
243
|
+
getTestPacks(): TaskResultPack[];
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
interface InitializeServerOptions {
|
|
247
|
+
server?: ViteNodeServer;
|
|
248
|
+
runner?: ViteNodeRunner;
|
|
249
|
+
}
|
|
250
|
+
declare class WorkspaceProject {
|
|
251
|
+
path: string | number;
|
|
252
|
+
ctx: Vitest;
|
|
253
|
+
configOverride: Partial<ResolvedConfig> | undefined;
|
|
254
|
+
config: ResolvedConfig;
|
|
255
|
+
server: ViteDevServer;
|
|
256
|
+
vitenode: ViteNodeServer;
|
|
257
|
+
runner: ViteNodeRunner;
|
|
258
|
+
browser: ViteDevServer;
|
|
259
|
+
typechecker?: Typechecker;
|
|
260
|
+
closingPromise: Promise<unknown> | undefined;
|
|
261
|
+
browserProvider: BrowserProvider | undefined;
|
|
262
|
+
constructor(path: string | number, ctx: Vitest);
|
|
263
|
+
getName(): string;
|
|
264
|
+
isCore(): boolean;
|
|
265
|
+
get reporters(): Reporter[];
|
|
266
|
+
globTestFiles(filters?: string[]): Promise<string[]>;
|
|
267
|
+
globAllTestFiles(config: ResolvedConfig, cwd: string): Promise<string[]>;
|
|
268
|
+
globFiles(include: string[], exclude: string[], cwd: string): Promise<string[]>;
|
|
269
|
+
isTargetFile(id: string, source?: string): Promise<boolean>;
|
|
270
|
+
isInSourceTestFile(code: string): boolean;
|
|
271
|
+
filterFiles(testFiles: string[], filters: string[] | undefined, dir: string): string[];
|
|
272
|
+
initBrowserServer(options: UserConfig): Promise<void>;
|
|
273
|
+
setServer(options: UserConfig, server: ViteDevServer, params?: InitializeServerOptions): Promise<void>;
|
|
274
|
+
report<T extends keyof Reporter>(name: T, ...args: ArgumentsType$1<Reporter[T]>): Promise<void>;
|
|
275
|
+
typecheck(filters?: string[]): Promise<void>;
|
|
276
|
+
isBrowserEnabled(): boolean | 0;
|
|
277
|
+
getSerializableConfig(): ResolvedConfig;
|
|
278
|
+
close(): Promise<unknown>;
|
|
279
|
+
initBrowserProvider(): Promise<void>;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
interface BrowserProviderOptions {
|
|
283
|
+
browser: string;
|
|
284
|
+
}
|
|
285
|
+
interface BrowserProvider {
|
|
286
|
+
name: string;
|
|
287
|
+
getSupportedBrowsers(): readonly string[];
|
|
288
|
+
initialize(ctx: WorkspaceProject, options: BrowserProviderOptions): Awaitable$1<void>;
|
|
289
|
+
openPage(url: string): Awaitable$1<void>;
|
|
290
|
+
catchError(cb: (error: Error) => Awaitable$1<void>): () => Awaitable$1<void>;
|
|
291
|
+
close(): Awaitable$1<void>;
|
|
292
|
+
}
|
|
293
|
+
interface BrowserConfigOptions {
|
|
294
|
+
/**
|
|
295
|
+
* if running tests in the browser should be the default
|
|
296
|
+
*
|
|
297
|
+
* @default false
|
|
298
|
+
*/
|
|
299
|
+
enabled?: boolean;
|
|
300
|
+
/**
|
|
301
|
+
* Name of the browser
|
|
302
|
+
*/
|
|
303
|
+
name: string;
|
|
304
|
+
/**
|
|
305
|
+
* browser provider
|
|
306
|
+
*
|
|
307
|
+
* @default 'webdriverio'
|
|
308
|
+
*/
|
|
309
|
+
provider?: 'webdriverio' | 'playwright' | (string & {});
|
|
310
|
+
/**
|
|
311
|
+
* enable headless mode
|
|
312
|
+
*
|
|
313
|
+
* @default process.env.CI
|
|
314
|
+
*/
|
|
315
|
+
headless?: boolean;
|
|
316
|
+
/**
|
|
317
|
+
* Serve API options.
|
|
318
|
+
*
|
|
319
|
+
* The default port is 63315.
|
|
320
|
+
*/
|
|
321
|
+
api?: ApiConfig | number;
|
|
322
|
+
/**
|
|
323
|
+
* Update ESM imports so they can be spied/stubbed with vi.spyOn.
|
|
324
|
+
* Enabled by default when running in browser.
|
|
325
|
+
*
|
|
326
|
+
* @default true
|
|
327
|
+
* @experimental
|
|
328
|
+
*/
|
|
329
|
+
slowHijackESM?: boolean;
|
|
330
|
+
}
|
|
331
|
+
interface ResolvedBrowserOptions extends BrowserConfigOptions {
|
|
332
|
+
enabled: boolean;
|
|
333
|
+
headless: boolean;
|
|
334
|
+
api: ApiConfig;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
type WorkspaceSpec = [project: WorkspaceProject, testFile: string];
|
|
338
|
+
type RunWithFiles = (files: WorkspaceSpec[], invalidates?: string[]) => Promise<void>;
|
|
339
|
+
interface ProcessPool {
|
|
340
|
+
runTests: RunWithFiles;
|
|
341
|
+
close: () => Promise<void>;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
interface CollectingPromise {
|
|
345
|
+
promise: Promise<void>;
|
|
346
|
+
resolve: () => void;
|
|
347
|
+
}
|
|
348
|
+
declare class StateManager {
|
|
349
|
+
filesMap: Map<string, File[]>;
|
|
350
|
+
pathsSet: Set<string>;
|
|
351
|
+
collectingPromise: CollectingPromise | undefined;
|
|
352
|
+
browserTestPromises: Map<string, {
|
|
353
|
+
resolve: (v: unknown) => void;
|
|
354
|
+
reject: (v: unknown) => void;
|
|
355
|
+
}>;
|
|
356
|
+
idMap: Map<string, Task>;
|
|
357
|
+
taskFileMap: WeakMap<Task, File>;
|
|
358
|
+
errorsSet: Set<unknown>;
|
|
359
|
+
processTimeoutCauses: Set<string>;
|
|
360
|
+
catchError(err: unknown, type: string): void;
|
|
361
|
+
clearErrors(): void;
|
|
362
|
+
getUnhandledErrors(): unknown[];
|
|
363
|
+
addProcessTimeoutCause(cause: string): void;
|
|
364
|
+
getProcessTimeoutCauses(): string[];
|
|
365
|
+
getPaths(): string[];
|
|
366
|
+
getFiles(keys?: string[]): File[];
|
|
367
|
+
getFilepaths(): string[];
|
|
368
|
+
getFailedFilepaths(): string[];
|
|
369
|
+
collectPaths(paths?: string[]): void;
|
|
370
|
+
collectFiles(files?: File[]): void;
|
|
371
|
+
clearFiles(project: WorkspaceProject, paths?: string[]): void;
|
|
372
|
+
updateId(task: Task): void;
|
|
373
|
+
updateTasks(packs: TaskResultPack[]): void;
|
|
374
|
+
updateUserLog(log: UserConsoleLog): void;
|
|
375
|
+
getCountOfFailedTests(): number;
|
|
376
|
+
cancelFiles(files: string[], root: string): void;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
declare class Logger {
|
|
380
|
+
ctx: Vitest;
|
|
381
|
+
console: Console;
|
|
382
|
+
outputStream: NodeJS.WriteStream & {
|
|
383
|
+
fd: 1;
|
|
384
|
+
};
|
|
385
|
+
errorStream: NodeJS.WriteStream & {
|
|
386
|
+
fd: 2;
|
|
387
|
+
};
|
|
388
|
+
logUpdate: ((...text: string[]) => void) & {
|
|
389
|
+
clear(): void;
|
|
390
|
+
done(): void;
|
|
391
|
+
};
|
|
392
|
+
private _clearScreenPending;
|
|
393
|
+
constructor(ctx: Vitest, console?: Console);
|
|
394
|
+
log(...args: any[]): void;
|
|
395
|
+
error(...args: any[]): void;
|
|
396
|
+
warn(...args: any[]): void;
|
|
397
|
+
clearFullScreen(message: string): void;
|
|
398
|
+
clearScreen(message: string, force?: boolean): void;
|
|
399
|
+
private _clearScreen;
|
|
400
|
+
printError(err: unknown, fullStack?: boolean, type?: string): Promise<void>;
|
|
401
|
+
printNoTestFound(filters?: string[]): void;
|
|
402
|
+
printBanner(): void;
|
|
403
|
+
printUnhandledErrors(errors: unknown[]): Promise<void>;
|
|
404
|
+
printSourceTypeErrors(errors: TypeCheckError[]): Promise<void>;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
interface SuiteResultCache {
|
|
408
|
+
failed: boolean;
|
|
409
|
+
duration: number;
|
|
410
|
+
}
|
|
411
|
+
declare class ResultsCache {
|
|
412
|
+
private cache;
|
|
413
|
+
private workspacesKeyMap;
|
|
414
|
+
private cachePath;
|
|
415
|
+
private version;
|
|
416
|
+
private root;
|
|
417
|
+
getCachePath(): string | null;
|
|
418
|
+
setConfig(root: string, config: ResolvedConfig['cache']): void;
|
|
419
|
+
getResults(key: string): SuiteResultCache | undefined;
|
|
420
|
+
readFromCache(): Promise<void>;
|
|
421
|
+
updateResults(files: File[]): void;
|
|
422
|
+
removeFromCache(filepath: string): void;
|
|
423
|
+
writeToCache(): Promise<void>;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
interface CliOptions extends UserConfig {
|
|
427
|
+
/**
|
|
428
|
+
* Override the watch mode
|
|
429
|
+
*/
|
|
430
|
+
run?: boolean;
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Start Vitest programmatically
|
|
434
|
+
*
|
|
435
|
+
* Returns a Vitest instance if initialized successfully.
|
|
436
|
+
*/
|
|
437
|
+
declare function startVitest(mode: VitestRunMode, cliFilters?: string[], options?: CliOptions, viteOverrides?: UserConfig$1): Promise<Vitest | undefined>;
|
|
438
|
+
|
|
439
|
+
type FileStatsCache = Pick<Stats, 'size'>;
|
|
440
|
+
declare class FilesStatsCache {
|
|
441
|
+
cache: Map<string, FileStatsCache>;
|
|
442
|
+
getStats(key: string): FileStatsCache | undefined;
|
|
443
|
+
populateStats(root: string, specs: WorkspaceSpec[]): Promise<void>;
|
|
444
|
+
updateStats(fsPath: string, key: string): Promise<void>;
|
|
445
|
+
removeStats(fsPath: string): void;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
declare class VitestCache {
|
|
449
|
+
results: ResultsCache;
|
|
450
|
+
stats: FilesStatsCache;
|
|
451
|
+
getFileTestResults(key: string): SuiteResultCache | undefined;
|
|
452
|
+
getFileStats(key: string): {
|
|
453
|
+
size: number;
|
|
454
|
+
} | undefined;
|
|
455
|
+
static resolveCacheDir(root: string, dir: string | undefined): string;
|
|
456
|
+
static clearCache(options: CliOptions): Promise<{
|
|
457
|
+
dir: string;
|
|
458
|
+
cleared: boolean;
|
|
459
|
+
}>;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
declare class Vitest {
|
|
463
|
+
readonly mode: VitestRunMode;
|
|
464
|
+
config: ResolvedConfig;
|
|
465
|
+
configOverride: Partial<ResolvedConfig>;
|
|
466
|
+
server: ViteDevServer;
|
|
467
|
+
state: StateManager;
|
|
468
|
+
snapshot: SnapshotManager;
|
|
469
|
+
cache: VitestCache;
|
|
470
|
+
reporters: Reporter[];
|
|
471
|
+
coverageProvider: CoverageProvider | null | undefined;
|
|
472
|
+
browserProvider: BrowserProvider | undefined;
|
|
473
|
+
logger: Logger;
|
|
474
|
+
pool: ProcessPool | undefined;
|
|
475
|
+
vitenode: ViteNodeServer;
|
|
476
|
+
invalidates: Set<string>;
|
|
477
|
+
changedTests: Set<string>;
|
|
478
|
+
filenamePattern?: string;
|
|
479
|
+
runningPromise?: Promise<void>;
|
|
480
|
+
closingPromise?: Promise<void>;
|
|
481
|
+
isCancelling: boolean;
|
|
482
|
+
isFirstRun: boolean;
|
|
483
|
+
restartsCount: number;
|
|
484
|
+
runner: ViteNodeRunner;
|
|
485
|
+
private coreWorkspace;
|
|
486
|
+
projects: WorkspaceProject[];
|
|
487
|
+
private projectsTestFiles;
|
|
488
|
+
constructor(mode: VitestRunMode);
|
|
489
|
+
private _onRestartListeners;
|
|
490
|
+
private _onSetServer;
|
|
491
|
+
private _onCancelListeners;
|
|
492
|
+
setServer(options: UserConfig, server: ViteDevServer, cliOptions: UserConfig): Promise<void>;
|
|
493
|
+
private createCoreWorkspace;
|
|
494
|
+
getCoreWorkspaceProject(): WorkspaceProject | null;
|
|
495
|
+
private resolveWorkspace;
|
|
496
|
+
private initCoverageProvider;
|
|
497
|
+
private initBrowserProviders;
|
|
498
|
+
typecheck(filters?: string[]): Promise<void[]>;
|
|
499
|
+
start(filters?: string[]): Promise<void>;
|
|
500
|
+
private getTestDependencies;
|
|
501
|
+
filterTestsBySource(specs: WorkspaceSpec[]): Promise<WorkspaceSpec[]>;
|
|
502
|
+
getProjectsByTestFile(file: string): WorkspaceSpec[];
|
|
503
|
+
runFiles(paths: WorkspaceSpec[]): Promise<void>;
|
|
504
|
+
cancelCurrentRun(reason: CancelReason): Promise<void>;
|
|
505
|
+
rerunFiles(files?: string[], trigger?: string): Promise<void>;
|
|
506
|
+
changeNamePattern(pattern: string, files?: string[], trigger?: string): Promise<void>;
|
|
507
|
+
changeFilenamePattern(pattern: string): Promise<void>;
|
|
508
|
+
rerunFailed(): Promise<void>;
|
|
509
|
+
updateSnapshot(files?: string[]): Promise<void>;
|
|
510
|
+
private _rerunTimer;
|
|
511
|
+
private scheduleRerun;
|
|
512
|
+
getModuleProjects(id: string): WorkspaceProject[];
|
|
513
|
+
private unregisterWatcher;
|
|
514
|
+
private registerWatcher;
|
|
515
|
+
/**
|
|
516
|
+
* @returns A value indicating whether rerun is needed (changedTests was mutated)
|
|
517
|
+
*/
|
|
518
|
+
private handleFileChanged;
|
|
519
|
+
private reportCoverage;
|
|
520
|
+
close(): Promise<void>;
|
|
521
|
+
/**
|
|
522
|
+
* Close the thread pool and exit the process
|
|
523
|
+
*/
|
|
524
|
+
exit(force?: boolean): Promise<void>;
|
|
525
|
+
report<T extends keyof Reporter>(name: T, ...args: ArgumentsType$1<Reporter[T]>): Promise<void>;
|
|
526
|
+
globTestFiles(filters?: string[]): Promise<WorkspaceSpec[]>;
|
|
527
|
+
shouldKeepServer(): boolean;
|
|
528
|
+
onServerRestart(fn: OnServerRestartHandler): void;
|
|
529
|
+
onAfterSetServer(fn: OnServerRestartHandler): void;
|
|
530
|
+
onCancel(fn: (reason: CancelReason) => void): void;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
type MockFactoryWithHelper = (importOriginal: <T = unknown>() => Promise<T>) => any;
|
|
534
|
+
type MockFactory = () => any;
|
|
535
|
+
type MockMap = Map<string, Record<string, string | null | MockFactory>>;
|
|
536
|
+
|
|
537
|
+
interface TestSequencer {
|
|
538
|
+
/**
|
|
539
|
+
* Slicing tests into shards. Will be run before `sort`.
|
|
540
|
+
* Only run, if `shard` is defined.
|
|
541
|
+
*/
|
|
542
|
+
shard(files: WorkspaceSpec[]): Awaitable<WorkspaceSpec[]>;
|
|
543
|
+
sort(files: WorkspaceSpec[]): Awaitable<WorkspaceSpec[]>;
|
|
544
|
+
}
|
|
545
|
+
interface TestSequencerConstructor {
|
|
546
|
+
new (ctx: Vitest): TestSequencer;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
declare abstract class BaseReporter implements Reporter {
|
|
550
|
+
start: number;
|
|
551
|
+
end: number;
|
|
552
|
+
watchFilters?: string[];
|
|
553
|
+
isTTY: boolean;
|
|
554
|
+
ctx: Vitest;
|
|
555
|
+
private _filesInWatchMode;
|
|
556
|
+
private _lastRunTimeout;
|
|
557
|
+
private _lastRunTimer;
|
|
558
|
+
private _lastRunCount;
|
|
559
|
+
private _timeStart;
|
|
560
|
+
constructor();
|
|
561
|
+
get mode(): VitestRunMode;
|
|
562
|
+
onInit(ctx: Vitest): void;
|
|
563
|
+
relative(path: string): string;
|
|
564
|
+
onFinished(files?: File[], errors?: unknown[]): Promise<void>;
|
|
565
|
+
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
566
|
+
onWatcherStart(files?: File[], errors?: unknown[]): Promise<void>;
|
|
567
|
+
private resetLastRunLog;
|
|
568
|
+
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
569
|
+
onUserConsoleLog(log: UserConsoleLog): void;
|
|
570
|
+
shouldLog(log: UserConsoleLog): boolean;
|
|
571
|
+
onServerRestart(reason?: string): void;
|
|
572
|
+
reportSummary(files: File[]): Promise<void>;
|
|
573
|
+
reportTestSummary(files: File[]): Promise<void>;
|
|
574
|
+
private printErrorsSummary;
|
|
575
|
+
reportBenchmarkSummary(files: File[]): Promise<void>;
|
|
576
|
+
private printTaskErrors;
|
|
577
|
+
registerUnhandledRejection(): void;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
declare class BasicReporter extends BaseReporter {
|
|
581
|
+
isTTY: boolean;
|
|
582
|
+
reportSummary(files: File[]): Promise<void>;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
type Awaitable<T> = T | PromiseLike<T>;
|
|
586
|
+
type Nullable<T> = T | null | undefined;
|
|
587
|
+
type Arrayable<T> = T | Array<T>;
|
|
588
|
+
type ArgumentsType$1<T> = T extends (...args: infer U) => any ? U : never;
|
|
589
|
+
type MutableArray<T extends readonly any[]> = {
|
|
590
|
+
-readonly [k in keyof T]: T[k];
|
|
591
|
+
};
|
|
592
|
+
interface Constructable {
|
|
593
|
+
new (...args: any[]): any;
|
|
594
|
+
}
|
|
595
|
+
interface ModuleCache {
|
|
596
|
+
promise?: Promise<any>;
|
|
597
|
+
exports?: any;
|
|
598
|
+
code?: string;
|
|
599
|
+
}
|
|
600
|
+
interface EnvironmentReturn {
|
|
601
|
+
teardown: (global: any) => Awaitable<void>;
|
|
602
|
+
}
|
|
603
|
+
interface Environment {
|
|
604
|
+
name: string;
|
|
605
|
+
setup(global: any, options: Record<string, any>): Awaitable<EnvironmentReturn>;
|
|
606
|
+
}
|
|
607
|
+
interface UserConsoleLog {
|
|
608
|
+
content: string;
|
|
609
|
+
type: 'stdout' | 'stderr';
|
|
610
|
+
taskId?: string;
|
|
611
|
+
time: number;
|
|
612
|
+
size: number;
|
|
613
|
+
}
|
|
614
|
+
interface ModuleGraphData {
|
|
615
|
+
graph: Record<string, string[]>;
|
|
616
|
+
externalized: string[];
|
|
617
|
+
inlined: string[];
|
|
618
|
+
}
|
|
619
|
+
type OnServerRestartHandler = (reason?: string) => Promise<void> | void;
|
|
620
|
+
|
|
621
|
+
interface ListRendererOptions$1 {
|
|
622
|
+
renderSucceed?: boolean;
|
|
623
|
+
logger: Logger;
|
|
624
|
+
showHeap: boolean;
|
|
625
|
+
mode: VitestRunMode;
|
|
626
|
+
}
|
|
627
|
+
declare function createListRenderer(_tasks: Task[], options: ListRendererOptions$1): {
|
|
628
|
+
start(): any;
|
|
629
|
+
update(_tasks: Task[]): any;
|
|
630
|
+
stop(): Promise<any>;
|
|
631
|
+
clear(): void;
|
|
632
|
+
};
|
|
633
|
+
|
|
634
|
+
declare class DefaultReporter extends BaseReporter {
|
|
635
|
+
renderer?: ReturnType<typeof createListRenderer>;
|
|
636
|
+
rendererOptions: ListRendererOptions$1;
|
|
637
|
+
onTestRemoved(trigger?: string): Promise<void>;
|
|
638
|
+
onCollected(): void;
|
|
639
|
+
onFinished(files?: _vitest_runner.File[], errors?: unknown[]): Promise<void>;
|
|
640
|
+
onWatcherStart(files?: _vitest_runner.File[], errors?: unknown[]): Promise<void>;
|
|
641
|
+
stopListRender(): Promise<void>;
|
|
642
|
+
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
643
|
+
onUserConsoleLog(log: UserConsoleLog): void;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
declare class DotReporter extends BaseReporter {
|
|
647
|
+
renderer?: ReturnType<typeof createListRenderer>;
|
|
648
|
+
onCollected(): void;
|
|
649
|
+
onFinished(files?: _vitest_runner.File[], errors?: unknown[]): Promise<void>;
|
|
650
|
+
onWatcherStart(): Promise<void>;
|
|
651
|
+
stopListRender(): Promise<void>;
|
|
652
|
+
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
653
|
+
onUserConsoleLog(log: UserConsoleLog): void;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
interface Callsite {
|
|
657
|
+
line: number;
|
|
658
|
+
column: number;
|
|
659
|
+
}
|
|
660
|
+
declare class JsonReporter$1 implements Reporter {
|
|
661
|
+
start: number;
|
|
662
|
+
ctx: Vitest;
|
|
663
|
+
onInit(ctx: Vitest): void;
|
|
664
|
+
protected logTasks(files: File[]): Promise<void>;
|
|
665
|
+
onFinished(files?: File[]): Promise<void>;
|
|
666
|
+
/**
|
|
667
|
+
* Writes the report to an output file if specified in the config,
|
|
668
|
+
* or logs it to the console otherwise.
|
|
669
|
+
* @param report
|
|
670
|
+
*/
|
|
671
|
+
writeReport(report: string): Promise<void>;
|
|
672
|
+
protected getFailureLocation(test: Task): Promise<Callsite | undefined>;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
declare class VerboseReporter extends DefaultReporter {
|
|
676
|
+
constructor();
|
|
677
|
+
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
interface Reporter {
|
|
681
|
+
onInit?(ctx: Vitest): void;
|
|
682
|
+
onPathsCollected?: (paths?: string[]) => Awaitable<void>;
|
|
683
|
+
onCollected?: (files?: File[]) => Awaitable<void>;
|
|
684
|
+
onFinished?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
|
|
685
|
+
onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
|
|
686
|
+
onTestRemoved?: (trigger?: string) => Awaitable<void>;
|
|
687
|
+
onWatcherStart?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
|
|
688
|
+
onWatcherRerun?: (files: string[], trigger?: string) => Awaitable<void>;
|
|
689
|
+
onServerRestart?: (reason?: string) => Awaitable<void>;
|
|
690
|
+
onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
|
|
691
|
+
onProcessTimeout?: () => Awaitable<void>;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
declare class TapReporter implements Reporter {
|
|
695
|
+
protected ctx: Vitest;
|
|
696
|
+
private logger;
|
|
697
|
+
onInit(ctx: Vitest): void;
|
|
698
|
+
static getComment(task: Task$1): string;
|
|
699
|
+
private logErrorDetails;
|
|
700
|
+
protected logTasks(tasks: Task$1[]): void;
|
|
701
|
+
onFinished(files?: _vitest_runner.File[]): Promise<void>;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
declare class JUnitReporter implements Reporter {
|
|
705
|
+
private ctx;
|
|
706
|
+
private reportFile?;
|
|
707
|
+
private baseLog;
|
|
708
|
+
private logger;
|
|
709
|
+
private _timeStart;
|
|
710
|
+
private fileFd?;
|
|
711
|
+
onInit(ctx: Vitest): Promise<void>;
|
|
712
|
+
writeElement(name: string, attrs: Record<string, any>, children: () => Promise<void>): Promise<void>;
|
|
713
|
+
writeErrorDetails(error: ErrorWithDiff): Promise<void>;
|
|
714
|
+
writeLogs(task: Task$1, type: 'err' | 'out'): Promise<void>;
|
|
715
|
+
writeTasks(tasks: Task$1[], filename: string): Promise<void>;
|
|
716
|
+
onFinished(files?: _vitest_runner.File[]): Promise<void>;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
declare class TapFlatReporter extends TapReporter {
|
|
720
|
+
onInit(ctx: Vitest): void;
|
|
721
|
+
onFinished(files?: _vitest_runner.File[]): Promise<void>;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
declare class HangingProcessReporter implements Reporter {
|
|
725
|
+
whyRunning: (() => void) | undefined;
|
|
726
|
+
onInit(): void;
|
|
727
|
+
onProcessTimeout(): void;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
declare class JsonReporter implements Reporter {
|
|
731
|
+
start: number;
|
|
732
|
+
ctx: Vitest;
|
|
733
|
+
onInit(ctx: Vitest): void;
|
|
734
|
+
protected logTasks(files: File[]): Promise<void>;
|
|
735
|
+
onFinished(files?: File[]): Promise<void>;
|
|
736
|
+
/**
|
|
737
|
+
* Writes the report to an output file if specified in the config,
|
|
738
|
+
* or logs it to the console otherwise.
|
|
739
|
+
* @param report
|
|
740
|
+
*/
|
|
741
|
+
writeReport(report: string): Promise<void>;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
interface ListRendererOptions {
|
|
745
|
+
renderSucceed?: boolean;
|
|
746
|
+
logger: Logger;
|
|
747
|
+
showHeap: boolean;
|
|
748
|
+
}
|
|
749
|
+
declare function createTableRenderer(_tasks: Task[], options: ListRendererOptions): {
|
|
750
|
+
start(): any;
|
|
751
|
+
update(_tasks: Task[]): any;
|
|
752
|
+
stop(): Promise<any>;
|
|
753
|
+
clear(): void;
|
|
754
|
+
};
|
|
755
|
+
|
|
756
|
+
declare class TableReporter extends BaseReporter {
|
|
757
|
+
renderer?: ReturnType<typeof createTableRenderer>;
|
|
758
|
+
rendererOptions: ListRendererOptions$1;
|
|
759
|
+
onTestRemoved(trigger?: string): Promise<void>;
|
|
760
|
+
onCollected(): void;
|
|
761
|
+
onFinished(files?: _vitest_runner.File[], errors?: unknown[]): Promise<void>;
|
|
762
|
+
onWatcherStart(): Promise<void>;
|
|
763
|
+
stopListRender(): Promise<void>;
|
|
764
|
+
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
765
|
+
onUserConsoleLog(log: UserConsoleLog): void;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
declare const BenchmarkReportsMap: {
|
|
769
|
+
default: typeof TableReporter;
|
|
770
|
+
verbose: typeof VerboseReporter;
|
|
771
|
+
json: typeof JsonReporter;
|
|
772
|
+
};
|
|
773
|
+
type BenchmarkBuiltinReporters = keyof typeof BenchmarkReportsMap;
|
|
774
|
+
|
|
775
|
+
declare const ReportersMap: {
|
|
776
|
+
default: typeof DefaultReporter;
|
|
777
|
+
basic: typeof BasicReporter;
|
|
778
|
+
verbose: typeof VerboseReporter;
|
|
779
|
+
dot: typeof DotReporter;
|
|
780
|
+
json: typeof JsonReporter$1;
|
|
781
|
+
tap: typeof TapReporter;
|
|
782
|
+
'tap-flat': typeof TapFlatReporter;
|
|
783
|
+
junit: typeof JUnitReporter;
|
|
784
|
+
'hanging-process': typeof HangingProcessReporter;
|
|
785
|
+
};
|
|
786
|
+
type BuiltinReporters = keyof typeof ReportersMap;
|
|
787
|
+
|
|
788
|
+
declare function createExpect(test?: Test$2): ExpectStatic;
|
|
789
|
+
declare const globalExpect: ExpectStatic;
|
|
790
|
+
|
|
791
|
+
declare function setupChaiConfig(config: ChaiConfig): void;
|
|
792
|
+
type ChaiConfig = Omit<Partial<typeof chai.config>, 'useProxy' | 'proxyExcludedKeys'>;
|
|
793
|
+
|
|
794
|
+
// Type definitions for istanbul-lib-report 3.0
|
|
795
|
+
|
|
796
|
+
|
|
797
|
+
interface Node {
|
|
798
|
+
isRoot(): boolean;
|
|
799
|
+
visit(visitor: Visitor, state: any): void;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
interface Visitor<N extends Node = Node> {
|
|
803
|
+
onStart(root: N, state: any): void;
|
|
804
|
+
onSummary(root: N, state: any): void;
|
|
805
|
+
onDetail(root: N, state: any): void;
|
|
806
|
+
onSummaryEnd(root: N, state: any): void;
|
|
807
|
+
onEnd(root: N, state: any): void;
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
// Type definitions for istanbul-reports 3.0
|
|
811
|
+
|
|
812
|
+
|
|
813
|
+
interface FileOptions {
|
|
814
|
+
file: string;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
interface ProjectOptions {
|
|
818
|
+
projectRoot: string;
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
interface ReportOptions {
|
|
822
|
+
clover: CloverOptions;
|
|
823
|
+
cobertura: CoberturaOptions;
|
|
824
|
+
'html-spa': HtmlSpaOptions;
|
|
825
|
+
html: HtmlOptions;
|
|
826
|
+
json: JsonOptions;
|
|
827
|
+
'json-summary': JsonSummaryOptions;
|
|
828
|
+
lcov: LcovOptions;
|
|
829
|
+
lcovonly: LcovOnlyOptions;
|
|
830
|
+
none: never;
|
|
831
|
+
teamcity: TeamcityOptions;
|
|
832
|
+
text: TextOptions;
|
|
833
|
+
'text-lcov': TextLcovOptions;
|
|
834
|
+
'text-summary': TextSummaryOptions;
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
interface CloverOptions extends FileOptions, ProjectOptions {}
|
|
838
|
+
|
|
839
|
+
interface CoberturaOptions extends FileOptions, ProjectOptions {}
|
|
840
|
+
|
|
841
|
+
interface HtmlSpaOptions extends HtmlOptions {
|
|
842
|
+
metricsToShow: Array<'lines' | 'branches' | 'functions' | 'statements'>;
|
|
843
|
+
}
|
|
844
|
+
interface HtmlOptions {
|
|
845
|
+
verbose: boolean;
|
|
846
|
+
skipEmpty: boolean;
|
|
847
|
+
subdir: string;
|
|
848
|
+
linkMapper: LinkMapper;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
type JsonOptions = FileOptions;
|
|
852
|
+
type JsonSummaryOptions = FileOptions;
|
|
853
|
+
|
|
854
|
+
interface LcovOptions extends FileOptions, ProjectOptions {}
|
|
855
|
+
interface LcovOnlyOptions extends FileOptions, ProjectOptions {}
|
|
856
|
+
|
|
857
|
+
interface TeamcityOptions extends FileOptions {
|
|
858
|
+
blockName: string;
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
interface TextOptions extends FileOptions {
|
|
862
|
+
maxCols: number;
|
|
863
|
+
skipEmpty: boolean;
|
|
864
|
+
skipFull: boolean;
|
|
865
|
+
}
|
|
866
|
+
type TextLcovOptions = ProjectOptions;
|
|
867
|
+
type TextSummaryOptions = FileOptions;
|
|
868
|
+
|
|
869
|
+
interface LinkMapper {
|
|
870
|
+
getPath(node: string | Node): string;
|
|
871
|
+
relativePath(source: string | Node, target: string | Node): string;
|
|
872
|
+
assetPath(node: Node, name: string): string;
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
|
|
876
|
+
type ReturnType$1<T> = T extends (...args: any) => infer R ? R : never;
|
|
877
|
+
type PromisifyFn<T> = ReturnType$1<T> extends Promise<any> ? T : (...args: ArgumentsType<T>) => Promise<Awaited<ReturnType$1<T>>>;
|
|
878
|
+
type BirpcFn<T> = PromisifyFn<T> & {
|
|
879
|
+
/**
|
|
880
|
+
* Send event without asking for response
|
|
881
|
+
*/
|
|
882
|
+
asEvent(...args: ArgumentsType<T>): void;
|
|
883
|
+
};
|
|
884
|
+
type BirpcReturn<RemoteFunctions, LocalFunctions = {}> = {
|
|
885
|
+
[K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]>;
|
|
886
|
+
} & {
|
|
887
|
+
$functions: LocalFunctions;
|
|
888
|
+
};
|
|
889
|
+
|
|
890
|
+
interface RuntimeRPC {
|
|
891
|
+
fetch: (id: string, environment: VitestEnvironment) => Promise<FetchResult>;
|
|
892
|
+
resolveId: (id: string, importer: string | undefined, environment: VitestEnvironment) => Promise<ViteNodeResolveId | null>;
|
|
893
|
+
getSourceMap: (id: string, force?: boolean) => Promise<RawSourceMap | undefined>;
|
|
894
|
+
onFinished: (files: File[], errors?: unknown[]) => void;
|
|
895
|
+
onWorkerExit: (error: unknown, code?: number) => void;
|
|
896
|
+
onPathsCollected: (paths: string[]) => void;
|
|
897
|
+
onUserConsoleLog: (log: UserConsoleLog) => void;
|
|
898
|
+
onUnhandledError: (err: unknown, type: string) => void;
|
|
899
|
+
onCollected: (files: File[]) => void;
|
|
900
|
+
onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void;
|
|
901
|
+
onTaskUpdate: (pack: TaskResultPack[]) => void;
|
|
902
|
+
onCancel(reason: CancelReason): void;
|
|
903
|
+
getCountOfFailedTests(): number;
|
|
904
|
+
snapshotSaved: (snapshot: SnapshotResult) => void;
|
|
905
|
+
resolveSnapshotPath: (testPath: string) => string;
|
|
906
|
+
}
|
|
907
|
+
interface RunnerRPC {
|
|
908
|
+
onCancel: (reason: CancelReason) => void;
|
|
909
|
+
}
|
|
910
|
+
interface ContextTestEnvironment {
|
|
911
|
+
name: VitestEnvironment;
|
|
912
|
+
options: EnvironmentOptions | null;
|
|
913
|
+
}
|
|
914
|
+
interface ContextRPC {
|
|
915
|
+
config: ResolvedConfig;
|
|
916
|
+
files: string[];
|
|
917
|
+
invalidates?: string[];
|
|
918
|
+
environment: ContextTestEnvironment;
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
interface WorkerContext extends ContextRPC {
|
|
922
|
+
workerId: number;
|
|
923
|
+
port: MessagePort;
|
|
924
|
+
}
|
|
925
|
+
type ResolveIdFunction = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
|
|
926
|
+
interface AfterSuiteRunMeta {
|
|
927
|
+
coverage?: unknown;
|
|
928
|
+
}
|
|
929
|
+
interface WorkerGlobalState {
|
|
930
|
+
ctx: WorkerContext;
|
|
931
|
+
config: ResolvedConfig;
|
|
932
|
+
rpc: BirpcReturn<RuntimeRPC>;
|
|
933
|
+
current?: Test$2;
|
|
934
|
+
filepath?: string;
|
|
935
|
+
environmentTeardownRun?: boolean;
|
|
936
|
+
onCancel: Promise<CancelReason>;
|
|
937
|
+
moduleCache: ModuleCacheMap;
|
|
938
|
+
mockMap: MockMap;
|
|
939
|
+
durations: {
|
|
940
|
+
environment: number;
|
|
941
|
+
prepare: number;
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
type TransformResult = string | Partial<TransformResult$1> | undefined | null | void;
|
|
946
|
+
interface CoverageProvider {
|
|
947
|
+
name: string;
|
|
948
|
+
initialize(ctx: Vitest): Promise<void> | void;
|
|
949
|
+
resolveOptions(): ResolvedCoverageOptions;
|
|
950
|
+
clean(clean?: boolean): void | Promise<void>;
|
|
951
|
+
onAfterSuiteRun(meta: AfterSuiteRunMeta): void | Promise<void>;
|
|
952
|
+
reportCoverage(reportContext?: ReportContext): void | Promise<void>;
|
|
953
|
+
onFileTransform?(sourceCode: string, id: string, pluginCtx: any): TransformResult | Promise<TransformResult>;
|
|
954
|
+
}
|
|
955
|
+
interface ReportContext {
|
|
956
|
+
/** Indicates whether all tests were run. False when only specific tests were run. */
|
|
957
|
+
allTestsRun?: boolean;
|
|
958
|
+
}
|
|
959
|
+
interface CoverageProviderModule {
|
|
960
|
+
/**
|
|
961
|
+
* Factory for creating a new coverage provider
|
|
962
|
+
*/
|
|
963
|
+
getProvider(): CoverageProvider | Promise<CoverageProvider>;
|
|
964
|
+
/**
|
|
965
|
+
* Executed before tests are run in the worker thread.
|
|
966
|
+
*/
|
|
967
|
+
startCoverage?(): unknown | Promise<unknown>;
|
|
968
|
+
/**
|
|
969
|
+
* Executed on after each run in the worker thread. Possible to return a payload passed to the provider
|
|
970
|
+
*/
|
|
971
|
+
takeCoverage?(): unknown | Promise<unknown>;
|
|
972
|
+
/**
|
|
973
|
+
* Executed after all tests have been run in the worker thread.
|
|
974
|
+
*/
|
|
975
|
+
stopCoverage?(): unknown | Promise<unknown>;
|
|
976
|
+
}
|
|
977
|
+
type CoverageReporter = keyof ReportOptions;
|
|
978
|
+
type CoverageReporterWithOptions<ReporterName extends CoverageReporter = CoverageReporter> = ReporterName extends CoverageReporter ? ReportOptions[ReporterName] extends never ? [ReporterName, {}] : [ReporterName, Partial<ReportOptions[ReporterName]>] : never;
|
|
979
|
+
type Provider = 'c8' | 'istanbul' | 'custom' | undefined;
|
|
980
|
+
type CoverageOptions<T extends Provider = Provider> = T extends 'istanbul' ? ({
|
|
981
|
+
provider: T;
|
|
982
|
+
} & CoverageIstanbulOptions) : T extends 'c8' ? ({
|
|
983
|
+
provider: T;
|
|
984
|
+
} & CoverageC8Options) : T extends 'custom' ? ({
|
|
985
|
+
provider: T;
|
|
986
|
+
} & CustomProviderOptions) : ({
|
|
987
|
+
provider?: T;
|
|
988
|
+
} & (CoverageC8Options));
|
|
989
|
+
/** Fields that have default values. Internally these will always be defined. */
|
|
990
|
+
type FieldsWithDefaultValues = 'enabled' | 'clean' | 'cleanOnRerun' | 'reportsDirectory' | 'exclude' | 'extension';
|
|
991
|
+
type ResolvedCoverageOptions<T extends Provider = Provider> = CoverageOptions<T> & Required<Pick<CoverageOptions<T>, FieldsWithDefaultValues>> & {
|
|
992
|
+
reporter: CoverageReporterWithOptions[];
|
|
993
|
+
};
|
|
994
|
+
interface BaseCoverageOptions {
|
|
995
|
+
/**
|
|
996
|
+
* Enables coverage collection. Can be overridden using `--coverage` CLI option.
|
|
997
|
+
*
|
|
998
|
+
* @default false
|
|
999
|
+
*/
|
|
1000
|
+
enabled?: boolean;
|
|
1001
|
+
/**
|
|
1002
|
+
* List of files included in coverage as glob patterns
|
|
1003
|
+
*
|
|
1004
|
+
* @default ['**']
|
|
1005
|
+
*/
|
|
1006
|
+
include?: string[];
|
|
1007
|
+
/**
|
|
1008
|
+
* Extensions for files to be included in coverage
|
|
1009
|
+
*
|
|
1010
|
+
* @default ['.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx', '.vue', '.svelte']
|
|
1011
|
+
*/
|
|
1012
|
+
extension?: string | string[];
|
|
1013
|
+
/**
|
|
1014
|
+
* List of files excluded from coverage as glob patterns
|
|
1015
|
+
*/
|
|
1016
|
+
exclude?: string[];
|
|
1017
|
+
/**
|
|
1018
|
+
* Whether to include all files, including the untested ones into report
|
|
1019
|
+
*
|
|
1020
|
+
* @default false
|
|
1021
|
+
*/
|
|
1022
|
+
all?: boolean;
|
|
1023
|
+
/**
|
|
1024
|
+
* Clean coverage results before running tests
|
|
1025
|
+
*
|
|
1026
|
+
* @default true
|
|
1027
|
+
*/
|
|
1028
|
+
clean?: boolean;
|
|
1029
|
+
/**
|
|
1030
|
+
* Clean coverage report on watch rerun
|
|
1031
|
+
*
|
|
1032
|
+
* @default true
|
|
1033
|
+
*/
|
|
1034
|
+
cleanOnRerun?: boolean;
|
|
1035
|
+
/**
|
|
1036
|
+
* Directory to write coverage report to
|
|
1037
|
+
*/
|
|
1038
|
+
reportsDirectory?: string;
|
|
1039
|
+
/**
|
|
1040
|
+
* Coverage reporters to use.
|
|
1041
|
+
* See [istanbul documentation](https://istanbul.js.org/docs/advanced/alternative-reporters/) for detailed list of all reporters.
|
|
1042
|
+
*
|
|
1043
|
+
* @default ['text', 'html', 'clover', 'json']
|
|
1044
|
+
*/
|
|
1045
|
+
reporter?: Arrayable<CoverageReporter> | (CoverageReporter | [CoverageReporter] | CoverageReporterWithOptions)[];
|
|
1046
|
+
/**
|
|
1047
|
+
* Do not show files with 100% statement, branch, and function coverage
|
|
1048
|
+
*
|
|
1049
|
+
* @default false
|
|
1050
|
+
*/
|
|
1051
|
+
skipFull?: boolean;
|
|
1052
|
+
/**
|
|
1053
|
+
* Check thresholds per file.
|
|
1054
|
+
* See `lines`, `functions`, `branches` and `statements` for the actual thresholds.
|
|
1055
|
+
*
|
|
1056
|
+
* @default false
|
|
1057
|
+
*/
|
|
1058
|
+
perFile?: boolean;
|
|
1059
|
+
/**
|
|
1060
|
+
* Threshold for lines
|
|
1061
|
+
*
|
|
1062
|
+
* @default undefined
|
|
1063
|
+
*/
|
|
1064
|
+
lines?: number;
|
|
1065
|
+
/**
|
|
1066
|
+
* Threshold for functions
|
|
1067
|
+
*
|
|
1068
|
+
* @default undefined
|
|
1069
|
+
*/
|
|
1070
|
+
functions?: number;
|
|
1071
|
+
/**
|
|
1072
|
+
* Threshold for branches
|
|
1073
|
+
*
|
|
1074
|
+
* @default undefined
|
|
1075
|
+
*/
|
|
1076
|
+
branches?: number;
|
|
1077
|
+
/**
|
|
1078
|
+
* Threshold for statements
|
|
1079
|
+
*
|
|
1080
|
+
* @default undefined
|
|
1081
|
+
*/
|
|
1082
|
+
statements?: number;
|
|
1083
|
+
/**
|
|
1084
|
+
* Watermarks for statements, lines, branches and functions.
|
|
1085
|
+
*
|
|
1086
|
+
* Default value is `[50,80]` for each property.
|
|
1087
|
+
*/
|
|
1088
|
+
watermarks?: {
|
|
1089
|
+
statements?: [number, number];
|
|
1090
|
+
functions?: [number, number];
|
|
1091
|
+
branches?: [number, number];
|
|
1092
|
+
lines?: [number, number];
|
|
1093
|
+
};
|
|
1094
|
+
/**
|
|
1095
|
+
* Update threshold values automatically when current coverage is higher than earlier thresholds
|
|
1096
|
+
*
|
|
1097
|
+
* @default false
|
|
1098
|
+
*/
|
|
1099
|
+
thresholdAutoUpdate?: boolean;
|
|
1100
|
+
}
|
|
1101
|
+
interface CoverageIstanbulOptions extends BaseCoverageOptions {
|
|
1102
|
+
/**
|
|
1103
|
+
* Set to array of class method names to ignore for coverage
|
|
1104
|
+
*
|
|
1105
|
+
* @default []
|
|
1106
|
+
*/
|
|
1107
|
+
ignoreClassMethods?: string[];
|
|
1108
|
+
}
|
|
1109
|
+
interface CoverageC8Options extends BaseCoverageOptions {
|
|
1110
|
+
/**
|
|
1111
|
+
* Allow files from outside of your cwd.
|
|
1112
|
+
*
|
|
1113
|
+
* @default false
|
|
1114
|
+
*/
|
|
1115
|
+
allowExternal?: boolean;
|
|
1116
|
+
/**
|
|
1117
|
+
* Exclude coverage under `/node_modules/`
|
|
1118
|
+
*
|
|
1119
|
+
* @default true
|
|
1120
|
+
*/
|
|
1121
|
+
excludeNodeModules?: boolean;
|
|
1122
|
+
/**
|
|
1123
|
+
* Specifies the directories that are used when `--all` is enabled.
|
|
1124
|
+
*
|
|
1125
|
+
* @default cwd
|
|
1126
|
+
*/
|
|
1127
|
+
src?: string[];
|
|
1128
|
+
/**
|
|
1129
|
+
* Shortcut for `--check-coverage --lines 100 --functions 100 --branches 100 --statements 100`
|
|
1130
|
+
*
|
|
1131
|
+
* @default false
|
|
1132
|
+
*/
|
|
1133
|
+
100?: boolean;
|
|
1134
|
+
}
|
|
1135
|
+
interface CustomProviderOptions extends Pick<BaseCoverageOptions, FieldsWithDefaultValues> {
|
|
1136
|
+
/** Name of the module or path to a file to load the custom provider from */
|
|
1137
|
+
customProviderModule: string;
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
interface JSDOMOptions {
|
|
1141
|
+
/**
|
|
1142
|
+
* The html content for the test.
|
|
1143
|
+
*
|
|
1144
|
+
* @default '<!DOCTYPE html>'
|
|
1145
|
+
*/
|
|
1146
|
+
html?: string | Buffer | ArrayBufferLike;
|
|
1147
|
+
/**
|
|
1148
|
+
* referrer just affects the value read from document.referrer.
|
|
1149
|
+
* It defaults to no referrer (which reflects as the empty string).
|
|
1150
|
+
*/
|
|
1151
|
+
referrer?: string;
|
|
1152
|
+
/**
|
|
1153
|
+
* userAgent affects the value read from navigator.userAgent, as well as the User-Agent header sent while fetching subresources.
|
|
1154
|
+
*
|
|
1155
|
+
* @default `Mozilla/5.0 (${process.platform}) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/${jsdomVersion}`
|
|
1156
|
+
*/
|
|
1157
|
+
userAgent?: string;
|
|
1158
|
+
/**
|
|
1159
|
+
* url sets the value returned by window.location, document.URL, and document.documentURI,
|
|
1160
|
+
* and affects things like resolution of relative URLs within the document
|
|
1161
|
+
* and the same-origin restrictions and referrer used while fetching subresources.
|
|
1162
|
+
*
|
|
1163
|
+
* @default 'http://localhost:3000'.
|
|
1164
|
+
*/
|
|
1165
|
+
url?: string;
|
|
1166
|
+
/**
|
|
1167
|
+
* contentType affects the value read from document.contentType, and how the document is parsed: as HTML or as XML.
|
|
1168
|
+
* Values that are not "text/html" or an XML mime type will throw.
|
|
1169
|
+
*
|
|
1170
|
+
* @default 'text/html'.
|
|
1171
|
+
*/
|
|
1172
|
+
contentType?: string;
|
|
1173
|
+
/**
|
|
1174
|
+
* The maximum size in code units for the separate storage areas used by localStorage and sessionStorage.
|
|
1175
|
+
* Attempts to store data larger than this limit will cause a DOMException to be thrown. By default, it is set
|
|
1176
|
+
* to 5,000,000 code units per origin, as inspired by the HTML specification.
|
|
1177
|
+
*
|
|
1178
|
+
* @default 5_000_000
|
|
1179
|
+
*/
|
|
1180
|
+
storageQuota?: number;
|
|
1181
|
+
/**
|
|
1182
|
+
* Enable console?
|
|
1183
|
+
*
|
|
1184
|
+
* @default false
|
|
1185
|
+
*/
|
|
1186
|
+
console?: boolean;
|
|
1187
|
+
/**
|
|
1188
|
+
* jsdom does not have the capability to render visual content, and will act like a headless browser by default.
|
|
1189
|
+
* It provides hints to web pages through APIs such as document.hidden that their content is not visible.
|
|
1190
|
+
*
|
|
1191
|
+
* When the `pretendToBeVisual` option is set to `true`, jsdom will pretend that it is rendering and displaying
|
|
1192
|
+
* content.
|
|
1193
|
+
*
|
|
1194
|
+
* @default true
|
|
1195
|
+
*/
|
|
1196
|
+
pretendToBeVisual?: boolean;
|
|
1197
|
+
/**
|
|
1198
|
+
* `includeNodeLocations` preserves the location info produced by the HTML parser,
|
|
1199
|
+
* allowing you to retrieve it with the nodeLocation() method (described below).
|
|
1200
|
+
*
|
|
1201
|
+
* It defaults to false to give the best performance,
|
|
1202
|
+
* and cannot be used with an XML content type since our XML parser does not support location info.
|
|
1203
|
+
*
|
|
1204
|
+
* @default false
|
|
1205
|
+
*/
|
|
1206
|
+
includeNodeLocations?: boolean | undefined;
|
|
1207
|
+
/**
|
|
1208
|
+
* @default 'dangerously'
|
|
1209
|
+
*/
|
|
1210
|
+
runScripts?: 'dangerously' | 'outside-only';
|
|
1211
|
+
/**
|
|
1212
|
+
* Enable CookieJar
|
|
1213
|
+
*
|
|
1214
|
+
* @default false
|
|
1215
|
+
*/
|
|
1216
|
+
cookieJar?: boolean;
|
|
1217
|
+
resources?: 'usable' | any;
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
interface BenchmarkUserOptions {
|
|
1221
|
+
/**
|
|
1222
|
+
* Include globs for benchmark test files
|
|
1223
|
+
*
|
|
1224
|
+
* @default ['**\/*.{bench,benchmark}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}']
|
|
1225
|
+
*/
|
|
1226
|
+
include?: string[];
|
|
1227
|
+
/**
|
|
1228
|
+
* Exclude globs for benchmark test files
|
|
1229
|
+
* @default ['node_modules', 'dist', '.idea', '.git', '.cache']
|
|
1230
|
+
*/
|
|
1231
|
+
exclude?: string[];
|
|
1232
|
+
/**
|
|
1233
|
+
* Include globs for in-source benchmark test files
|
|
1234
|
+
*
|
|
1235
|
+
* @default []
|
|
1236
|
+
*/
|
|
1237
|
+
includeSource?: string[];
|
|
1238
|
+
/**
|
|
1239
|
+
* Custom reporter for output. Can contain one or more built-in report names, reporter instances,
|
|
1240
|
+
* and/or paths to custom reporters
|
|
1241
|
+
*/
|
|
1242
|
+
reporters?: Arrayable$1<BenchmarkBuiltinReporters | Reporter>;
|
|
1243
|
+
/**
|
|
1244
|
+
* Write test results to a file when the `--reporter=json` option is also specified.
|
|
1245
|
+
* Also definable individually per reporter by using an object instead.
|
|
1246
|
+
*/
|
|
1247
|
+
outputFile?: string | (Partial<Record<BenchmarkBuiltinReporters, string>> & Record<string, string>);
|
|
1248
|
+
}
|
|
1249
|
+
interface Benchmark extends TaskCustom {
|
|
1250
|
+
meta: {
|
|
1251
|
+
benchmark: true;
|
|
1252
|
+
task?: Task$2;
|
|
1253
|
+
result?: TaskResult;
|
|
1254
|
+
};
|
|
1255
|
+
}
|
|
1256
|
+
interface BenchmarkResult extends TaskResult {
|
|
1257
|
+
name: string;
|
|
1258
|
+
rank: number;
|
|
1259
|
+
}
|
|
1260
|
+
type BenchFunction = (this: Bench) => Promise<void> | void;
|
|
1261
|
+
type BenchmarkAPI = ChainableFunction<'skip' | 'only' | 'todo', [
|
|
1262
|
+
name: string,
|
|
1263
|
+
fn?: BenchFunction,
|
|
1264
|
+
options?: Options
|
|
1265
|
+
], void> & {
|
|
1266
|
+
skipIf(condition: any): BenchmarkAPI;
|
|
1267
|
+
runIf(condition: any): BenchmarkAPI;
|
|
1268
|
+
};
|
|
1269
|
+
|
|
1270
|
+
type BuiltinEnvironment = 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime';
|
|
1271
|
+
type VitestEnvironment = BuiltinEnvironment | (string & Record<never, never>);
|
|
1272
|
+
type VitestPool = 'browser' | 'threads' | 'child_process';
|
|
1273
|
+
type CSSModuleScopeStrategy = 'stable' | 'scoped' | 'non-scoped';
|
|
1274
|
+
type ApiConfig = Pick<CommonServerOptions, 'port' | 'strictPort' | 'host'>;
|
|
1275
|
+
|
|
1276
|
+
interface EnvironmentOptions {
|
|
1277
|
+
/**
|
|
1278
|
+
* jsdom options.
|
|
1279
|
+
*/
|
|
1280
|
+
jsdom?: JSDOMOptions;
|
|
1281
|
+
[x: string]: unknown;
|
|
1282
|
+
}
|
|
1283
|
+
type VitestRunMode = 'test' | 'benchmark' | 'typecheck';
|
|
1284
|
+
interface SequenceOptions {
|
|
1285
|
+
/**
|
|
1286
|
+
* Class that handles sorting and sharding algorithm.
|
|
1287
|
+
* If you only need to change sorting, you can extend
|
|
1288
|
+
* your custom sequencer from `BaseSequencer` from `vitest/node`.
|
|
1289
|
+
* @default BaseSequencer
|
|
1290
|
+
*/
|
|
1291
|
+
sequencer?: TestSequencerConstructor;
|
|
1292
|
+
/**
|
|
1293
|
+
* Should tests run in random order.
|
|
1294
|
+
* @default false
|
|
1295
|
+
*/
|
|
1296
|
+
shuffle?: boolean;
|
|
1297
|
+
/**
|
|
1298
|
+
* Defines how setup files should be ordered
|
|
1299
|
+
* - 'parallel' will run all setup files in parallel
|
|
1300
|
+
* - 'list' will run all setup files in the order they are defined in the config file
|
|
1301
|
+
* @default 'parallel'
|
|
1302
|
+
*/
|
|
1303
|
+
setupFiles?: SequenceSetupFiles;
|
|
1304
|
+
/**
|
|
1305
|
+
* Seed for the random number generator.
|
|
1306
|
+
* @default Date.now()
|
|
1307
|
+
*/
|
|
1308
|
+
seed?: number;
|
|
1309
|
+
/**
|
|
1310
|
+
* Defines how hooks should be ordered
|
|
1311
|
+
* - `stack` will order "after" hooks in reverse order, "before" hooks will run sequentially
|
|
1312
|
+
* - `list` will order hooks in the order they are defined
|
|
1313
|
+
* - `parallel` will run hooks in a single group in parallel
|
|
1314
|
+
* @default 'parallel'
|
|
1315
|
+
*/
|
|
1316
|
+
hooks?: SequenceHooks;
|
|
1317
|
+
}
|
|
1318
|
+
interface DepsOptions {
|
|
1319
|
+
/**
|
|
1320
|
+
* Enable dependency optimization. This can improve the performance of your tests.
|
|
1321
|
+
*/
|
|
1322
|
+
experimentalOptimizer?: Omit<DepOptimizationConfig, 'disabled'> & {
|
|
1323
|
+
enabled: boolean;
|
|
1324
|
+
};
|
|
1325
|
+
/**
|
|
1326
|
+
* Externalize means that Vite will bypass the package to native Node.
|
|
1327
|
+
*
|
|
1328
|
+
* Externalized dependencies will not be applied Vite's transformers and resolvers.
|
|
1329
|
+
* And does not support HMR on reload.
|
|
1330
|
+
*
|
|
1331
|
+
* Typically, packages under `node_modules` are externalized.
|
|
1332
|
+
*/
|
|
1333
|
+
external?: (string | RegExp)[];
|
|
1334
|
+
/**
|
|
1335
|
+
* Vite will process inlined modules.
|
|
1336
|
+
*
|
|
1337
|
+
* This could be helpful to handle packages that ship `.js` in ESM format (that Node can't handle).
|
|
1338
|
+
*
|
|
1339
|
+
* If `true`, every dependency will be inlined
|
|
1340
|
+
*/
|
|
1341
|
+
inline?: (string | RegExp)[] | true;
|
|
1342
|
+
/**
|
|
1343
|
+
* Interpret CJS module's default as named exports
|
|
1344
|
+
*
|
|
1345
|
+
* @default true
|
|
1346
|
+
*/
|
|
1347
|
+
interopDefault?: boolean;
|
|
1348
|
+
/**
|
|
1349
|
+
* When a dependency is a valid ESM package, try to guess the cjs version based on the path.
|
|
1350
|
+
* This will significantly improve the performance in huge repo, but might potentially
|
|
1351
|
+
* cause some misalignment if a package have different logic in ESM and CJS mode.
|
|
1352
|
+
*
|
|
1353
|
+
* @default false
|
|
1354
|
+
*/
|
|
1355
|
+
fallbackCJS?: boolean;
|
|
1356
|
+
/**
|
|
1357
|
+
* Use experimental Node loader to resolve imports inside node_modules using Vite resolve algorithm.
|
|
1358
|
+
* @default false
|
|
1359
|
+
*/
|
|
1360
|
+
registerNodeLoader?: boolean;
|
|
1361
|
+
}
|
|
1362
|
+
interface InlineConfig {
|
|
1363
|
+
/**
|
|
1364
|
+
* Name of the project. Will be used to display in the reporter.
|
|
1365
|
+
*/
|
|
1366
|
+
name?: string;
|
|
1367
|
+
/**
|
|
1368
|
+
* Benchmark options.
|
|
1369
|
+
*
|
|
1370
|
+
* @default {}
|
|
1371
|
+
*/
|
|
1372
|
+
benchmark?: BenchmarkUserOptions;
|
|
1373
|
+
/**
|
|
1374
|
+
* Include globs for test files
|
|
1375
|
+
*
|
|
1376
|
+
* @default ['**\/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}']
|
|
1377
|
+
*/
|
|
1378
|
+
include?: string[];
|
|
1379
|
+
/**
|
|
1380
|
+
* Exclude globs for test files
|
|
1381
|
+
* @default ['node_modules', 'dist', '.idea', '.git', '.cache']
|
|
1382
|
+
*/
|
|
1383
|
+
exclude?: string[];
|
|
1384
|
+
/**
|
|
1385
|
+
* Include globs for in-source test files
|
|
1386
|
+
*
|
|
1387
|
+
* @default []
|
|
1388
|
+
*/
|
|
1389
|
+
includeSource?: string[];
|
|
1390
|
+
/**
|
|
1391
|
+
* Handling for dependencies inlining or externalizing
|
|
1392
|
+
*/
|
|
1393
|
+
deps?: DepsOptions;
|
|
1394
|
+
/**
|
|
1395
|
+
* Base directory to scan for the test files
|
|
1396
|
+
*
|
|
1397
|
+
* @default `config.root`
|
|
1398
|
+
*/
|
|
1399
|
+
dir?: string;
|
|
1400
|
+
/**
|
|
1401
|
+
* Register apis globally
|
|
1402
|
+
*
|
|
1403
|
+
* @default false
|
|
1404
|
+
*/
|
|
1405
|
+
globals?: boolean;
|
|
1406
|
+
/**
|
|
1407
|
+
* Running environment
|
|
1408
|
+
*
|
|
1409
|
+
* Supports 'node', 'jsdom', 'happy-dom', 'edge-runtime'
|
|
1410
|
+
*
|
|
1411
|
+
* If used unsupported string, will try to load the package `vitest-environment-${env}`
|
|
1412
|
+
*
|
|
1413
|
+
* @default 'node'
|
|
1414
|
+
*/
|
|
1415
|
+
environment?: VitestEnvironment;
|
|
1416
|
+
/**
|
|
1417
|
+
* Environment options.
|
|
1418
|
+
*/
|
|
1419
|
+
environmentOptions?: EnvironmentOptions;
|
|
1420
|
+
/**
|
|
1421
|
+
* Automatically assign environment based on globs. The first match will be used.
|
|
1422
|
+
* This has effect only when running tests inside Node.js.
|
|
1423
|
+
*
|
|
1424
|
+
* Format: [glob, environment-name]
|
|
1425
|
+
*
|
|
1426
|
+
* @default []
|
|
1427
|
+
* @example [
|
|
1428
|
+
* // all tests in tests/dom will run in jsdom
|
|
1429
|
+
* ['tests/dom/**', 'jsdom'],
|
|
1430
|
+
* // all tests in tests/ with .edge.test.ts will run in edge-runtime
|
|
1431
|
+
* ['**\/*.edge.test.ts', 'edge-runtime'],
|
|
1432
|
+
* // ...
|
|
1433
|
+
* ]
|
|
1434
|
+
*/
|
|
1435
|
+
environmentMatchGlobs?: [string, VitestEnvironment][];
|
|
1436
|
+
/**
|
|
1437
|
+
* Automatically assign pool based on globs. The first match will be used.
|
|
1438
|
+
*
|
|
1439
|
+
* Format: [glob, pool-name]
|
|
1440
|
+
*
|
|
1441
|
+
* @default []
|
|
1442
|
+
* @example [
|
|
1443
|
+
* // all tests in "child_process" directory will run using "child_process" API
|
|
1444
|
+
* ['tests/child_process/**', 'child_process'],
|
|
1445
|
+
* // all other tests will run based on "threads" option, if you didn't specify other globs
|
|
1446
|
+
* // ...
|
|
1447
|
+
* ]
|
|
1448
|
+
*/
|
|
1449
|
+
poolMatchGlobs?: [string, Omit<VitestPool, 'browser'>][];
|
|
1450
|
+
/**
|
|
1451
|
+
* Update snapshot
|
|
1452
|
+
*
|
|
1453
|
+
* @default false
|
|
1454
|
+
*/
|
|
1455
|
+
update?: boolean;
|
|
1456
|
+
/**
|
|
1457
|
+
* Watch mode
|
|
1458
|
+
*
|
|
1459
|
+
* @default true
|
|
1460
|
+
*/
|
|
1461
|
+
watch?: boolean;
|
|
1462
|
+
/**
|
|
1463
|
+
* Project root
|
|
1464
|
+
*
|
|
1465
|
+
* @default process.cwd()
|
|
1466
|
+
*/
|
|
1467
|
+
root?: string;
|
|
1468
|
+
/**
|
|
1469
|
+
* Custom reporter for output. Can contain one or more built-in report names, reporter instances,
|
|
1470
|
+
* and/or paths to custom reporters.
|
|
1471
|
+
*/
|
|
1472
|
+
reporters?: Arrayable<BuiltinReporters | 'html' | Reporter | Omit<string, BuiltinReporters>>;
|
|
1473
|
+
/**
|
|
1474
|
+
* Write test results to a file when the --reporter=json` or `--reporter=junit` option is also specified.
|
|
1475
|
+
* Also definable individually per reporter by using an object instead.
|
|
1476
|
+
*/
|
|
1477
|
+
outputFile?: string | (Partial<Record<BuiltinReporters, string>> & Record<string, string>);
|
|
1478
|
+
/**
|
|
1479
|
+
* Enable multi-threading
|
|
1480
|
+
*
|
|
1481
|
+
* @default true
|
|
1482
|
+
*/
|
|
1483
|
+
threads?: boolean;
|
|
1484
|
+
/**
|
|
1485
|
+
* Maximum number of threads
|
|
1486
|
+
*
|
|
1487
|
+
* @default available CPUs
|
|
1488
|
+
*/
|
|
1489
|
+
maxThreads?: number;
|
|
1490
|
+
/**
|
|
1491
|
+
* Minimum number of threads
|
|
1492
|
+
*
|
|
1493
|
+
* @default available CPUs
|
|
1494
|
+
*/
|
|
1495
|
+
minThreads?: number;
|
|
1496
|
+
/**
|
|
1497
|
+
* Use Atomics to synchronize threads
|
|
1498
|
+
*
|
|
1499
|
+
* This can improve performance in some cases, but might cause segfault in older Node versions.
|
|
1500
|
+
*
|
|
1501
|
+
* @default false
|
|
1502
|
+
*/
|
|
1503
|
+
useAtomics?: boolean;
|
|
1504
|
+
/**
|
|
1505
|
+
* Default timeout of a test in milliseconds
|
|
1506
|
+
*
|
|
1507
|
+
* @default 5000
|
|
1508
|
+
*/
|
|
1509
|
+
testTimeout?: number;
|
|
1510
|
+
/**
|
|
1511
|
+
* Default timeout of a hook in milliseconds
|
|
1512
|
+
*
|
|
1513
|
+
* @default 10000
|
|
1514
|
+
*/
|
|
1515
|
+
hookTimeout?: number;
|
|
1516
|
+
/**
|
|
1517
|
+
* Default timeout to wait for close when Vitest shuts down, in milliseconds
|
|
1518
|
+
*
|
|
1519
|
+
* @default 1000
|
|
1520
|
+
*/
|
|
1521
|
+
teardownTimeout?: number;
|
|
1522
|
+
/**
|
|
1523
|
+
* Silent mode
|
|
1524
|
+
*
|
|
1525
|
+
* @default false
|
|
1526
|
+
*/
|
|
1527
|
+
silent?: boolean;
|
|
1528
|
+
/**
|
|
1529
|
+
* Hide logs for skipped tests
|
|
1530
|
+
*
|
|
1531
|
+
* @default false
|
|
1532
|
+
*/
|
|
1533
|
+
hideSkippedTests?: boolean;
|
|
1534
|
+
/**
|
|
1535
|
+
* Path to setup files
|
|
1536
|
+
*/
|
|
1537
|
+
setupFiles?: string | string[];
|
|
1538
|
+
/**
|
|
1539
|
+
* Path to global setup files
|
|
1540
|
+
*/
|
|
1541
|
+
globalSetup?: string | string[];
|
|
1542
|
+
/**
|
|
1543
|
+
* Glob pattern of file paths to be ignore from triggering watch rerun
|
|
1544
|
+
*/
|
|
1545
|
+
watchExclude?: string[];
|
|
1546
|
+
/**
|
|
1547
|
+
* Glob patter of file paths that will trigger the whole suite rerun
|
|
1548
|
+
*
|
|
1549
|
+
* Useful if you are testing calling CLI commands
|
|
1550
|
+
*
|
|
1551
|
+
* @default []
|
|
1552
|
+
*/
|
|
1553
|
+
forceRerunTriggers?: string[];
|
|
1554
|
+
/**
|
|
1555
|
+
* Isolate environment for each test file
|
|
1556
|
+
*
|
|
1557
|
+
* @default true
|
|
1558
|
+
*/
|
|
1559
|
+
isolate?: boolean;
|
|
1560
|
+
/**
|
|
1561
|
+
* Run tests inside a single thread.
|
|
1562
|
+
*
|
|
1563
|
+
* @default false
|
|
1564
|
+
*/
|
|
1565
|
+
singleThread?: boolean;
|
|
1566
|
+
/**
|
|
1567
|
+
* Coverage options
|
|
1568
|
+
*/
|
|
1569
|
+
coverage?: CoverageOptions;
|
|
1570
|
+
/**
|
|
1571
|
+
* run test names with the specified pattern
|
|
1572
|
+
*/
|
|
1573
|
+
testNamePattern?: string | RegExp;
|
|
1574
|
+
/**
|
|
1575
|
+
* Will call `.mockClear()` on all spies before each test
|
|
1576
|
+
* @default false
|
|
1577
|
+
*/
|
|
1578
|
+
clearMocks?: boolean;
|
|
1579
|
+
/**
|
|
1580
|
+
* Will call `.mockReset()` on all spies before each test
|
|
1581
|
+
* @default false
|
|
1582
|
+
*/
|
|
1583
|
+
mockReset?: boolean;
|
|
1584
|
+
/**
|
|
1585
|
+
* Will call `.mockRestore()` on all spies before each test
|
|
1586
|
+
* @default false
|
|
1587
|
+
*/
|
|
1588
|
+
restoreMocks?: boolean;
|
|
1589
|
+
/**
|
|
1590
|
+
* Will restore all global stubs to their original values before each test
|
|
1591
|
+
* @default false
|
|
1592
|
+
*/
|
|
1593
|
+
unstubGlobals?: boolean;
|
|
1594
|
+
/**
|
|
1595
|
+
* Will restore all env stubs to their original values before each test
|
|
1596
|
+
* @default false
|
|
1597
|
+
*/
|
|
1598
|
+
unstubEnvs?: boolean;
|
|
1599
|
+
/**
|
|
1600
|
+
* Serve API options.
|
|
1601
|
+
*
|
|
1602
|
+
* When set to true, the default port is 51204.
|
|
1603
|
+
*
|
|
1604
|
+
* @default false
|
|
1605
|
+
*/
|
|
1606
|
+
api?: boolean | number | ApiConfig;
|
|
1607
|
+
/**
|
|
1608
|
+
* Enable Vitest UI
|
|
1609
|
+
* @internal WIP
|
|
1610
|
+
*/
|
|
1611
|
+
ui?: boolean;
|
|
1612
|
+
/**
|
|
1613
|
+
* options for test in a browser environment
|
|
1614
|
+
* @experimental
|
|
1615
|
+
*
|
|
1616
|
+
* @default false
|
|
1617
|
+
*/
|
|
1618
|
+
browser?: BrowserConfigOptions;
|
|
1619
|
+
/**
|
|
1620
|
+
* Open UI automatically.
|
|
1621
|
+
*
|
|
1622
|
+
* @default true
|
|
1623
|
+
*/
|
|
1624
|
+
open?: boolean;
|
|
1625
|
+
/**
|
|
1626
|
+
* Base url for the UI
|
|
1627
|
+
*
|
|
1628
|
+
* @default '/__vitest__/'
|
|
1629
|
+
*/
|
|
1630
|
+
uiBase?: string;
|
|
1631
|
+
/**
|
|
1632
|
+
* Determine the transform method of modules
|
|
1633
|
+
*/
|
|
1634
|
+
transformMode?: {
|
|
1635
|
+
/**
|
|
1636
|
+
* Use SSR transform pipeline for the specified files.
|
|
1637
|
+
* Vite plugins will receive `ssr: true` flag when processing those files.
|
|
1638
|
+
*
|
|
1639
|
+
* @default [/\.([cm]?[jt]sx?|json)$/]
|
|
1640
|
+
*/
|
|
1641
|
+
ssr?: RegExp[];
|
|
1642
|
+
/**
|
|
1643
|
+
* First do a normal transform pipeline (targeting browser),
|
|
1644
|
+
* then then do a SSR rewrite to run the code in Node.
|
|
1645
|
+
* Vite plugins will receive `ssr: false` flag when processing those files.
|
|
1646
|
+
*
|
|
1647
|
+
* @default other than `ssr`
|
|
1648
|
+
*/
|
|
1649
|
+
web?: RegExp[];
|
|
1650
|
+
};
|
|
1651
|
+
/**
|
|
1652
|
+
* Format options for snapshot testing.
|
|
1653
|
+
*/
|
|
1654
|
+
snapshotFormat?: PrettyFormatOptions;
|
|
1655
|
+
/**
|
|
1656
|
+
* Resolve custom snapshot path
|
|
1657
|
+
*/
|
|
1658
|
+
resolveSnapshotPath?: (path: string, extension: string) => string;
|
|
1659
|
+
/**
|
|
1660
|
+
* Pass with no tests
|
|
1661
|
+
*/
|
|
1662
|
+
passWithNoTests?: boolean;
|
|
1663
|
+
/**
|
|
1664
|
+
* Allow tests and suites that are marked as only
|
|
1665
|
+
*/
|
|
1666
|
+
allowOnly?: boolean;
|
|
1667
|
+
/**
|
|
1668
|
+
* Show heap usage after each test. Useful for debugging memory leaks.
|
|
1669
|
+
*/
|
|
1670
|
+
logHeapUsage?: boolean;
|
|
1671
|
+
/**
|
|
1672
|
+
* Custom environment variables assigned to `process.env` before running tests.
|
|
1673
|
+
*/
|
|
1674
|
+
env?: Record<string, string>;
|
|
1675
|
+
/**
|
|
1676
|
+
* Options for @sinon/fake-timers
|
|
1677
|
+
*/
|
|
1678
|
+
fakeTimers?: FakeTimerInstallOpts;
|
|
1679
|
+
/**
|
|
1680
|
+
* Custom handler for console.log in tests.
|
|
1681
|
+
*
|
|
1682
|
+
* Return `false` to ignore the log.
|
|
1683
|
+
*/
|
|
1684
|
+
onConsoleLog?: (log: string, type: 'stdout' | 'stderr') => false | void;
|
|
1685
|
+
/**
|
|
1686
|
+
* Indicates if CSS files should be processed.
|
|
1687
|
+
*
|
|
1688
|
+
* When excluded, the CSS files will be replaced with empty strings to bypass the subsequent processing.
|
|
1689
|
+
*
|
|
1690
|
+
* @default { include: [], modules: { classNameStrategy: false } }
|
|
1691
|
+
*/
|
|
1692
|
+
css?: boolean | {
|
|
1693
|
+
include?: RegExp | RegExp[];
|
|
1694
|
+
exclude?: RegExp | RegExp[];
|
|
1695
|
+
modules?: {
|
|
1696
|
+
classNameStrategy?: CSSModuleScopeStrategy;
|
|
1697
|
+
};
|
|
1698
|
+
};
|
|
1699
|
+
/**
|
|
1700
|
+
* A number of tests that are allowed to run at the same time marked with `test.concurrent`.
|
|
1701
|
+
* @default 5
|
|
1702
|
+
*/
|
|
1703
|
+
maxConcurrency?: number;
|
|
1704
|
+
/**
|
|
1705
|
+
* Options for configuring cache policy.
|
|
1706
|
+
* @default { dir: 'node_modules/.vitest' }
|
|
1707
|
+
*/
|
|
1708
|
+
cache?: false | {
|
|
1709
|
+
dir?: string;
|
|
1710
|
+
};
|
|
1711
|
+
/**
|
|
1712
|
+
* Options for configuring the order of running tests.
|
|
1713
|
+
*/
|
|
1714
|
+
sequence?: SequenceOptions;
|
|
1715
|
+
/**
|
|
1716
|
+
* Specifies an `Object`, or an `Array` of `Object`,
|
|
1717
|
+
* which defines aliases used to replace values in `import` or `require` statements.
|
|
1718
|
+
* Will be merged with the default aliases inside `resolve.alias`.
|
|
1719
|
+
*/
|
|
1720
|
+
alias?: AliasOptions;
|
|
1721
|
+
/**
|
|
1722
|
+
* Ignore any unhandled errors that occur
|
|
1723
|
+
*/
|
|
1724
|
+
dangerouslyIgnoreUnhandledErrors?: boolean;
|
|
1725
|
+
/**
|
|
1726
|
+
* Options for configuring typechecking test environment.
|
|
1727
|
+
*/
|
|
1728
|
+
typecheck?: Partial<TypecheckConfig>;
|
|
1729
|
+
/**
|
|
1730
|
+
* The number of milliseconds after which a test is considered slow and reported as such in the results.
|
|
1731
|
+
*
|
|
1732
|
+
* @default 300
|
|
1733
|
+
*/
|
|
1734
|
+
slowTestThreshold?: number;
|
|
1735
|
+
/**
|
|
1736
|
+
* Path to a custom test runner.
|
|
1737
|
+
*/
|
|
1738
|
+
runner?: string;
|
|
1739
|
+
/**
|
|
1740
|
+
* Debug tests by opening `node:inspector` in worker / child process.
|
|
1741
|
+
* Provides similar experience as `--inspect` Node CLI argument.
|
|
1742
|
+
* Requires `singleThread: true` OR `threads: false`.
|
|
1743
|
+
*/
|
|
1744
|
+
inspect?: boolean;
|
|
1745
|
+
/**
|
|
1746
|
+
* Debug tests by opening `node:inspector` in worker / child process and wait for debugger to connect.
|
|
1747
|
+
* Provides similar experience as `--inspect-brk` Node CLI argument.
|
|
1748
|
+
* Requires `singleThread: true` OR `threads: false`.
|
|
1749
|
+
*/
|
|
1750
|
+
inspectBrk?: boolean;
|
|
1751
|
+
/**
|
|
1752
|
+
* Modify default Chai config. Vitest uses Chai for `expect` and `assert` matches.
|
|
1753
|
+
* https://github.com/chaijs/chai/blob/4.x.x/lib/chai/config.js
|
|
1754
|
+
*/
|
|
1755
|
+
chaiConfig?: ChaiConfig;
|
|
1756
|
+
/**
|
|
1757
|
+
* Stop test execution when given number of tests have failed.
|
|
1758
|
+
*/
|
|
1759
|
+
bail?: number;
|
|
1760
|
+
}
|
|
1761
|
+
interface TypecheckConfig {
|
|
1762
|
+
/**
|
|
1763
|
+
* What tools to use for type checking.
|
|
1764
|
+
*/
|
|
1765
|
+
checker: 'tsc' | 'vue-tsc' | (string & Record<never, never>);
|
|
1766
|
+
/**
|
|
1767
|
+
* Pattern for files that should be treated as test files
|
|
1768
|
+
*/
|
|
1769
|
+
include: string[];
|
|
1770
|
+
/**
|
|
1771
|
+
* Pattern for files that should not be treated as test files
|
|
1772
|
+
*/
|
|
1773
|
+
exclude: string[];
|
|
1774
|
+
/**
|
|
1775
|
+
* Check JS files that have `@ts-check` comment.
|
|
1776
|
+
* If you have it enabled in tsconfig, this will not overwrite it.
|
|
1777
|
+
*/
|
|
1778
|
+
allowJs?: boolean;
|
|
1779
|
+
/**
|
|
1780
|
+
* Do not fail, if Vitest found errors outside the test files.
|
|
1781
|
+
*/
|
|
1782
|
+
ignoreSourceErrors?: boolean;
|
|
1783
|
+
/**
|
|
1784
|
+
* Path to tsconfig, relative to the project root.
|
|
1785
|
+
*/
|
|
1786
|
+
tsconfig?: string;
|
|
1787
|
+
}
|
|
1788
|
+
interface UserConfig extends InlineConfig {
|
|
1789
|
+
/**
|
|
1790
|
+
* Path to the config file.
|
|
1791
|
+
*
|
|
1792
|
+
* Default resolving to `vitest.config.*`, `vite.config.*`
|
|
1793
|
+
*
|
|
1794
|
+
* Setting to `false` will disable config resolving.
|
|
1795
|
+
*/
|
|
1796
|
+
config?: string | false | undefined;
|
|
1797
|
+
/**
|
|
1798
|
+
* Use happy-dom
|
|
1799
|
+
*/
|
|
1800
|
+
dom?: boolean;
|
|
1801
|
+
/**
|
|
1802
|
+
* Run tests that cover a list of source files
|
|
1803
|
+
*/
|
|
1804
|
+
related?: string[] | string;
|
|
1805
|
+
/**
|
|
1806
|
+
* Overrides Vite mode
|
|
1807
|
+
* @default 'test'
|
|
1808
|
+
*/
|
|
1809
|
+
mode?: string;
|
|
1810
|
+
/**
|
|
1811
|
+
* Runs tests that are affected by the changes in the repository, or between specified branch or commit hash
|
|
1812
|
+
* Requires initialized git repository
|
|
1813
|
+
* @default false
|
|
1814
|
+
*/
|
|
1815
|
+
changed?: boolean | string;
|
|
1816
|
+
/**
|
|
1817
|
+
* Test suite shard to execute in a format of <index>/<count>.
|
|
1818
|
+
* Will divide tests into a `count` numbers, and run only the `indexed` part.
|
|
1819
|
+
* Cannot be used with enabled watch.
|
|
1820
|
+
* @example --shard=2/3
|
|
1821
|
+
*/
|
|
1822
|
+
shard?: string;
|
|
1823
|
+
}
|
|
1824
|
+
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'browser' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'benchmark' | 'shard' | 'cache' | 'sequence' | 'typecheck' | 'runner'> {
|
|
1825
|
+
mode: VitestRunMode;
|
|
1826
|
+
base?: string;
|
|
1827
|
+
config?: string;
|
|
1828
|
+
filters?: string[];
|
|
1829
|
+
testNamePattern?: RegExp;
|
|
1830
|
+
related?: string[];
|
|
1831
|
+
coverage: ResolvedCoverageOptions;
|
|
1832
|
+
snapshotOptions: SnapshotStateOptions;
|
|
1833
|
+
browser: ResolvedBrowserOptions;
|
|
1834
|
+
reporters: (Reporter | BuiltinReporters)[];
|
|
1835
|
+
defines: Record<string, any>;
|
|
1836
|
+
api?: ApiConfig;
|
|
1837
|
+
benchmark?: Required<Omit<BenchmarkUserOptions, 'outputFile'>> & {
|
|
1838
|
+
outputFile?: BenchmarkUserOptions['outputFile'];
|
|
1839
|
+
};
|
|
1840
|
+
shard?: {
|
|
1841
|
+
index: number;
|
|
1842
|
+
count: number;
|
|
1843
|
+
};
|
|
1844
|
+
cache: {
|
|
1845
|
+
dir: string;
|
|
1846
|
+
} | false;
|
|
1847
|
+
sequence: {
|
|
1848
|
+
sequencer: TestSequencerConstructor;
|
|
1849
|
+
hooks: SequenceHooks;
|
|
1850
|
+
setupFiles: SequenceSetupFiles;
|
|
1851
|
+
shuffle?: boolean;
|
|
1852
|
+
seed: number;
|
|
1853
|
+
};
|
|
1854
|
+
typecheck: TypecheckConfig;
|
|
1855
|
+
runner?: string;
|
|
1856
|
+
}
|
|
1857
|
+
type ProjectConfig = Omit<UserConfig, 'sequencer' | 'shard' | 'watch' | 'run' | 'cache' | 'update' | 'reporters' | 'outputFile' | 'maxThreads' | 'minThreads' | 'useAtomics' | 'teardownTimeout' | 'silent' | 'watchExclude' | 'forceRerunTriggers' | 'testNamePattern' | 'ui' | 'open' | 'uiBase' | 'snapshotFormat' | 'resolveSnapshotPath' | 'passWithNoTests' | 'onConsoleLog' | 'dangerouslyIgnoreUnhandledErrors' | 'slowTestThreshold' | 'inspect' | 'inspectBrk' | 'deps' | 'coverage'> & {
|
|
1858
|
+
sequencer?: Omit<SequenceOptions, 'sequencer' | 'seed'>;
|
|
1859
|
+
deps?: Omit<DepsOptions, 'registerNodeLoader'>;
|
|
1860
|
+
};
|
|
1861
|
+
type RuntimeConfig = Pick<UserConfig, 'allowOnly' | 'testTimeout' | 'hookTimeout' | 'clearMocks' | 'mockReset' | 'restoreMocks' | 'fakeTimers' | 'maxConcurrency'> & {
|
|
1862
|
+
sequence?: {
|
|
1863
|
+
hooks?: SequenceHooks;
|
|
1864
|
+
};
|
|
1865
|
+
};
|
|
1866
|
+
|
|
1867
|
+
type VitestInlineConfig = InlineConfig;
|
|
1868
|
+
declare module 'vite' {
|
|
1869
|
+
interface UserConfig {
|
|
1870
|
+
/**
|
|
1871
|
+
* Options for Vitest
|
|
1872
|
+
*/
|
|
1873
|
+
test?: VitestInlineConfig;
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1876
|
+
|
|
1877
|
+
declare module '@vitest/expect' {
|
|
1878
|
+
interface MatcherState {
|
|
1879
|
+
environment: VitestEnvironment;
|
|
1880
|
+
snapshotState: SnapshotState;
|
|
1881
|
+
}
|
|
1882
|
+
interface ExpectStatic {
|
|
1883
|
+
addSnapshotSerializer(plugin: Plugin): void;
|
|
1884
|
+
}
|
|
1885
|
+
interface Assertion<T> {
|
|
1886
|
+
matchSnapshot<U extends {
|
|
1887
|
+
[P in keyof T]: any;
|
|
1888
|
+
}>(snapshot: Partial<U>, message?: string): void;
|
|
1889
|
+
matchSnapshot(message?: string): void;
|
|
1890
|
+
toMatchSnapshot<U extends {
|
|
1891
|
+
[P in keyof T]: any;
|
|
1892
|
+
}>(snapshot: Partial<U>, message?: string): void;
|
|
1893
|
+
toMatchSnapshot(message?: string): void;
|
|
1894
|
+
toMatchInlineSnapshot<U extends {
|
|
1895
|
+
[P in keyof T]: any;
|
|
1896
|
+
}>(properties: Partial<U>, snapshot?: string, message?: string): void;
|
|
1897
|
+
toMatchInlineSnapshot(snapshot?: string, message?: string): void;
|
|
1898
|
+
toThrowErrorMatchingSnapshot(message?: string): void;
|
|
1899
|
+
toThrowErrorMatchingInlineSnapshot(snapshot?: string, message?: string): void;
|
|
1900
|
+
toMatchFileSnapshot(filepath: string, message?: string): Promise<void>;
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
declare module '@vitest/runner' {
|
|
1904
|
+
interface TestContext {
|
|
1905
|
+
expect: ExpectStatic;
|
|
1906
|
+
}
|
|
1907
|
+
interface File {
|
|
1908
|
+
prepareDuration?: number;
|
|
1909
|
+
environmentLoad?: number;
|
|
1910
|
+
}
|
|
1911
|
+
interface TaskBase {
|
|
1912
|
+
logs?: UserConsoleLog[];
|
|
1913
|
+
}
|
|
1914
|
+
interface TaskResult {
|
|
1915
|
+
benchmark?: BenchmarkResult;
|
|
1916
|
+
}
|
|
1917
|
+
}
|
|
1918
|
+
|
|
1919
|
+
type RawErrsMap = Map<string, TscErrorInfo[]>;
|
|
1920
|
+
interface TscErrorInfo {
|
|
1921
|
+
filePath: string;
|
|
1922
|
+
errCode: number;
|
|
1923
|
+
errMsg: string;
|
|
1924
|
+
line: number;
|
|
1925
|
+
column: number;
|
|
1926
|
+
}
|
|
1927
|
+
interface CollectLineNumbers {
|
|
1928
|
+
target: number;
|
|
1929
|
+
next: number;
|
|
1930
|
+
prev?: number;
|
|
1931
|
+
}
|
|
1932
|
+
type CollectLines = {
|
|
1933
|
+
[key in keyof CollectLineNumbers]: string;
|
|
1934
|
+
};
|
|
1935
|
+
interface RootAndTarget {
|
|
1936
|
+
root: string;
|
|
1937
|
+
targetAbsPath: string;
|
|
1938
|
+
}
|
|
1939
|
+
type Context = RootAndTarget & {
|
|
1940
|
+
rawErrsMap: RawErrsMap;
|
|
1941
|
+
openedDirs: Set<string>;
|
|
1942
|
+
lastActivePath?: string;
|
|
1943
|
+
};
|
|
1944
|
+
|
|
1945
|
+
export { CoverageOptions as $, AfterSuiteRunMeta as A, BenchmarkAPI as B, ChaiConfig as C, Arrayable as D, EnvironmentOptions as E, FakeTimerInstallOpts as F, ArgumentsType$1 as G, MutableArray as H, InlineConfig as I, JSDOMOptions as J, Constructable as K, ModuleCache as L, MockFactoryWithHelper as M, Nullable as N, EnvironmentReturn as O, ProjectConfig as P, Environment as Q, RuntimeConfig as R, OnServerRestartHandler as S, TscErrorInfo as T, UserConsoleLog as U, VitestEnvironment as V, WorkerContext as W, CoverageProvider as X, ReportContext as Y, CoverageProviderModule as Z, CoverageReporter as _, ResolvedConfig as a, ResolvedCoverageOptions as a0, BaseCoverageOptions as a1, CoverageIstanbulOptions as a2, CoverageC8Options as a3, CustomProviderOptions as a4, BenchmarkUserOptions as a5, Benchmark as a6, BenchmarkResult as a7, BenchFunction as a8, MockFactory as a9, MockMap as aa, TestSequencer as ab, WorkspaceSpec as ac, WorkspaceProject as ad, startVitest as ae, TestSequencerConstructor as af, HtmlOptions as ag, FileOptions as ah, CloverOptions as ai, CoberturaOptions as aj, HtmlSpaOptions as ak, LcovOptions as al, LcovOnlyOptions as am, TeamcityOptions as an, TextOptions as ao, ProjectOptions as ap, ModuleGraphData as b, Reporter as c, createExpect as d, RawErrsMap as e, CollectLineNumbers as f, globalExpect as g, CollectLines as h, RootAndTarget as i, Context as j, BuiltinEnvironment as k, VitestPool as l, CSSModuleScopeStrategy as m, ApiConfig as n, VitestRunMode as o, TypecheckConfig as p, UserConfig as q, RuntimeRPC as r, setupChaiConfig as s, RunnerRPC as t, ContextTestEnvironment as u, ContextRPC as v, Vitest as w, ResolveIdFunction as x, WorkerGlobalState as y, Awaitable as z };
|