vitest 0.7.6 → 0.7.9
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/dist/{chunk-api-setup.e20120cf.js → chunk-api-setup.293836c1.js} +6 -6
- package/dist/chunk-defaults.720fd914.js +1 -1
- package/dist/{chunk-integrations-globals.cd2261c2.js → chunk-integrations-globals.06d5e380.js} +2 -2
- package/dist/{chunk-runtime-chain.ff1c4d60.js → chunk-runtime-chain.7032872a.js} +9 -9
- package/dist/{chunk-utils-path.577ffb7b.js → chunk-utils-path.bd53cafb.js} +3 -3
- package/dist/{chunk-vite-node-externalize.fe4b860d.js → chunk-vite-node-externalize.211a5067.js} +41 -25
- package/dist/{chunk-vite-node-utils.45af7aa1.js → chunk-vite-node-utils.71f7ea0f.js} +14 -10
- package/dist/cli.js +4 -4
- package/dist/config.d.ts +3 -904
- package/dist/entry.js +9 -9
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/jest-mock.js +2 -2
- package/dist/node.d.ts +4 -1
- package/dist/node.js +3 -3
- package/dist/worker.js +4 -4
- package/package.json +6 -6
package/dist/config.d.ts
CHANGED
|
@@ -1,911 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE file in the root directory of this source tree.
|
|
8
|
-
*/
|
|
9
|
-
declare type Colors = {
|
|
10
|
-
comment: {
|
|
11
|
-
close: string;
|
|
12
|
-
open: string;
|
|
13
|
-
};
|
|
14
|
-
content: {
|
|
15
|
-
close: string;
|
|
16
|
-
open: string;
|
|
17
|
-
};
|
|
18
|
-
prop: {
|
|
19
|
-
close: string;
|
|
20
|
-
open: string;
|
|
21
|
-
};
|
|
22
|
-
tag: {
|
|
23
|
-
close: string;
|
|
24
|
-
open: string;
|
|
25
|
-
};
|
|
26
|
-
value: {
|
|
27
|
-
close: string;
|
|
28
|
-
open: string;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
declare type Indent = (arg0: string) => string;
|
|
32
|
-
declare type Refs = Array<unknown>;
|
|
33
|
-
declare type Print = (arg0: unknown) => string;
|
|
34
|
-
declare type ThemeReceived = {
|
|
35
|
-
comment?: string;
|
|
36
|
-
content?: string;
|
|
37
|
-
prop?: string;
|
|
38
|
-
tag?: string;
|
|
39
|
-
value?: string;
|
|
40
|
-
};
|
|
41
|
-
declare type CompareKeys = ((a: string, b: string) => number) | undefined;
|
|
42
|
-
interface PrettyFormatOptions {
|
|
43
|
-
callToJSON?: boolean;
|
|
44
|
-
compareKeys?: CompareKeys;
|
|
45
|
-
escapeRegex?: boolean;
|
|
46
|
-
escapeString?: boolean;
|
|
47
|
-
highlight?: boolean;
|
|
48
|
-
indent?: number;
|
|
49
|
-
maxDepth?: number;
|
|
50
|
-
min?: boolean;
|
|
51
|
-
plugins?: Plugins;
|
|
52
|
-
printBasicPrototype?: boolean;
|
|
53
|
-
printFunctionName?: boolean;
|
|
54
|
-
theme?: ThemeReceived;
|
|
55
|
-
}
|
|
56
|
-
declare type OptionsReceived = PrettyFormatOptions;
|
|
57
|
-
declare type Config = {
|
|
58
|
-
callToJSON: boolean;
|
|
59
|
-
compareKeys: CompareKeys;
|
|
60
|
-
colors: Colors;
|
|
61
|
-
escapeRegex: boolean;
|
|
62
|
-
escapeString: boolean;
|
|
63
|
-
indent: string;
|
|
64
|
-
maxDepth: number;
|
|
65
|
-
min: boolean;
|
|
66
|
-
plugins: Plugins;
|
|
67
|
-
printBasicPrototype: boolean;
|
|
68
|
-
printFunctionName: boolean;
|
|
69
|
-
spacingInner: string;
|
|
70
|
-
spacingOuter: string;
|
|
71
|
-
};
|
|
72
|
-
declare type Printer = (val: unknown, config: Config, indentation: string, depth: number, refs: Refs, hasCalledToJSON?: boolean) => string;
|
|
73
|
-
declare type Test$1 = (arg0: any) => boolean;
|
|
74
|
-
declare type NewPlugin = {
|
|
75
|
-
serialize: (val: any, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer) => string;
|
|
76
|
-
test: Test$1;
|
|
77
|
-
};
|
|
78
|
-
declare type PluginOptions = {
|
|
79
|
-
edgeSpacing: string;
|
|
80
|
-
min: boolean;
|
|
81
|
-
spacing: string;
|
|
82
|
-
};
|
|
83
|
-
declare type OldPlugin = {
|
|
84
|
-
print: (val: unknown, print: Print, indent: Indent, options: PluginOptions, colors: Colors) => string;
|
|
85
|
-
test: Test$1;
|
|
86
|
-
};
|
|
87
|
-
declare type Plugin = NewPlugin | OldPlugin;
|
|
88
|
-
declare type Plugins = Array<Plugin>;
|
|
89
|
-
|
|
90
|
-
interface DepsHandlingOptions {
|
|
91
|
-
external?: (string | RegExp)[];
|
|
92
|
-
inline?: (string | RegExp)[];
|
|
93
|
-
/**
|
|
94
|
-
* Try to guess the CJS version of a package when it's invalid ESM
|
|
95
|
-
* @default false
|
|
96
|
-
*/
|
|
97
|
-
fallbackCJS?: boolean;
|
|
98
|
-
}
|
|
99
|
-
interface StartOfSourceMap {
|
|
100
|
-
file?: string;
|
|
101
|
-
sourceRoot?: string;
|
|
102
|
-
}
|
|
103
|
-
interface RawSourceMap extends StartOfSourceMap {
|
|
104
|
-
version: string;
|
|
105
|
-
sources: string[];
|
|
106
|
-
names: string[];
|
|
107
|
-
sourcesContent?: string[];
|
|
108
|
-
mappings: string;
|
|
109
|
-
}
|
|
110
|
-
interface FetchResult {
|
|
111
|
-
code?: string;
|
|
112
|
-
externalize?: string;
|
|
113
|
-
map?: RawSourceMap;
|
|
114
|
-
}
|
|
115
|
-
interface ViteNodeResolveId {
|
|
116
|
-
external?: boolean | 'absolute' | 'relative';
|
|
117
|
-
id: string;
|
|
118
|
-
meta?: Record<string, any> | null;
|
|
119
|
-
moduleSideEffects?: boolean | 'no-treeshake' | null;
|
|
120
|
-
syntheticNamedExports?: boolean | string | null;
|
|
121
|
-
}
|
|
122
|
-
interface ViteNodeServerOptions {
|
|
123
|
-
/**
|
|
124
|
-
* Inject inline sourcemap to modules
|
|
125
|
-
* @default 'inline'
|
|
126
|
-
*/
|
|
127
|
-
sourcemap?: 'inline' | boolean;
|
|
128
|
-
/**
|
|
129
|
-
* Deps handling
|
|
130
|
-
*/
|
|
131
|
-
deps?: DepsHandlingOptions;
|
|
132
|
-
/**
|
|
133
|
-
* Transform method for modules
|
|
134
|
-
*/
|
|
135
|
-
transformMode?: {
|
|
136
|
-
ssr?: RegExp[];
|
|
137
|
-
web?: RegExp[];
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
declare class ViteNodeServer {
|
|
142
|
-
server: ViteDevServer;
|
|
143
|
-
options: ViteNodeServerOptions;
|
|
144
|
-
private fetchPromiseMap;
|
|
145
|
-
private transformPromiseMap;
|
|
146
|
-
fetchCache: Map<string, {
|
|
147
|
-
timestamp: number;
|
|
148
|
-
result: FetchResult;
|
|
149
|
-
}>;
|
|
150
|
-
constructor(server: ViteDevServer, options?: ViteNodeServerOptions);
|
|
151
|
-
shouldExternalize(id: string): Promise<string | false>;
|
|
152
|
-
resolveId(id: string, importer?: string): Promise<ViteNodeResolveId | null>;
|
|
153
|
-
fetchModule(id: string): Promise<FetchResult>;
|
|
154
|
-
transformRequest(id: string): Promise<TransformResult | null | undefined>;
|
|
155
|
-
getTransformMode(id: string): "web" | "ssr";
|
|
156
|
-
private _fetchModule;
|
|
157
|
-
private _transformRequest;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
declare class SnapshotManager {
|
|
161
|
-
config: ResolvedConfig;
|
|
162
|
-
summary: SnapshotSummary;
|
|
163
|
-
constructor(config: ResolvedConfig);
|
|
164
|
-
clear(): void;
|
|
165
|
-
add(result: SnapshotResult): void;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
declare type RunWithFiles = (files: string[], invalidates?: string[]) => Promise<void>;
|
|
169
|
-
interface WorkerPool {
|
|
170
|
-
runTests: RunWithFiles;
|
|
171
|
-
collectTests: RunWithFiles;
|
|
172
|
-
close: () => Promise<void>;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
declare class StateManager {
|
|
176
|
-
filesMap: Map<string, File>;
|
|
177
|
-
idMap: Map<string, Task>;
|
|
178
|
-
taskFileMap: WeakMap<Task, File>;
|
|
179
|
-
getFiles(keys?: string[]): File[];
|
|
180
|
-
getFilepaths(): string[];
|
|
181
|
-
getFailedFilepaths(): string[];
|
|
182
|
-
collectFiles(files?: File[]): void;
|
|
183
|
-
updateId(task: Task): void;
|
|
184
|
-
updateTasks(packs: TaskResultPack[]): void;
|
|
185
|
-
updateUserLog(log: UserConsoleLog): void;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
declare class Vitest {
|
|
189
|
-
config: ResolvedConfig;
|
|
190
|
-
configOverride: Partial<ResolvedConfig> | undefined;
|
|
191
|
-
server: ViteDevServer;
|
|
192
|
-
state: StateManager;
|
|
193
|
-
snapshot: SnapshotManager;
|
|
194
|
-
reporters: Reporter[];
|
|
195
|
-
console: Console;
|
|
196
|
-
pool: WorkerPool | undefined;
|
|
197
|
-
outputStream: NodeJS.WriteStream & {
|
|
198
|
-
fd: 1;
|
|
199
|
-
};
|
|
200
|
-
errorStream: NodeJS.WriteStream & {
|
|
201
|
-
fd: 2;
|
|
202
|
-
};
|
|
203
|
-
vitenode: ViteNodeServer;
|
|
204
|
-
invalidates: Set<string>;
|
|
205
|
-
changedTests: Set<string>;
|
|
206
|
-
runningPromise?: Promise<void>;
|
|
207
|
-
closingPromise?: Promise<void>;
|
|
208
|
-
isFirstRun: boolean;
|
|
209
|
-
restartsCount: number;
|
|
210
|
-
private _onRestartListeners;
|
|
211
|
-
constructor();
|
|
212
|
-
setServer(options: UserConfig$1, server: ViteDevServer): Promise<void>;
|
|
213
|
-
getConfig(): ResolvedConfig;
|
|
214
|
-
start(filters?: string[]): Promise<void>;
|
|
215
|
-
private getTestDependencies;
|
|
216
|
-
filterTestsBySource(tests: string[]): Promise<string[]>;
|
|
217
|
-
runFiles(files: string[]): Promise<void>;
|
|
218
|
-
rerunFiles(files?: string[], trigger?: string): Promise<void>;
|
|
219
|
-
changeNamePattern(pattern: string, files?: string[], trigger?: string): Promise<void>;
|
|
220
|
-
returnFailed(): Promise<void>;
|
|
221
|
-
updateSnapshot(files?: string[]): Promise<void>;
|
|
222
|
-
log(...args: any[]): void;
|
|
223
|
-
error(...args: any[]): void;
|
|
224
|
-
private _rerunTimer;
|
|
225
|
-
private scheduleRerun;
|
|
226
|
-
private unregisterWatcher;
|
|
227
|
-
private registerWatcher;
|
|
228
|
-
/**
|
|
229
|
-
* @returns A value indicating whether rerun is needed (changedTests was mutated)
|
|
230
|
-
*/
|
|
231
|
-
private handleFileChanged;
|
|
232
|
-
close(): Promise<void>;
|
|
233
|
-
exit(force?: boolean): Promise<void>;
|
|
234
|
-
report<T extends keyof Reporter>(name: T, ...args: ArgumentsType<Reporter[T]>): Promise<void>;
|
|
235
|
-
globTestFiles(filters?: string[]): Promise<string[]>;
|
|
236
|
-
isTargetFile(id: string, source?: string): Promise<boolean>;
|
|
237
|
-
isInSourceTestFile(code: string): boolean;
|
|
238
|
-
printError(err: unknown): Promise<void>;
|
|
239
|
-
onServerRestarted(fn: () => void): void;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
declare abstract class BaseReporter implements Reporter {
|
|
243
|
-
start: number;
|
|
244
|
-
end: number;
|
|
245
|
-
watchFilters?: string[];
|
|
246
|
-
isTTY: boolean;
|
|
247
|
-
ctx: Vitest;
|
|
248
|
-
constructor();
|
|
249
|
-
onInit(ctx: Vitest): void;
|
|
250
|
-
relative(path: string): string;
|
|
251
|
-
onFinished(files?: File[]): Promise<void>;
|
|
252
|
-
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
253
|
-
onWatcherStart(): Promise<void>;
|
|
254
|
-
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
255
|
-
onUserConsoleLog(log: UserConsoleLog): void;
|
|
256
|
-
onServerRestart(): void;
|
|
257
|
-
reportSummary(files: File[]): Promise<void>;
|
|
258
|
-
private printTaskErrors;
|
|
259
|
-
registerUnhandledRejection(): void;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
interface ListRendererOptions {
|
|
263
|
-
renderSucceed?: boolean;
|
|
264
|
-
outputStream: NodeJS.WritableStream;
|
|
265
|
-
}
|
|
266
|
-
declare const createListRenderer: (_tasks: Task[], options: ListRendererOptions) => {
|
|
267
|
-
start(): any;
|
|
268
|
-
update(_tasks: Task[]): any;
|
|
269
|
-
stop(): Promise<any>;
|
|
270
|
-
clear(): void;
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
declare class DefaultReporter extends BaseReporter {
|
|
274
|
-
renderer?: ReturnType<typeof createListRenderer>;
|
|
275
|
-
rendererOptions: ListRendererOptions;
|
|
276
|
-
onCollected(): void;
|
|
277
|
-
onFinished(files?: File[]): Promise<void>;
|
|
278
|
-
onWatcherStart(): Promise<void>;
|
|
279
|
-
stopListRender(): Promise<void>;
|
|
280
|
-
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
281
|
-
onUserConsoleLog(log: UserConsoleLog): void;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
declare class DotReporter extends BaseReporter {
|
|
285
|
-
renderer?: ReturnType<typeof createListRenderer>;
|
|
286
|
-
onCollected(): void;
|
|
287
|
-
onFinished(files?: File[]): Promise<void>;
|
|
288
|
-
onWatcherStart(): Promise<void>;
|
|
289
|
-
stopListRender(): Promise<void>;
|
|
290
|
-
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
291
|
-
onUserConsoleLog(log: UserConsoleLog): void;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
declare class JsonReporter implements Reporter {
|
|
295
|
-
start: number;
|
|
296
|
-
ctx: Vitest;
|
|
297
|
-
onInit(ctx: Vitest): void;
|
|
298
|
-
protected logTasks(files: File[]): Promise<void>;
|
|
299
|
-
onFinished(files?: File[]): Promise<void>;
|
|
300
|
-
/**
|
|
301
|
-
* Writes the report to an output file if specified in the config,
|
|
302
|
-
* or logs it to the console otherwise.
|
|
303
|
-
* @param report
|
|
304
|
-
*/
|
|
305
|
-
writeReport(report: string): Promise<void>;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
declare class VerboseReporter extends DefaultReporter {
|
|
309
|
-
constructor();
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
declare class TapReporter implements Reporter {
|
|
313
|
-
protected ctx: Vitest;
|
|
314
|
-
private logger;
|
|
315
|
-
onInit(ctx: Vitest): void;
|
|
316
|
-
static getComment(task: Task): string;
|
|
317
|
-
private logErrorDetails;
|
|
318
|
-
protected logTasks(tasks: Task[]): void;
|
|
319
|
-
onFinished(files?: File[]): Promise<void>;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
declare class JUnitReporter implements Reporter {
|
|
323
|
-
private ctx;
|
|
324
|
-
private reportFile?;
|
|
325
|
-
private baseLog;
|
|
326
|
-
private logger;
|
|
327
|
-
onInit(ctx: Vitest): Promise<void>;
|
|
328
|
-
writeElement(name: string, attrs: Record<string, any>, children: () => Promise<void>): Promise<void>;
|
|
329
|
-
writeErrorDetails(error: ErrorWithDiff): Promise<void>;
|
|
330
|
-
writeLogs(task: Task, type: 'err' | 'out'): Promise<void>;
|
|
331
|
-
writeTasks(tasks: Task[], filename: string): Promise<void>;
|
|
332
|
-
onFinished(files?: File[]): Promise<void>;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
declare class TapFlatReporter extends TapReporter {
|
|
336
|
-
onInit(ctx: Vitest): void;
|
|
337
|
-
onFinished(files?: File[]): Promise<void>;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
declare const ReportersMap: {
|
|
341
|
-
default: typeof DefaultReporter;
|
|
342
|
-
verbose: typeof VerboseReporter;
|
|
343
|
-
dot: typeof DotReporter;
|
|
344
|
-
json: typeof JsonReporter;
|
|
345
|
-
tap: typeof TapReporter;
|
|
346
|
-
'tap-flat': typeof TapFlatReporter;
|
|
347
|
-
junit: typeof JUnitReporter;
|
|
348
|
-
};
|
|
349
|
-
declare type BuiltinReporters = keyof typeof ReportersMap;
|
|
350
|
-
|
|
351
|
-
declare type Awaitable<T> = T | PromiseLike<T>;
|
|
352
|
-
declare type Arrayable<T> = T | Array<T>;
|
|
353
|
-
declare type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never;
|
|
354
|
-
interface UserConsoleLog {
|
|
355
|
-
content: string;
|
|
356
|
-
type: 'stdout' | 'stderr';
|
|
357
|
-
taskId?: string;
|
|
358
|
-
time: number;
|
|
359
|
-
}
|
|
360
|
-
interface Position {
|
|
361
|
-
line: number;
|
|
362
|
-
column: number;
|
|
363
|
-
}
|
|
364
|
-
interface ParsedStack {
|
|
365
|
-
method: string;
|
|
366
|
-
file: string;
|
|
367
|
-
line: number;
|
|
368
|
-
column: number;
|
|
369
|
-
sourcePos?: Position;
|
|
370
|
-
}
|
|
371
|
-
interface ErrorWithDiff extends Error {
|
|
372
|
-
name: string;
|
|
373
|
-
nameStr?: string;
|
|
374
|
-
stack?: string;
|
|
375
|
-
stackStr?: string;
|
|
376
|
-
stacks?: ParsedStack[];
|
|
377
|
-
showDiff?: boolean;
|
|
378
|
-
actual?: any;
|
|
379
|
-
expected?: any;
|
|
380
|
-
operator?: string;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
declare type CoverageReporter = 'clover' | 'cobertura' | 'html-spa' | 'html' | 'json-summary' | 'json' | 'lcov' | 'lcovonly' | 'none' | 'teamcity' | 'text-lcov' | 'text-summary' | 'text';
|
|
384
|
-
interface C8Options {
|
|
385
|
-
/**
|
|
386
|
-
* Enable coverage, pass `--coverage` to enable
|
|
387
|
-
*
|
|
388
|
-
* @default false
|
|
389
|
-
*/
|
|
390
|
-
enabled?: boolean;
|
|
391
|
-
/**
|
|
392
|
-
* Directory to write coverage report to
|
|
393
|
-
*/
|
|
394
|
-
reportsDirectory?: string;
|
|
395
|
-
/**
|
|
396
|
-
* Clean coverage before running tests
|
|
397
|
-
*
|
|
398
|
-
* @default true
|
|
399
|
-
*/
|
|
400
|
-
clean?: boolean;
|
|
401
|
-
/**
|
|
402
|
-
* Clean coverage report on watch rerun
|
|
403
|
-
*
|
|
404
|
-
* @default false
|
|
405
|
-
*/
|
|
406
|
-
cleanOnRerun?: boolean;
|
|
407
|
-
/**
|
|
408
|
-
* Allow files from outside of your cwd.
|
|
409
|
-
*
|
|
410
|
-
* @default false
|
|
411
|
-
*/
|
|
412
|
-
allowExternal?: any;
|
|
413
|
-
/**
|
|
414
|
-
* Reporters
|
|
415
|
-
*
|
|
416
|
-
* @default 'text'
|
|
417
|
-
*/
|
|
418
|
-
reporter?: Arrayable<CoverageReporter>;
|
|
419
|
-
/**
|
|
420
|
-
* Exclude coverage under /node_modules/
|
|
421
|
-
*
|
|
422
|
-
* @default true
|
|
423
|
-
*/
|
|
424
|
-
excludeNodeModules?: boolean;
|
|
425
|
-
exclude?: string[];
|
|
426
|
-
include?: string[];
|
|
427
|
-
skipFull?: boolean;
|
|
428
|
-
extension?: string | string[];
|
|
429
|
-
all?: boolean;
|
|
430
|
-
100?: boolean;
|
|
431
|
-
lines?: number;
|
|
432
|
-
functions?: number;
|
|
433
|
-
branches?: number;
|
|
434
|
-
statements?: number;
|
|
435
|
-
}
|
|
436
|
-
interface ResolvedC8Options extends Required<C8Options> {
|
|
437
|
-
tempDirectory: string;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
interface JSDOMOptions {
|
|
441
|
-
/**
|
|
442
|
-
* The html content for the test.
|
|
443
|
-
*
|
|
444
|
-
* @default '<!DOCTYPE html>'
|
|
445
|
-
*/
|
|
446
|
-
html?: string | Buffer | ArrayBufferLike;
|
|
447
|
-
/**
|
|
448
|
-
* referrer just affects the value read from document.referrer.
|
|
449
|
-
* It defaults to no referrer (which reflects as the empty string).
|
|
450
|
-
*/
|
|
451
|
-
referrer?: string;
|
|
452
|
-
/**
|
|
453
|
-
* userAgent affects the value read from navigator.userAgent, as well as the User-Agent header sent while fetching subresources.
|
|
454
|
-
*
|
|
455
|
-
* @default `Mozilla/5.0 (${process.platform}) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/${jsdomVersion}`
|
|
456
|
-
*/
|
|
457
|
-
userAgent?: string;
|
|
458
|
-
/**
|
|
459
|
-
* url sets the value returned by window.location, document.URL, and document.documentURI,
|
|
460
|
-
* and affects things like resolution of relative URLs within the document
|
|
461
|
-
* and the same-origin restrictions and referrer used while fetching subresources.
|
|
462
|
-
*
|
|
463
|
-
* @default 'http://localhost:3000'.
|
|
464
|
-
*/
|
|
465
|
-
url?: string;
|
|
466
|
-
/**
|
|
467
|
-
* contentType affects the value read from document.contentType, and how the document is parsed: as HTML or as XML.
|
|
468
|
-
* Values that are not "text/html" or an XML mime type will throw.
|
|
469
|
-
*
|
|
470
|
-
* @default 'text/html'.
|
|
471
|
-
*/
|
|
472
|
-
contentType?: string;
|
|
473
|
-
/**
|
|
474
|
-
* The maximum size in code units for the separate storage areas used by localStorage and sessionStorage.
|
|
475
|
-
* Attempts to store data larger than this limit will cause a DOMException to be thrown. By default, it is set
|
|
476
|
-
* to 5,000,000 code units per origin, as inspired by the HTML specification.
|
|
477
|
-
*
|
|
478
|
-
* @default 5_000_000
|
|
479
|
-
*/
|
|
480
|
-
storageQuota?: number;
|
|
481
|
-
/**
|
|
482
|
-
* Enable console?
|
|
483
|
-
*
|
|
484
|
-
* @default false
|
|
485
|
-
*/
|
|
486
|
-
console?: boolean;
|
|
487
|
-
/**
|
|
488
|
-
* jsdom does not have the capability to render visual content, and will act like a headless browser by default.
|
|
489
|
-
* It provides hints to web pages through APIs such as document.hidden that their content is not visible.
|
|
490
|
-
*
|
|
491
|
-
* When the `pretendToBeVisual` option is set to `true`, jsdom will pretend that it is rendering and displaying
|
|
492
|
-
* content.
|
|
493
|
-
*
|
|
494
|
-
* @default true
|
|
495
|
-
*/
|
|
496
|
-
pretendToBeVisual?: boolean;
|
|
497
|
-
/**
|
|
498
|
-
* `includeNodeLocations` preserves the location info produced by the HTML parser,
|
|
499
|
-
* allowing you to retrieve it with the nodeLocation() method (described below).
|
|
500
|
-
*
|
|
501
|
-
* It defaults to false to give the best performance,
|
|
502
|
-
* and cannot be used with an XML content type since our XML parser does not support location info.
|
|
503
|
-
*
|
|
504
|
-
* @default false
|
|
505
|
-
*/
|
|
506
|
-
includeNodeLocations?: boolean | undefined;
|
|
507
|
-
/**
|
|
508
|
-
* @default 'dangerously'
|
|
509
|
-
*/
|
|
510
|
-
runScripts?: 'dangerously' | 'outside-only';
|
|
511
|
-
/**
|
|
512
|
-
* Enable CookieJar
|
|
513
|
-
*
|
|
514
|
-
* @default false
|
|
515
|
-
*/
|
|
516
|
-
cookieJar?: boolean;
|
|
517
|
-
resources?: 'usable' | any;
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
declare type RunMode = 'run' | 'skip' | 'only' | 'todo';
|
|
521
|
-
declare type TaskState = RunMode | 'pass' | 'fail';
|
|
522
|
-
interface TaskBase {
|
|
523
|
-
id: string;
|
|
524
|
-
name: string;
|
|
525
|
-
mode: RunMode;
|
|
526
|
-
concurrent?: boolean;
|
|
527
|
-
suite?: Suite;
|
|
528
|
-
file?: File;
|
|
529
|
-
result?: TaskResult;
|
|
530
|
-
logs?: UserConsoleLog[];
|
|
531
|
-
}
|
|
532
|
-
interface TaskResult {
|
|
533
|
-
state: TaskState;
|
|
534
|
-
duration?: number;
|
|
535
|
-
startTime?: number;
|
|
536
|
-
error?: ErrorWithDiff;
|
|
537
|
-
hooks?: Partial<Record<keyof SuiteHooks, TaskState>>;
|
|
538
|
-
}
|
|
539
|
-
declare type TaskResultPack = [id: string, result: TaskResult | undefined];
|
|
540
|
-
interface Suite extends TaskBase {
|
|
541
|
-
type: 'suite';
|
|
542
|
-
tasks: Task[];
|
|
543
|
-
}
|
|
544
|
-
interface File extends Suite {
|
|
545
|
-
filepath: string;
|
|
546
|
-
collectDuration?: number;
|
|
547
|
-
}
|
|
548
|
-
interface Test extends TaskBase {
|
|
549
|
-
type: 'test';
|
|
550
|
-
suite: Suite;
|
|
551
|
-
result?: TaskResult;
|
|
552
|
-
fails?: boolean;
|
|
553
|
-
}
|
|
554
|
-
declare type Task = Test | Suite | File;
|
|
555
|
-
declare type HookListener<T extends any[]> = (...args: T) => Awaitable<void>;
|
|
556
|
-
interface SuiteHooks {
|
|
557
|
-
beforeAll: HookListener<[Suite]>[];
|
|
558
|
-
afterAll: HookListener<[Suite]>[];
|
|
559
|
-
beforeEach: HookListener<[Test, Suite]>[];
|
|
560
|
-
afterEach: HookListener<[Test, Suite]>[];
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
interface Reporter {
|
|
564
|
-
onInit?(ctx: Vitest): void;
|
|
565
|
-
onCollected?: (files?: File[]) => Awaitable<void>;
|
|
566
|
-
onFinished?: (files?: File[]) => Awaitable<void>;
|
|
567
|
-
onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
|
|
568
|
-
onWatcherStart?: () => Awaitable<void>;
|
|
569
|
-
onWatcherRerun?: (files: string[], trigger?: string) => Awaitable<void>;
|
|
570
|
-
onServerRestart?: () => Awaitable<void>;
|
|
571
|
-
onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
declare type SnapshotUpdateState = 'all' | 'new' | 'none';
|
|
575
|
-
interface SnapshotStateOptions {
|
|
576
|
-
updateSnapshot: SnapshotUpdateState;
|
|
577
|
-
expand?: boolean;
|
|
578
|
-
snapshotFormat?: OptionsReceived;
|
|
579
|
-
}
|
|
580
|
-
interface SnapshotResult {
|
|
581
|
-
filepath: string;
|
|
582
|
-
added: number;
|
|
583
|
-
fileDeleted: boolean;
|
|
584
|
-
matched: number;
|
|
585
|
-
unchecked: number;
|
|
586
|
-
uncheckedKeys: Array<string>;
|
|
587
|
-
unmatched: number;
|
|
588
|
-
updated: number;
|
|
589
|
-
}
|
|
590
|
-
interface UncheckedSnapshot {
|
|
591
|
-
filePath: string;
|
|
592
|
-
keys: Array<string>;
|
|
593
|
-
}
|
|
594
|
-
interface SnapshotSummary {
|
|
595
|
-
added: number;
|
|
596
|
-
didUpdate: boolean;
|
|
597
|
-
failure: boolean;
|
|
598
|
-
filesAdded: number;
|
|
599
|
-
filesRemoved: number;
|
|
600
|
-
filesRemovedList: Array<string>;
|
|
601
|
-
filesUnmatched: number;
|
|
602
|
-
filesUpdated: number;
|
|
603
|
-
matched: number;
|
|
604
|
-
total: number;
|
|
605
|
-
unchecked: number;
|
|
606
|
-
uncheckedKeysByFile: Array<UncheckedSnapshot>;
|
|
607
|
-
unmatched: number;
|
|
608
|
-
updated: number;
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
declare type BuiltinEnvironment = 'node' | 'jsdom' | 'happy-dom';
|
|
612
|
-
declare type ApiConfig = Pick<CommonServerOptions, 'port' | 'strictPort' | 'host'>;
|
|
613
|
-
|
|
614
|
-
interface EnvironmentOptions {
|
|
615
|
-
/**
|
|
616
|
-
* jsdom options.
|
|
617
|
-
*/
|
|
618
|
-
jsdom?: JSDOMOptions;
|
|
619
|
-
}
|
|
620
|
-
interface InlineConfig {
|
|
621
|
-
/**
|
|
622
|
-
* Include globs for test files
|
|
623
|
-
*
|
|
624
|
-
* @default ['**\/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}']
|
|
625
|
-
*/
|
|
626
|
-
include?: string[];
|
|
627
|
-
/**
|
|
628
|
-
* Exclude globs for test files
|
|
629
|
-
* @default ['node_modules', 'dist', '.idea', '.git', '.cache']
|
|
630
|
-
*/
|
|
631
|
-
exclude?: string[];
|
|
632
|
-
/**
|
|
633
|
-
* Include globs for in-source test files
|
|
634
|
-
*
|
|
635
|
-
* @default []
|
|
636
|
-
*/
|
|
637
|
-
includeSource?: string[];
|
|
638
|
-
/**
|
|
639
|
-
* Handling for dependencies inlining or externalizing
|
|
640
|
-
*/
|
|
641
|
-
deps?: {
|
|
642
|
-
/**
|
|
643
|
-
* Externalize means that Vite will bypass the package to native Node.
|
|
644
|
-
*
|
|
645
|
-
* Externalized dependencies will not be applied Vite's transformers and resolvers.
|
|
646
|
-
* And does not support HMR on reload.
|
|
647
|
-
*
|
|
648
|
-
* Typically, packages under `node_modules` are externalized.
|
|
649
|
-
*/
|
|
650
|
-
external?: (string | RegExp)[];
|
|
651
|
-
/**
|
|
652
|
-
* Vite will process inlined modules.
|
|
653
|
-
*
|
|
654
|
-
* This could be helpful to handle packages that ship `.js` in ESM format (that Node can't handle).
|
|
655
|
-
*/
|
|
656
|
-
inline?: (string | RegExp)[];
|
|
657
|
-
/**
|
|
658
|
-
* Interpret CJS module's default as named exports
|
|
659
|
-
*
|
|
660
|
-
* @default true
|
|
661
|
-
*/
|
|
662
|
-
interopDefault?: boolean;
|
|
663
|
-
/**
|
|
664
|
-
* When a dependency is a valid ESM package, try to guess the cjs version based on the path.
|
|
665
|
-
* This will significantly improve the performance in huge repo, but might potentially
|
|
666
|
-
* cause some misalignment if a package have different logic in ESM and CJS mode.
|
|
667
|
-
*
|
|
668
|
-
* @default false
|
|
669
|
-
*/
|
|
670
|
-
fallbackCJS?: boolean;
|
|
671
|
-
};
|
|
672
|
-
/**
|
|
673
|
-
* Base directory to scan for the test files
|
|
674
|
-
*
|
|
675
|
-
* @default `config.root`
|
|
676
|
-
*/
|
|
677
|
-
dir?: string;
|
|
678
|
-
/**
|
|
679
|
-
* Register apis globally
|
|
680
|
-
*
|
|
681
|
-
* @default false
|
|
682
|
-
*/
|
|
683
|
-
globals?: boolean;
|
|
684
|
-
/**
|
|
685
|
-
* @deprecated
|
|
686
|
-
*/
|
|
687
|
-
global?: boolean;
|
|
688
|
-
/**
|
|
689
|
-
* Running environment
|
|
690
|
-
*
|
|
691
|
-
* Supports 'node', 'jsdom', 'happy-dom'
|
|
692
|
-
*
|
|
693
|
-
* @default 'node'
|
|
694
|
-
*/
|
|
695
|
-
environment?: BuiltinEnvironment;
|
|
696
|
-
/**
|
|
697
|
-
* Environment options.
|
|
698
|
-
*/
|
|
699
|
-
environmentOptions?: EnvironmentOptions;
|
|
700
|
-
/**
|
|
701
|
-
* Update snapshot
|
|
702
|
-
*
|
|
703
|
-
* @default false
|
|
704
|
-
*/
|
|
705
|
-
update?: boolean;
|
|
706
|
-
/**
|
|
707
|
-
* Watch mode
|
|
708
|
-
*
|
|
709
|
-
* @default true
|
|
710
|
-
*/
|
|
711
|
-
watch?: boolean;
|
|
712
|
-
/**
|
|
713
|
-
* Project root
|
|
714
|
-
*
|
|
715
|
-
* @default process.cwd()
|
|
716
|
-
*/
|
|
717
|
-
root?: string;
|
|
718
|
-
/**
|
|
719
|
-
* Custom reporter for output
|
|
720
|
-
*/
|
|
721
|
-
reporters?: Arrayable<BuiltinReporters | Reporter>;
|
|
722
|
-
/**
|
|
723
|
-
* diff output length
|
|
724
|
-
*/
|
|
725
|
-
outputTruncateLength?: number;
|
|
726
|
-
/**
|
|
727
|
-
* Write test results to a file when the --reporter=json option is also specified
|
|
728
|
-
*/
|
|
729
|
-
outputFile?: string;
|
|
730
|
-
/**
|
|
731
|
-
* Enable multi-threading
|
|
732
|
-
*
|
|
733
|
-
* @default true
|
|
734
|
-
*/
|
|
735
|
-
threads?: boolean;
|
|
736
|
-
/**
|
|
737
|
-
* Maximum number of threads
|
|
738
|
-
*
|
|
739
|
-
* @default available CPUs
|
|
740
|
-
*/
|
|
741
|
-
maxThreads?: number;
|
|
742
|
-
/**
|
|
743
|
-
* Minimum number of threads
|
|
744
|
-
*
|
|
745
|
-
* @default available CPUs
|
|
746
|
-
*/
|
|
747
|
-
minThreads?: number;
|
|
748
|
-
/**
|
|
749
|
-
* Default timeout of a test in milliseconds
|
|
750
|
-
*
|
|
751
|
-
* @default 5000
|
|
752
|
-
*/
|
|
753
|
-
testTimeout?: number;
|
|
754
|
-
/**
|
|
755
|
-
* Default timeout of a hook in milliseconds
|
|
756
|
-
*
|
|
757
|
-
* @default 10000
|
|
758
|
-
*/
|
|
759
|
-
hookTimeout?: number;
|
|
760
|
-
/**
|
|
761
|
-
* Silent mode
|
|
762
|
-
*
|
|
763
|
-
* @default false
|
|
764
|
-
*/
|
|
765
|
-
silent?: boolean;
|
|
766
|
-
/**
|
|
767
|
-
* Path to setup files
|
|
768
|
-
*/
|
|
769
|
-
setupFiles?: string | string[];
|
|
770
|
-
/**
|
|
771
|
-
* Path to global setup files
|
|
772
|
-
*/
|
|
773
|
-
globalSetup?: string | string[];
|
|
774
|
-
/**
|
|
775
|
-
* Pattern of file paths to be ignore from triggering watch rerun
|
|
776
|
-
*
|
|
777
|
-
* @default ['**\/node_modules\/**', '**\/dist/**']
|
|
778
|
-
*/
|
|
779
|
-
watchIgnore?: (string | RegExp)[];
|
|
780
|
-
/**
|
|
781
|
-
* Isolate environment for each test file
|
|
782
|
-
*
|
|
783
|
-
* @default true
|
|
784
|
-
*/
|
|
785
|
-
isolate?: boolean;
|
|
786
|
-
/**
|
|
787
|
-
* Coverage options
|
|
788
|
-
*/
|
|
789
|
-
coverage?: C8Options;
|
|
790
|
-
/**
|
|
791
|
-
* run test names with the specified pattern
|
|
792
|
-
*/
|
|
793
|
-
testNamePattern?: string | RegExp;
|
|
794
|
-
/**
|
|
795
|
-
* Will call `.mockClear()` on all spies before each test
|
|
796
|
-
* @default false
|
|
797
|
-
*/
|
|
798
|
-
clearMocks?: boolean;
|
|
799
|
-
/**
|
|
800
|
-
* Will call `.mockReset()` on all spies before each test
|
|
801
|
-
* @default false
|
|
802
|
-
*/
|
|
803
|
-
mockReset?: boolean;
|
|
804
|
-
/**
|
|
805
|
-
* Will call `.mockRestore()` on all spies before each test
|
|
806
|
-
* @default false
|
|
807
|
-
*/
|
|
808
|
-
restoreMocks?: boolean;
|
|
809
|
-
/**
|
|
810
|
-
* Serve API options.
|
|
811
|
-
*
|
|
812
|
-
* When set to true, the default port is 51204.
|
|
813
|
-
*
|
|
814
|
-
* @default false
|
|
815
|
-
*/
|
|
816
|
-
api?: boolean | number | ApiConfig;
|
|
817
|
-
/**
|
|
818
|
-
* Enable Vitest UI
|
|
819
|
-
* @internal WIP
|
|
820
|
-
*/
|
|
821
|
-
ui?: boolean;
|
|
822
|
-
/**
|
|
823
|
-
* Open UI automatically.
|
|
824
|
-
*
|
|
825
|
-
* @default true
|
|
826
|
-
*/
|
|
827
|
-
open?: boolean;
|
|
828
|
-
/**
|
|
829
|
-
* Base url for the UI
|
|
830
|
-
*
|
|
831
|
-
* @default '/__vitest__/'
|
|
832
|
-
*/
|
|
833
|
-
uiBase?: string;
|
|
834
|
-
/**
|
|
835
|
-
* Determine the transform method of modules
|
|
836
|
-
*/
|
|
837
|
-
transformMode?: {
|
|
838
|
-
/**
|
|
839
|
-
* Use SSR transform pipeline for the specified files.
|
|
840
|
-
* Vite plugins will receive `ssr: true` flag when processing those files.
|
|
841
|
-
*
|
|
842
|
-
* @default [/\.([cm]?[jt]sx?|json)$/]
|
|
843
|
-
*/
|
|
844
|
-
ssr?: RegExp[];
|
|
845
|
-
/**
|
|
846
|
-
* First do a normal transform pipeline (targeting browser),
|
|
847
|
-
* then then do a SSR rewrite to run the code in Node.
|
|
848
|
-
* Vite plugins will receive `ssr: false` flag when processing those files.
|
|
849
|
-
*
|
|
850
|
-
* @default other than `ssr`
|
|
851
|
-
*/
|
|
852
|
-
web?: RegExp[];
|
|
853
|
-
};
|
|
854
|
-
/**
|
|
855
|
-
* Format options for snapshot testing.
|
|
856
|
-
*/
|
|
857
|
-
snapshotFormat?: PrettyFormatOptions;
|
|
858
|
-
}
|
|
859
|
-
interface UserConfig$1 extends InlineConfig {
|
|
860
|
-
/**
|
|
861
|
-
* Path to the config file.
|
|
862
|
-
*
|
|
863
|
-
* Default resolving to one of:
|
|
864
|
-
* - `vitest.config.js`
|
|
865
|
-
* - `vitest.config.ts`
|
|
866
|
-
* - `vite.config.js`
|
|
867
|
-
* - `vite.config.ts`
|
|
868
|
-
*/
|
|
869
|
-
config?: string | undefined;
|
|
870
|
-
/**
|
|
871
|
-
* Use happy-dom
|
|
872
|
-
*/
|
|
873
|
-
dom?: boolean;
|
|
874
|
-
/**
|
|
875
|
-
* Pass with no tests
|
|
876
|
-
*/
|
|
877
|
-
passWithNoTests?: boolean;
|
|
878
|
-
/**
|
|
879
|
-
* Allow tests and suites that are marked as only
|
|
880
|
-
*/
|
|
881
|
-
allowOnly?: boolean;
|
|
882
|
-
/**
|
|
883
|
-
* Run tests that cover a list of source files
|
|
884
|
-
*/
|
|
885
|
-
related?: string[] | string;
|
|
886
|
-
/**
|
|
887
|
-
* Overrides Vite mode
|
|
888
|
-
* @default 'test'
|
|
889
|
-
*/
|
|
890
|
-
mode?: string;
|
|
891
|
-
}
|
|
892
|
-
interface ResolvedConfig extends Omit<Required<UserConfig$1>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters'> {
|
|
893
|
-
base?: string;
|
|
894
|
-
config?: string;
|
|
895
|
-
filters?: string[];
|
|
896
|
-
testNamePattern?: RegExp;
|
|
897
|
-
related?: string[];
|
|
898
|
-
coverage: ResolvedC8Options;
|
|
899
|
-
snapshotOptions: SnapshotStateOptions;
|
|
900
|
-
reporters: (Reporter | BuiltinReporters)[];
|
|
901
|
-
defines: Record<string, any>;
|
|
902
|
-
api?: ApiConfig;
|
|
903
|
-
}
|
|
1
|
+
import { UserConfig as UserConfig$2 } from 'vite';
|
|
2
|
+
import { UserConfig as UserConfig$1 } from 'vitest';
|
|
904
3
|
|
|
905
4
|
declare const configDefaults: UserConfig$1;
|
|
906
5
|
|
|
907
6
|
interface UserConfig extends UserConfig$2 {
|
|
908
|
-
test?:
|
|
7
|
+
test?: UserConfig$2['test'];
|
|
909
8
|
}
|
|
910
9
|
|
|
911
10
|
declare function defineConfig(config: UserConfig): UserConfig;
|