vitest 0.27.2 → 0.27.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/dist/browser.d.ts +3 -3
- package/dist/browser.js +12 -11
- package/dist/{chunk-api-setup.029198e3.js → chunk-api-setup.0a2398d8.js} +4 -3
- package/dist/{chunk-env-node.787e9561.js → chunk-env-node.ffd1183b.js} +26 -0
- package/dist/{chunk-integrations-coverage.44413252.js → chunk-integrations-coverage.18366936.js} +3 -1
- package/dist/{chunk-integrations-globals.0024ce21.js → chunk-integrations-globals.59b4d460.js} +7 -6
- package/dist/{chunk-mock-date.c543fa3e.js → chunk-mock-date.91595ccd.js} +3 -2
- package/dist/{chunk-node-git.125c9008.js → chunk-node-git.59caac18.js} +2 -1
- package/dist/{chunk-runtime-chain.2da9e75c.js → chunk-runtime-chain.07d16eac.js} +15 -16
- package/dist/{chunk-runtime-error.de671af0.js → chunk-runtime-error.f2062967.js} +1 -1
- package/dist/{chunk-runtime-mocker.58511c38.js → chunk-runtime-mocker.66533d65.js} +3 -3
- package/dist/{chunk-runtime-rpc.d709e91b.js → chunk-runtime-rpc.e79efa9a.js} +1 -1
- package/dist/{chunk-runtime-setup.35da9209.js → chunk-runtime-setup.8ca273cd.js} +17 -13
- package/dist/{chunk-snapshot-manager.ce714e21.js → chunk-snapshot-manager.d16903ef.js} +89 -4028
- package/dist/{chunk-utils-env.f4a39d2c.js → chunk-utils-env.4ebb0106.js} +1 -0
- package/dist/{chunk-utils-import.054ab315.js → chunk-utils-import.eb63557e.js} +3 -3
- package/dist/{chunk-utils-source-map.5f5d12cf.js → chunk-utils-source-map.832515f7.js} +2 -2
- package/dist/cli-wrapper.js +2 -1
- package/dist/cli.js +8 -6
- package/dist/config.cjs +10 -7
- package/dist/config.d.ts +16 -3
- package/dist/config.js +10 -8
- package/dist/entry.js +24 -13
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +1 -1
- package/dist/{index-50755efe.d.ts → index-2dd51af4.d.ts} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +8 -7
- package/dist/loader.js +5 -4
- package/dist/node.d.ts +2 -2
- package/dist/node.js +9 -7
- package/dist/suite.js +6 -5
- package/dist/{types-d97c72c7.d.ts → types-c1386a7d.d.ts} +332 -308
- package/dist/vendor-index.57682f0c.js +3964 -0
- package/dist/worker.js +11 -8
- package/package.json +7 -6
|
@@ -159,6 +159,282 @@ interface FakeTimerInstallOpts {
|
|
|
159
159
|
shouldClearNativeTimers?: boolean | undefined;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
+
type ChainableFunction<T extends string, Args extends any[], R = any, E = {}> = {
|
|
163
|
+
(...args: Args): R;
|
|
164
|
+
} & {
|
|
165
|
+
[x in T]: ChainableFunction<T, Args, R, E>;
|
|
166
|
+
} & {
|
|
167
|
+
fn: (this: Record<T, boolean | undefined>, ...args: Args) => R;
|
|
168
|
+
} & E;
|
|
169
|
+
|
|
170
|
+
interface BenchmarkUserOptions {
|
|
171
|
+
/**
|
|
172
|
+
* Include globs for benchmark test files
|
|
173
|
+
*
|
|
174
|
+
* @default ['**\/*.{bench,benchmark}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}']
|
|
175
|
+
*/
|
|
176
|
+
include?: string[];
|
|
177
|
+
/**
|
|
178
|
+
* Exclude globs for benchmark test files
|
|
179
|
+
* @default ['node_modules', 'dist', '.idea', '.git', '.cache']
|
|
180
|
+
*/
|
|
181
|
+
exclude?: string[];
|
|
182
|
+
/**
|
|
183
|
+
* Include globs for in-source benchmark test files
|
|
184
|
+
*
|
|
185
|
+
* @default []
|
|
186
|
+
*/
|
|
187
|
+
includeSource?: string[];
|
|
188
|
+
/**
|
|
189
|
+
* Custom reporter for output. Can contain one or more built-in report names, reporter instances,
|
|
190
|
+
* and/or paths to custom reporters
|
|
191
|
+
*/
|
|
192
|
+
reporters?: Arrayable<BenchmarkBuiltinReporters | Reporter>;
|
|
193
|
+
/**
|
|
194
|
+
* Write test results to a file when the `--reporter=json` option is also specified.
|
|
195
|
+
* Also definable individually per reporter by using an object instead.
|
|
196
|
+
*/
|
|
197
|
+
outputFile?: string | (Partial<Record<BenchmarkBuiltinReporters, string>> & Record<string, string>);
|
|
198
|
+
}
|
|
199
|
+
interface Benchmark extends TaskBase {
|
|
200
|
+
type: 'benchmark';
|
|
201
|
+
suite: Suite;
|
|
202
|
+
result?: TaskResult;
|
|
203
|
+
fails?: boolean;
|
|
204
|
+
task?: Task$1;
|
|
205
|
+
}
|
|
206
|
+
interface BenchmarkResult extends TaskResult$1 {
|
|
207
|
+
name: string;
|
|
208
|
+
rank: number;
|
|
209
|
+
}
|
|
210
|
+
type BenchFunction = (this: Bench) => Promise<void> | void;
|
|
211
|
+
type BenchmarkAPI = ChainableFunction<'skip' | 'only' | 'todo', [
|
|
212
|
+
name: string,
|
|
213
|
+
fn?: BenchFunction,
|
|
214
|
+
options?: Options
|
|
215
|
+
], void> & {
|
|
216
|
+
skipIf(condition: any): BenchmarkAPI;
|
|
217
|
+
runIf(condition: any): BenchmarkAPI;
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
type Awaitable<T> = T | PromiseLike<T>;
|
|
221
|
+
type Nullable<T> = T | null | undefined;
|
|
222
|
+
type Arrayable<T> = T | Array<T>;
|
|
223
|
+
type ArgumentsType$1<T> = T extends (...args: infer U) => any ? U : never;
|
|
224
|
+
type MergeInsertions<T> = T extends object ? {
|
|
225
|
+
[K in keyof T]: MergeInsertions<T[K]>;
|
|
226
|
+
} : T;
|
|
227
|
+
type DeepMerge<F, S> = MergeInsertions<{
|
|
228
|
+
[K in keyof F | keyof S]: K extends keyof S & keyof F ? DeepMerge<F[K], S[K]> : K extends keyof S ? S[K] : K extends keyof F ? F[K] : never;
|
|
229
|
+
}>;
|
|
230
|
+
type MutableArray<T extends readonly any[]> = {
|
|
231
|
+
-readonly [k in keyof T]: T[k];
|
|
232
|
+
};
|
|
233
|
+
interface Constructable {
|
|
234
|
+
new (...args: any[]): any;
|
|
235
|
+
}
|
|
236
|
+
interface ModuleCache {
|
|
237
|
+
promise?: Promise<any>;
|
|
238
|
+
exports?: any;
|
|
239
|
+
code?: string;
|
|
240
|
+
}
|
|
241
|
+
interface EnvironmentReturn {
|
|
242
|
+
teardown: (global: any) => Awaitable<void>;
|
|
243
|
+
}
|
|
244
|
+
interface Environment {
|
|
245
|
+
name: string;
|
|
246
|
+
setup(global: any, options: Record<string, any>): Awaitable<EnvironmentReturn>;
|
|
247
|
+
}
|
|
248
|
+
interface UserConsoleLog {
|
|
249
|
+
content: string;
|
|
250
|
+
type: 'stdout' | 'stderr';
|
|
251
|
+
taskId?: string;
|
|
252
|
+
time: number;
|
|
253
|
+
size: number;
|
|
254
|
+
}
|
|
255
|
+
interface ParsedStack {
|
|
256
|
+
method: string;
|
|
257
|
+
file: string;
|
|
258
|
+
line: number;
|
|
259
|
+
column: number;
|
|
260
|
+
}
|
|
261
|
+
interface ErrorWithDiff extends Error {
|
|
262
|
+
name: string;
|
|
263
|
+
nameStr?: string;
|
|
264
|
+
stack?: string;
|
|
265
|
+
stackStr?: string;
|
|
266
|
+
stacks?: ParsedStack[];
|
|
267
|
+
showDiff?: boolean;
|
|
268
|
+
actual?: any;
|
|
269
|
+
expected?: any;
|
|
270
|
+
operator?: string;
|
|
271
|
+
type?: string;
|
|
272
|
+
frame?: string;
|
|
273
|
+
}
|
|
274
|
+
interface ModuleGraphData {
|
|
275
|
+
graph: Record<string, string[]>;
|
|
276
|
+
externalized: string[];
|
|
277
|
+
inlined: string[];
|
|
278
|
+
}
|
|
279
|
+
type OnServerRestartHandler = (reason?: string) => Promise<void> | void;
|
|
280
|
+
|
|
281
|
+
type RunMode = 'run' | 'skip' | 'only' | 'todo';
|
|
282
|
+
type TaskState = RunMode | 'pass' | 'fail';
|
|
283
|
+
interface TaskBase {
|
|
284
|
+
id: string;
|
|
285
|
+
name: string;
|
|
286
|
+
mode: RunMode;
|
|
287
|
+
concurrent?: boolean;
|
|
288
|
+
shuffle?: boolean;
|
|
289
|
+
suite?: Suite;
|
|
290
|
+
file?: File;
|
|
291
|
+
result?: TaskResult;
|
|
292
|
+
retry?: number;
|
|
293
|
+
logs?: UserConsoleLog[];
|
|
294
|
+
meta?: any;
|
|
295
|
+
}
|
|
296
|
+
interface TaskResult {
|
|
297
|
+
state: TaskState;
|
|
298
|
+
duration?: number;
|
|
299
|
+
startTime?: number;
|
|
300
|
+
heap?: number;
|
|
301
|
+
/**
|
|
302
|
+
* @deprecated Use "errors" instead
|
|
303
|
+
*/
|
|
304
|
+
error?: ErrorWithDiff;
|
|
305
|
+
errors?: ErrorWithDiff[];
|
|
306
|
+
htmlError?: string;
|
|
307
|
+
hooks?: Partial<Record<keyof SuiteHooks, TaskState>>;
|
|
308
|
+
benchmark?: BenchmarkResult;
|
|
309
|
+
retryCount?: number;
|
|
310
|
+
}
|
|
311
|
+
type TaskResultPack = [id: string, result: TaskResult | undefined];
|
|
312
|
+
interface Suite extends TaskBase {
|
|
313
|
+
type: 'suite';
|
|
314
|
+
tasks: Task[];
|
|
315
|
+
filepath?: string;
|
|
316
|
+
benchmark?: Bench;
|
|
317
|
+
projectName?: string;
|
|
318
|
+
}
|
|
319
|
+
interface File extends Suite {
|
|
320
|
+
filepath: string;
|
|
321
|
+
collectDuration?: number;
|
|
322
|
+
setupDuration?: number;
|
|
323
|
+
}
|
|
324
|
+
interface Test<ExtraContext = {}> extends TaskBase {
|
|
325
|
+
type: 'test';
|
|
326
|
+
suite: Suite;
|
|
327
|
+
result?: TaskResult;
|
|
328
|
+
fails?: boolean;
|
|
329
|
+
context: TestContext & ExtraContext;
|
|
330
|
+
onFailed?: OnTestFailedHandler[];
|
|
331
|
+
}
|
|
332
|
+
type Task = Test | Suite | File | Benchmark;
|
|
333
|
+
type DoneCallback = (error?: any) => void;
|
|
334
|
+
type TestFunction<ExtraContext = {}> = (context: TestContext & ExtraContext) => Awaitable<any> | void;
|
|
335
|
+
type ExtractEachCallbackArgs<T extends ReadonlyArray<any>> = {
|
|
336
|
+
1: [T[0]];
|
|
337
|
+
2: [T[0], T[1]];
|
|
338
|
+
3: [T[0], T[1], T[2]];
|
|
339
|
+
4: [T[0], T[1], T[2], T[3]];
|
|
340
|
+
5: [T[0], T[1], T[2], T[3], T[4]];
|
|
341
|
+
6: [T[0], T[1], T[2], T[3], T[4], T[5]];
|
|
342
|
+
7: [T[0], T[1], T[2], T[3], T[4], T[5], T[6]];
|
|
343
|
+
8: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7]];
|
|
344
|
+
9: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7], T[8]];
|
|
345
|
+
10: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7], T[8], T[9]];
|
|
346
|
+
fallback: Array<T extends ReadonlyArray<infer U> ? U : any>;
|
|
347
|
+
}[T extends Readonly<[any]> ? 1 : T extends Readonly<[any, any]> ? 2 : T extends Readonly<[any, any, any]> ? 3 : T extends Readonly<[any, any, any, any]> ? 4 : T extends Readonly<[any, any, any, any, any]> ? 5 : T extends Readonly<[any, any, any, any, any, any]> ? 6 : T extends Readonly<[any, any, any, any, any, any, any]> ? 7 : T extends Readonly<[any, any, any, any, any, any, any, any]> ? 8 : T extends Readonly<[any, any, any, any, any, any, any, any, any]> ? 9 : T extends Readonly<[any, any, any, any, any, any, any, any, any, any]> ? 10 : 'fallback'];
|
|
348
|
+
interface SuiteEachFunction {
|
|
349
|
+
<T extends any[] | [any]>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T) => Awaitable<void>) => void;
|
|
350
|
+
<T extends ReadonlyArray<any>>(cases: ReadonlyArray<T>): (name: string, fn: (...args: ExtractEachCallbackArgs<T>) => Awaitable<void>) => void;
|
|
351
|
+
<T>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T[]) => Awaitable<void>) => void;
|
|
352
|
+
}
|
|
353
|
+
interface TestEachFunction {
|
|
354
|
+
<T extends any[] | [any]>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T) => Awaitable<void>, options?: number | TestOptions) => void;
|
|
355
|
+
<T extends ReadonlyArray<any>>(cases: ReadonlyArray<T>): (name: string, fn: (...args: ExtractEachCallbackArgs<T>) => Awaitable<void>, options?: number | TestOptions) => void;
|
|
356
|
+
<T>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T[]) => Awaitable<void>, options?: number | TestOptions) => void;
|
|
357
|
+
(...args: [TemplateStringsArray, ...any]): (name: string, fn: (...args: any[]) => Awaitable<void>, options?: number | TestOptions) => void;
|
|
358
|
+
}
|
|
359
|
+
type ChainableTestAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo' | 'fails', [
|
|
360
|
+
name: string,
|
|
361
|
+
fn?: TestFunction<ExtraContext>,
|
|
362
|
+
options?: number | TestOptions
|
|
363
|
+
], void, {
|
|
364
|
+
each: TestEachFunction;
|
|
365
|
+
<T extends ExtraContext>(name: string, fn?: TestFunction<T>, options?: number | TestOptions): void;
|
|
366
|
+
}>;
|
|
367
|
+
interface TestOptions {
|
|
368
|
+
/**
|
|
369
|
+
* Test timeout.
|
|
370
|
+
*/
|
|
371
|
+
timeout?: number;
|
|
372
|
+
/**
|
|
373
|
+
* Times to retry the test if fails. Useful for making flaky tests more stable.
|
|
374
|
+
* When retries is up, the last test error will be thrown.
|
|
375
|
+
*
|
|
376
|
+
* @default 1
|
|
377
|
+
*/
|
|
378
|
+
retry?: number;
|
|
379
|
+
}
|
|
380
|
+
type TestAPI<ExtraContext = {}> = ChainableTestAPI<ExtraContext> & {
|
|
381
|
+
each: TestEachFunction;
|
|
382
|
+
skipIf(condition: any): ChainableTestAPI<ExtraContext>;
|
|
383
|
+
runIf(condition: any): ChainableTestAPI<ExtraContext>;
|
|
384
|
+
};
|
|
385
|
+
type ChainableSuiteAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo' | 'shuffle', [
|
|
386
|
+
name: string,
|
|
387
|
+
factory?: SuiteFactory<ExtraContext>,
|
|
388
|
+
options?: number | TestOptions
|
|
389
|
+
], SuiteCollector<ExtraContext>, {
|
|
390
|
+
each: TestEachFunction;
|
|
391
|
+
<T extends ExtraContext>(name: string, factory?: SuiteFactory<T>): SuiteCollector<T>;
|
|
392
|
+
}>;
|
|
393
|
+
type SuiteAPI<ExtraContext = {}> = ChainableSuiteAPI<ExtraContext> & {
|
|
394
|
+
each: SuiteEachFunction;
|
|
395
|
+
skipIf(condition: any): ChainableSuiteAPI<ExtraContext>;
|
|
396
|
+
runIf(condition: any): ChainableSuiteAPI<ExtraContext>;
|
|
397
|
+
};
|
|
398
|
+
type HookListener<T extends any[], Return = void> = (...args: T) => Awaitable<Return>;
|
|
399
|
+
type HookCleanupCallback = (() => Awaitable<unknown>) | void;
|
|
400
|
+
interface SuiteHooks<ExtraContext = {}> {
|
|
401
|
+
beforeAll: HookListener<[Suite | File], HookCleanupCallback>[];
|
|
402
|
+
afterAll: HookListener<[Suite | File]>[];
|
|
403
|
+
beforeEach: HookListener<[TestContext & ExtraContext, Suite], HookCleanupCallback>[];
|
|
404
|
+
afterEach: HookListener<[TestContext & ExtraContext, Suite]>[];
|
|
405
|
+
}
|
|
406
|
+
interface SuiteCollector<ExtraContext = {}> {
|
|
407
|
+
readonly name: string;
|
|
408
|
+
readonly mode: RunMode;
|
|
409
|
+
type: 'collector';
|
|
410
|
+
test: TestAPI<ExtraContext>;
|
|
411
|
+
benchmark: BenchmarkAPI;
|
|
412
|
+
tasks: (Suite | Test | Benchmark | SuiteCollector<ExtraContext>)[];
|
|
413
|
+
collect: (file?: File) => Promise<Suite>;
|
|
414
|
+
clear: () => void;
|
|
415
|
+
on: <T extends keyof SuiteHooks<ExtraContext>>(name: T, ...fn: SuiteHooks<ExtraContext>[T]) => void;
|
|
416
|
+
}
|
|
417
|
+
type SuiteFactory<ExtraContext = {}> = (test: (name: string, fn: TestFunction<ExtraContext>) => void) => Awaitable<void>;
|
|
418
|
+
interface RuntimeContext {
|
|
419
|
+
tasks: (SuiteCollector | Test)[];
|
|
420
|
+
currentSuite: SuiteCollector | null;
|
|
421
|
+
}
|
|
422
|
+
interface TestContext {
|
|
423
|
+
/**
|
|
424
|
+
* Metadata of the current test
|
|
425
|
+
*/
|
|
426
|
+
meta: Readonly<Test>;
|
|
427
|
+
/**
|
|
428
|
+
* A expect instance bound to the test
|
|
429
|
+
*/
|
|
430
|
+
expect: Vi.ExpectStatic;
|
|
431
|
+
/**
|
|
432
|
+
* Extract hooks on test failed
|
|
433
|
+
*/
|
|
434
|
+
onTestFailed: (fn: OnTestFailedHandler) => void;
|
|
435
|
+
}
|
|
436
|
+
type OnTestFailedHandler = (result: TaskResult) => Awaitable<void>;
|
|
437
|
+
|
|
162
438
|
declare class SnapshotManager {
|
|
163
439
|
options: SnapshotStateOptions;
|
|
164
440
|
summary: SnapshotSummary;
|
|
@@ -440,7 +716,7 @@ declare abstract class BaseReporter implements Reporter {
|
|
|
440
716
|
start: number;
|
|
441
717
|
end: number;
|
|
442
718
|
watchFilters?: string[];
|
|
443
|
-
isTTY:
|
|
719
|
+
isTTY: boolean;
|
|
444
720
|
ctx: Vitest;
|
|
445
721
|
private _filesInWatchMode;
|
|
446
722
|
private _lastRunTimeout;
|
|
@@ -467,6 +743,11 @@ declare abstract class BaseReporter implements Reporter {
|
|
|
467
743
|
registerUnhandledRejection(): void;
|
|
468
744
|
}
|
|
469
745
|
|
|
746
|
+
declare class BasicReporter extends BaseReporter {
|
|
747
|
+
isTTY: boolean;
|
|
748
|
+
reportSummary(files: File[]): Promise<void>;
|
|
749
|
+
}
|
|
750
|
+
|
|
470
751
|
interface ListRendererOptions$1 {
|
|
471
752
|
renderSucceed?: boolean;
|
|
472
753
|
logger: Logger;
|
|
@@ -608,6 +889,7 @@ type BenchmarkBuiltinReporters = keyof typeof BenchmarkReportsMap;
|
|
|
608
889
|
|
|
609
890
|
declare const ReportersMap: {
|
|
610
891
|
default: typeof DefaultReporter;
|
|
892
|
+
basic: typeof BasicReporter;
|
|
611
893
|
verbose: typeof VerboseReporter;
|
|
612
894
|
dot: typeof DotReporter;
|
|
613
895
|
json: typeof JsonReporter$1;
|
|
@@ -799,90 +1081,29 @@ interface PluginContextMeta {
|
|
|
799
1081
|
watchMode: boolean;
|
|
800
1082
|
}
|
|
801
1083
|
|
|
802
|
-
interface ResolvedId extends ModuleOptions {
|
|
803
|
-
external: boolean | 'absolute';
|
|
804
|
-
id: string;
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
type IsExternal = (
|
|
808
|
-
source: string,
|
|
809
|
-
importer: string | undefined,
|
|
810
|
-
isResolved: boolean
|
|
811
|
-
) => boolean;
|
|
812
|
-
|
|
813
|
-
interface TransformPluginContext extends PluginContext {
|
|
814
|
-
getCombinedSourcemap: () => SourceMap;
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
type TransformResult = string | null | void | Partial<SourceDescription>;
|
|
818
|
-
type PreserveEntrySignaturesOption = false | 'strict' | 'allow-extension' | 'exports-only';
|
|
819
|
-
|
|
820
|
-
interface AcornNode {
|
|
821
|
-
end: number;
|
|
822
|
-
start: number;
|
|
823
|
-
type: string;
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
type Awaitable<T> = T | PromiseLike<T>;
|
|
827
|
-
type Nullable<T> = T | null | undefined;
|
|
828
|
-
type Arrayable<T> = T | Array<T>;
|
|
829
|
-
type ArgumentsType$1<T> = T extends (...args: infer U) => any ? U : never;
|
|
830
|
-
type MergeInsertions<T> = T extends object ? {
|
|
831
|
-
[K in keyof T]: MergeInsertions<T[K]>;
|
|
832
|
-
} : T;
|
|
833
|
-
type DeepMerge<F, S> = MergeInsertions<{
|
|
834
|
-
[K in keyof F | keyof S]: K extends keyof S & keyof F ? DeepMerge<F[K], S[K]> : K extends keyof S ? S[K] : K extends keyof F ? F[K] : never;
|
|
835
|
-
}>;
|
|
836
|
-
type MutableArray<T extends readonly any[]> = {
|
|
837
|
-
-readonly [k in keyof T]: T[k];
|
|
838
|
-
};
|
|
839
|
-
interface Constructable {
|
|
840
|
-
new (...args: any[]): any;
|
|
841
|
-
}
|
|
842
|
-
interface ModuleCache {
|
|
843
|
-
promise?: Promise<any>;
|
|
844
|
-
exports?: any;
|
|
845
|
-
code?: string;
|
|
846
|
-
}
|
|
847
|
-
interface EnvironmentReturn {
|
|
848
|
-
teardown: (global: any) => Awaitable<void>;
|
|
849
|
-
}
|
|
850
|
-
interface Environment {
|
|
851
|
-
name: string;
|
|
852
|
-
setup(global: any, options: Record<string, any>): Awaitable<EnvironmentReturn>;
|
|
853
|
-
}
|
|
854
|
-
interface UserConsoleLog {
|
|
855
|
-
content: string;
|
|
856
|
-
type: 'stdout' | 'stderr';
|
|
857
|
-
taskId?: string;
|
|
858
|
-
time: number;
|
|
859
|
-
size: number;
|
|
860
|
-
}
|
|
861
|
-
interface ParsedStack {
|
|
862
|
-
method: string;
|
|
863
|
-
file: string;
|
|
864
|
-
line: number;
|
|
865
|
-
column: number;
|
|
1084
|
+
interface ResolvedId extends ModuleOptions {
|
|
1085
|
+
external: boolean | 'absolute';
|
|
1086
|
+
id: string;
|
|
866
1087
|
}
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
operator?: string;
|
|
877
|
-
type?: string;
|
|
878
|
-
frame?: string;
|
|
1088
|
+
|
|
1089
|
+
type IsExternal = (
|
|
1090
|
+
source: string,
|
|
1091
|
+
importer: string | undefined,
|
|
1092
|
+
isResolved: boolean
|
|
1093
|
+
) => boolean;
|
|
1094
|
+
|
|
1095
|
+
interface TransformPluginContext extends PluginContext {
|
|
1096
|
+
getCombinedSourcemap: () => SourceMap;
|
|
879
1097
|
}
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
1098
|
+
|
|
1099
|
+
type TransformResult = string | null | void | Partial<SourceDescription>;
|
|
1100
|
+
type PreserveEntrySignaturesOption = false | 'strict' | 'allow-extension' | 'exports-only';
|
|
1101
|
+
|
|
1102
|
+
interface AcornNode {
|
|
1103
|
+
end: number;
|
|
1104
|
+
start: number;
|
|
1105
|
+
type: string;
|
|
884
1106
|
}
|
|
885
|
-
type OnServerRestartHandler = (reason?: string) => Promise<void> | void;
|
|
886
1107
|
|
|
887
1108
|
declare type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
|
|
888
1109
|
declare type ReturnType$1<T> = T extends (...args: any) => infer R ? R : never;
|
|
@@ -897,221 +1118,6 @@ declare type BirpcReturn<RemoteFunctions> = {
|
|
|
897
1118
|
[K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]>;
|
|
898
1119
|
};
|
|
899
1120
|
|
|
900
|
-
type ChainableFunction<T extends string, Args extends any[], R = any, E = {}> = {
|
|
901
|
-
(...args: Args): R;
|
|
902
|
-
} & {
|
|
903
|
-
[x in T]: ChainableFunction<T, Args, R, E>;
|
|
904
|
-
} & {
|
|
905
|
-
fn: (this: Record<T, boolean | undefined>, ...args: Args) => R;
|
|
906
|
-
} & E;
|
|
907
|
-
|
|
908
|
-
interface BenchmarkUserOptions {
|
|
909
|
-
/**
|
|
910
|
-
* Include globs for benchmark test files
|
|
911
|
-
*
|
|
912
|
-
* @default ['**\/*.{bench,benchmark}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}']
|
|
913
|
-
*/
|
|
914
|
-
include?: string[];
|
|
915
|
-
/**
|
|
916
|
-
* Exclude globs for benchmark test files
|
|
917
|
-
* @default ['node_modules', 'dist', '.idea', '.git', '.cache']
|
|
918
|
-
*/
|
|
919
|
-
exclude?: string[];
|
|
920
|
-
/**
|
|
921
|
-
* Include globs for in-source benchmark test files
|
|
922
|
-
*
|
|
923
|
-
* @default []
|
|
924
|
-
*/
|
|
925
|
-
includeSource?: string[];
|
|
926
|
-
/**
|
|
927
|
-
* Custom reporter for output. Can contain one or more built-in report names, reporter instances,
|
|
928
|
-
* and/or paths to custom reporters
|
|
929
|
-
*/
|
|
930
|
-
reporters?: Arrayable<BenchmarkBuiltinReporters | Reporter>;
|
|
931
|
-
/**
|
|
932
|
-
* Write test results to a file when the `--reporter=json` option is also specified.
|
|
933
|
-
* Also definable individually per reporter by using an object instead.
|
|
934
|
-
*/
|
|
935
|
-
outputFile?: string | (Partial<Record<BenchmarkBuiltinReporters, string>> & Record<string, string>);
|
|
936
|
-
}
|
|
937
|
-
interface Benchmark extends TaskBase {
|
|
938
|
-
type: 'benchmark';
|
|
939
|
-
suite: Suite;
|
|
940
|
-
result?: TaskResult;
|
|
941
|
-
fails?: boolean;
|
|
942
|
-
task?: Task$1;
|
|
943
|
-
}
|
|
944
|
-
interface BenchmarkResult extends TaskResult$1 {
|
|
945
|
-
name: string;
|
|
946
|
-
rank: number;
|
|
947
|
-
}
|
|
948
|
-
type BenchFunction = (this: Bench) => Promise<void> | void;
|
|
949
|
-
type BenchmarkAPI = ChainableFunction<'skip' | 'only' | 'todo', [
|
|
950
|
-
name: string,
|
|
951
|
-
fn?: BenchFunction,
|
|
952
|
-
options?: Options
|
|
953
|
-
], void> & {
|
|
954
|
-
skipIf(condition: any): BenchmarkAPI;
|
|
955
|
-
runIf(condition: any): BenchmarkAPI;
|
|
956
|
-
};
|
|
957
|
-
|
|
958
|
-
type RunMode = 'run' | 'skip' | 'only' | 'todo';
|
|
959
|
-
type TaskState = RunMode | 'pass' | 'fail';
|
|
960
|
-
interface TaskBase {
|
|
961
|
-
id: string;
|
|
962
|
-
name: string;
|
|
963
|
-
mode: RunMode;
|
|
964
|
-
concurrent?: boolean;
|
|
965
|
-
shuffle?: boolean;
|
|
966
|
-
suite?: Suite;
|
|
967
|
-
file?: File;
|
|
968
|
-
result?: TaskResult;
|
|
969
|
-
retry?: number;
|
|
970
|
-
logs?: UserConsoleLog[];
|
|
971
|
-
meta?: any;
|
|
972
|
-
}
|
|
973
|
-
interface TaskResult {
|
|
974
|
-
state: TaskState;
|
|
975
|
-
duration?: number;
|
|
976
|
-
startTime?: number;
|
|
977
|
-
heap?: number;
|
|
978
|
-
/**
|
|
979
|
-
* @deprecated Use "errors" instead
|
|
980
|
-
*/
|
|
981
|
-
error?: ErrorWithDiff;
|
|
982
|
-
errors?: ErrorWithDiff[];
|
|
983
|
-
htmlError?: string;
|
|
984
|
-
hooks?: Partial<Record<keyof SuiteHooks, TaskState>>;
|
|
985
|
-
benchmark?: BenchmarkResult;
|
|
986
|
-
retryCount?: number;
|
|
987
|
-
}
|
|
988
|
-
type TaskResultPack = [id: string, result: TaskResult | undefined];
|
|
989
|
-
interface Suite extends TaskBase {
|
|
990
|
-
type: 'suite';
|
|
991
|
-
tasks: Task[];
|
|
992
|
-
filepath?: string;
|
|
993
|
-
benchmark?: Bench;
|
|
994
|
-
projectName?: string;
|
|
995
|
-
}
|
|
996
|
-
interface File extends Suite {
|
|
997
|
-
filepath: string;
|
|
998
|
-
collectDuration?: number;
|
|
999
|
-
setupDuration?: number;
|
|
1000
|
-
}
|
|
1001
|
-
interface Test<ExtraContext = {}> extends TaskBase {
|
|
1002
|
-
type: 'test';
|
|
1003
|
-
suite: Suite;
|
|
1004
|
-
result?: TaskResult;
|
|
1005
|
-
fails?: boolean;
|
|
1006
|
-
context: TestContext & ExtraContext;
|
|
1007
|
-
onFailed?: OnTestFailedHandler[];
|
|
1008
|
-
}
|
|
1009
|
-
type Task = Test | Suite | File | Benchmark;
|
|
1010
|
-
type DoneCallback = (error?: any) => void;
|
|
1011
|
-
type TestFunction<ExtraContext = {}> = (context: TestContext & ExtraContext) => Awaitable<any> | void;
|
|
1012
|
-
type ExtractEachCallbackArgs<T extends ReadonlyArray<any>> = {
|
|
1013
|
-
1: [T[0]];
|
|
1014
|
-
2: [T[0], T[1]];
|
|
1015
|
-
3: [T[0], T[1], T[2]];
|
|
1016
|
-
4: [T[0], T[1], T[2], T[3]];
|
|
1017
|
-
5: [T[0], T[1], T[2], T[3], T[4]];
|
|
1018
|
-
6: [T[0], T[1], T[2], T[3], T[4], T[5]];
|
|
1019
|
-
7: [T[0], T[1], T[2], T[3], T[4], T[5], T[6]];
|
|
1020
|
-
8: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7]];
|
|
1021
|
-
9: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7], T[8]];
|
|
1022
|
-
10: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7], T[8], T[9]];
|
|
1023
|
-
fallback: Array<T extends ReadonlyArray<infer U> ? U : any>;
|
|
1024
|
-
}[T extends Readonly<[any]> ? 1 : T extends Readonly<[any, any]> ? 2 : T extends Readonly<[any, any, any]> ? 3 : T extends Readonly<[any, any, any, any]> ? 4 : T extends Readonly<[any, any, any, any, any]> ? 5 : T extends Readonly<[any, any, any, any, any, any]> ? 6 : T extends Readonly<[any, any, any, any, any, any, any]> ? 7 : T extends Readonly<[any, any, any, any, any, any, any, any]> ? 8 : T extends Readonly<[any, any, any, any, any, any, any, any, any]> ? 9 : T extends Readonly<[any, any, any, any, any, any, any, any, any, any]> ? 10 : 'fallback'];
|
|
1025
|
-
interface SuiteEachFunction {
|
|
1026
|
-
<T extends any[] | [any]>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T) => Awaitable<void>) => void;
|
|
1027
|
-
<T extends ReadonlyArray<any>>(cases: ReadonlyArray<T>): (name: string, fn: (...args: ExtractEachCallbackArgs<T>) => Awaitable<void>) => void;
|
|
1028
|
-
<T>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T[]) => Awaitable<void>) => void;
|
|
1029
|
-
}
|
|
1030
|
-
interface TestEachFunction {
|
|
1031
|
-
<T extends any[] | [any]>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T) => Awaitable<void>, options?: number | TestOptions) => void;
|
|
1032
|
-
<T extends ReadonlyArray<any>>(cases: ReadonlyArray<T>): (name: string, fn: (...args: ExtractEachCallbackArgs<T>) => Awaitable<void>, options?: number | TestOptions) => void;
|
|
1033
|
-
<T>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T[]) => Awaitable<void>, options?: number | TestOptions) => void;
|
|
1034
|
-
(...args: [TemplateStringsArray, ...any]): (name: string, fn: (...args: any[]) => Awaitable<void>, options?: number | TestOptions) => void;
|
|
1035
|
-
}
|
|
1036
|
-
type ChainableTestAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo' | 'fails', [
|
|
1037
|
-
name: string,
|
|
1038
|
-
fn?: TestFunction<ExtraContext>,
|
|
1039
|
-
options?: number | TestOptions
|
|
1040
|
-
], void, {
|
|
1041
|
-
each: TestEachFunction;
|
|
1042
|
-
<T extends ExtraContext>(name: string, fn?: TestFunction<T>, options?: number | TestOptions): void;
|
|
1043
|
-
}>;
|
|
1044
|
-
interface TestOptions {
|
|
1045
|
-
/**
|
|
1046
|
-
* Test timeout.
|
|
1047
|
-
*/
|
|
1048
|
-
timeout?: number;
|
|
1049
|
-
/**
|
|
1050
|
-
* Times to retry the test if fails. Useful for making flaky tests more stable.
|
|
1051
|
-
* When retries is up, the last test error will be thrown.
|
|
1052
|
-
*
|
|
1053
|
-
* @default 1
|
|
1054
|
-
*/
|
|
1055
|
-
retry?: number;
|
|
1056
|
-
}
|
|
1057
|
-
type TestAPI<ExtraContext = {}> = ChainableTestAPI<ExtraContext> & {
|
|
1058
|
-
each: TestEachFunction;
|
|
1059
|
-
skipIf(condition: any): ChainableTestAPI<ExtraContext>;
|
|
1060
|
-
runIf(condition: any): ChainableTestAPI<ExtraContext>;
|
|
1061
|
-
};
|
|
1062
|
-
type ChainableSuiteAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo' | 'shuffle', [
|
|
1063
|
-
name: string,
|
|
1064
|
-
factory?: SuiteFactory<ExtraContext>,
|
|
1065
|
-
options?: number | TestOptions
|
|
1066
|
-
], SuiteCollector<ExtraContext>, {
|
|
1067
|
-
each: TestEachFunction;
|
|
1068
|
-
<T extends ExtraContext>(name: string, factory?: SuiteFactory<T>): SuiteCollector<T>;
|
|
1069
|
-
}>;
|
|
1070
|
-
type SuiteAPI<ExtraContext = {}> = ChainableSuiteAPI<ExtraContext> & {
|
|
1071
|
-
each: SuiteEachFunction;
|
|
1072
|
-
skipIf(condition: any): ChainableSuiteAPI<ExtraContext>;
|
|
1073
|
-
runIf(condition: any): ChainableSuiteAPI<ExtraContext>;
|
|
1074
|
-
};
|
|
1075
|
-
type HookListener<T extends any[], Return = void> = (...args: T) => Awaitable<Return>;
|
|
1076
|
-
type HookCleanupCallback = (() => Awaitable<unknown>) | void;
|
|
1077
|
-
interface SuiteHooks<ExtraContext = {}> {
|
|
1078
|
-
beforeAll: HookListener<[Suite | File], HookCleanupCallback>[];
|
|
1079
|
-
afterAll: HookListener<[Suite | File]>[];
|
|
1080
|
-
beforeEach: HookListener<[TestContext & ExtraContext, Suite], HookCleanupCallback>[];
|
|
1081
|
-
afterEach: HookListener<[TestContext & ExtraContext, Suite]>[];
|
|
1082
|
-
}
|
|
1083
|
-
interface SuiteCollector<ExtraContext = {}> {
|
|
1084
|
-
readonly name: string;
|
|
1085
|
-
readonly mode: RunMode;
|
|
1086
|
-
type: 'collector';
|
|
1087
|
-
test: TestAPI<ExtraContext>;
|
|
1088
|
-
benchmark: BenchmarkAPI;
|
|
1089
|
-
tasks: (Suite | Test | Benchmark | SuiteCollector<ExtraContext>)[];
|
|
1090
|
-
collect: (file?: File) => Promise<Suite>;
|
|
1091
|
-
clear: () => void;
|
|
1092
|
-
on: <T extends keyof SuiteHooks<ExtraContext>>(name: T, ...fn: SuiteHooks<ExtraContext>[T]) => void;
|
|
1093
|
-
}
|
|
1094
|
-
type SuiteFactory<ExtraContext = {}> = (test: (name: string, fn: TestFunction<ExtraContext>) => void) => Awaitable<void>;
|
|
1095
|
-
interface RuntimeContext {
|
|
1096
|
-
tasks: (SuiteCollector | Test)[];
|
|
1097
|
-
currentSuite: SuiteCollector | null;
|
|
1098
|
-
}
|
|
1099
|
-
interface TestContext {
|
|
1100
|
-
/**
|
|
1101
|
-
* Metadata of the current test
|
|
1102
|
-
*/
|
|
1103
|
-
meta: Readonly<Test>;
|
|
1104
|
-
/**
|
|
1105
|
-
* A expect instance bound to the test
|
|
1106
|
-
*/
|
|
1107
|
-
expect: Vi.ExpectStatic;
|
|
1108
|
-
/**
|
|
1109
|
-
* Extract hooks on test failed
|
|
1110
|
-
*/
|
|
1111
|
-
onTestFailed: (fn: OnTestFailedHandler) => void;
|
|
1112
|
-
}
|
|
1113
|
-
type OnTestFailedHandler = (result: TaskResult) => Awaitable<void>;
|
|
1114
|
-
|
|
1115
1121
|
type SnapshotData = Record<string, string>;
|
|
1116
1122
|
type SnapshotUpdateState = 'all' | 'new' | 'none';
|
|
1117
1123
|
interface SnapshotStateOptions {
|
|
@@ -1178,7 +1184,7 @@ interface WorkerRPC {
|
|
|
1178
1184
|
onWorkerExit: (error: unknown, code?: number) => void;
|
|
1179
1185
|
onPathsCollected: (paths: string[]) => void;
|
|
1180
1186
|
onUserConsoleLog: (log: UserConsoleLog) => void;
|
|
1181
|
-
|
|
1187
|
+
onUnhandledError: (err: unknown, type: string) => void;
|
|
1182
1188
|
onCollected: (files: File[]) => void;
|
|
1183
1189
|
onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void;
|
|
1184
1190
|
onTaskUpdate: (pack: TaskResultPack[]) => void;
|
|
@@ -1203,7 +1209,7 @@ interface CoverageProvider {
|
|
|
1203
1209
|
clean(clean?: boolean): void | Promise<void>;
|
|
1204
1210
|
onBeforeFilesRun?(): void | Promise<void>;
|
|
1205
1211
|
onAfterSuiteRun(meta: AfterSuiteRunMeta): void | Promise<void>;
|
|
1206
|
-
reportCoverage(reportContext
|
|
1212
|
+
reportCoverage(reportContext?: ReportContext): void | Promise<void>;
|
|
1207
1213
|
onFileTransform?(sourceCode: string, id: string, pluginCtx: TransformPluginContext): TransformResult | Promise<TransformResult>;
|
|
1208
1214
|
}
|
|
1209
1215
|
interface ReportContext {
|
|
@@ -1221,16 +1227,19 @@ interface CoverageProviderModule {
|
|
|
1221
1227
|
takeCoverage?(): unknown | Promise<unknown>;
|
|
1222
1228
|
}
|
|
1223
1229
|
type CoverageReporter = 'clover' | 'cobertura' | 'html-spa' | 'html' | 'json-summary' | 'json' | 'lcov' | 'lcovonly' | 'none' | 'teamcity' | 'text-lcov' | 'text-summary' | 'text';
|
|
1224
|
-
type
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
+
type Provider = 'c8' | 'istanbul' | CoverageProviderModule | undefined;
|
|
1231
|
+
type CoverageOptions<T extends Provider = Provider> = T extends CoverageProviderModule ? ({
|
|
1232
|
+
provider: T;
|
|
1233
|
+
} & BaseCoverageOptions) : T extends 'istanbul' ? ({
|
|
1234
|
+
provider: T;
|
|
1235
|
+
} & CoverageIstanbulOptions) : ({
|
|
1236
|
+
provider?: T;
|
|
1237
|
+
} & CoverageC8Options);
|
|
1238
|
+
/** Fields that have default values. Internally these will always be defined. */
|
|
1239
|
+
type FieldsWithDefaultValues = 'enabled' | 'clean' | 'cleanOnRerun' | 'reportsDirectory' | 'exclude' | 'extension' | 'reporter';
|
|
1240
|
+
type ResolvedCoverageOptions<T extends Provider = Provider> = CoverageOptions<T> & Required<Pick<CoverageOptions<T>, FieldsWithDefaultValues>> & {
|
|
1241
|
+
reporter: CoverageReporter[];
|
|
1230
1242
|
};
|
|
1231
|
-
type ResolvedCoverageOptions = {
|
|
1232
|
-
tempDirectory: string;
|
|
1233
|
-
} & Required<CoverageOptions>;
|
|
1234
1243
|
interface BaseCoverageOptions {
|
|
1235
1244
|
/**
|
|
1236
1245
|
* Enables coverage collection. Can be overriden using `--coverage` CLI option.
|
|
@@ -1570,6 +1579,21 @@ interface InlineConfig {
|
|
|
1570
1579
|
* Environment options.
|
|
1571
1580
|
*/
|
|
1572
1581
|
environmentOptions?: EnvironmentOptions;
|
|
1582
|
+
/**
|
|
1583
|
+
* Automatically assign environment based on globs. The first match will be used.
|
|
1584
|
+
*
|
|
1585
|
+
* Format: [glob, environment-name]
|
|
1586
|
+
*
|
|
1587
|
+
* @default []
|
|
1588
|
+
* @example [
|
|
1589
|
+
* // all tests in tests/dom will run in jsdom
|
|
1590
|
+
* ['tests/dom/**', 'jsdom'],
|
|
1591
|
+
* // all tests in tests/ with .edge.test.ts will run in edge-runtime
|
|
1592
|
+
* ['**\/*.edge.test.ts', 'edge-runtime'],
|
|
1593
|
+
* // ...
|
|
1594
|
+
* ]
|
|
1595
|
+
*/
|
|
1596
|
+
environmentMatchGlobs?: [string, VitestEnvironment][];
|
|
1573
1597
|
/**
|
|
1574
1598
|
* Update snapshot
|
|
1575
1599
|
*
|