@vitest/runner 3.2.4 → 4.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/dist/chunk-tasks.js +332 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1928 -3
- package/dist/{tasks.d-CkscK4of.d.ts → tasks.d-Mq4HCGzK.d.ts} +35 -53
- package/dist/types.d.ts +12 -12
- package/dist/utils.d.ts +5 -8
- package/dist/utils.js +3 -4
- package/package.json +2 -2
- package/dist/chunk-hooks.js +0 -2254
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TestError, Awaitable } from '@vitest/utils';
|
|
2
2
|
|
|
3
3
|
interface FixtureItem extends FixtureOptions {
|
|
4
4
|
prop: string;
|
|
@@ -19,7 +19,7 @@ type ChainableFunction<
|
|
|
19
19
|
F extends (...args: any) => any,
|
|
20
20
|
C = object
|
|
21
21
|
> = F & { [x in T] : ChainableFunction<T, F, C> } & {
|
|
22
|
-
fn: (this: Record<T, any>, ...args: Parameters<F>) => ReturnType<F
|
|
22
|
+
fn: (this: Record<T, any>, ...args: Parameters<F>) => ReturnType<F>;
|
|
23
23
|
} & C;
|
|
24
24
|
declare function createChainable<
|
|
25
25
|
T extends string,
|
|
@@ -92,9 +92,15 @@ interface TaskBase {
|
|
|
92
92
|
* and parsing the stack trace, so the location might differ depending on the runtime.
|
|
93
93
|
*/
|
|
94
94
|
location?: {
|
|
95
|
-
line: number
|
|
96
|
-
column: number
|
|
95
|
+
line: number;
|
|
96
|
+
column: number;
|
|
97
97
|
};
|
|
98
|
+
/**
|
|
99
|
+
* If the test was collected by parsing the file AST, and the name
|
|
100
|
+
* is not a static string, this property will be set to `true`.
|
|
101
|
+
* @experimental
|
|
102
|
+
*/
|
|
103
|
+
dynamic?: boolean;
|
|
98
104
|
}
|
|
99
105
|
interface TaskPopulated extends TaskBase {
|
|
100
106
|
/**
|
|
@@ -129,7 +135,7 @@ interface TaskResult {
|
|
|
129
135
|
* Errors that occurred during the task execution. It is possible to have several errors
|
|
130
136
|
* if `expect.soft()` failed multiple times or `retry` was triggered.
|
|
131
137
|
*/
|
|
132
|
-
errors?:
|
|
138
|
+
errors?: TestError[];
|
|
133
139
|
/**
|
|
134
140
|
* How long in milliseconds the task took to run.
|
|
135
141
|
*/
|
|
@@ -243,29 +249,20 @@ interface TestAnnotation {
|
|
|
243
249
|
location?: TestAnnotationLocation;
|
|
244
250
|
attachment?: TestAttachment;
|
|
245
251
|
}
|
|
246
|
-
/**
|
|
247
|
-
* @deprecated Use `Test` instead. `type: 'custom'` is not used since 2.2
|
|
248
|
-
*/
|
|
249
|
-
type Custom<ExtraContext = object> = Test<ExtraContext>;
|
|
250
252
|
type Task = Test | Suite | File;
|
|
251
|
-
/**
|
|
252
|
-
* @deprecated Vitest doesn't provide `done()` anymore
|
|
253
|
-
*/
|
|
254
|
-
type DoneCallback = (error?: any) => void;
|
|
255
253
|
type TestFunction<ExtraContext = object> = (context: TestContext & ExtraContext) => Awaitable<any> | void;
|
|
256
|
-
// jest's ExtractEachCallbackArgs
|
|
257
254
|
type ExtractEachCallbackArgs<T extends ReadonlyArray<any>> = {
|
|
258
|
-
1: [T[0]]
|
|
259
|
-
2: [T[0], T[1]]
|
|
260
|
-
3: [T[0], T[1], T[2]]
|
|
261
|
-
4: [T[0], T[1], T[2], T[3]]
|
|
262
|
-
5: [T[0], T[1], T[2], T[3], T[4]]
|
|
263
|
-
6: [T[0], T[1], T[2], T[3], T[4], T[5]]
|
|
264
|
-
7: [T[0], T[1], T[2], T[3], T[4], T[5], T[6]]
|
|
265
|
-
8: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7]]
|
|
266
|
-
9: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7], T[8]]
|
|
267
|
-
10: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7], T[8], T[9]]
|
|
268
|
-
fallback: Array<T extends ReadonlyArray<infer U> ? U : any
|
|
255
|
+
1: [T[0]];
|
|
256
|
+
2: [T[0], T[1]];
|
|
257
|
+
3: [T[0], T[1], T[2]];
|
|
258
|
+
4: [T[0], T[1], T[2], T[3]];
|
|
259
|
+
5: [T[0], T[1], T[2], T[3], T[4]];
|
|
260
|
+
6: [T[0], T[1], T[2], T[3], T[4], T[5]];
|
|
261
|
+
7: [T[0], T[1], T[2], T[3], T[4], T[5], T[6]];
|
|
262
|
+
8: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7]];
|
|
263
|
+
9: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7], T[8]];
|
|
264
|
+
10: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7], T[8], T[9]];
|
|
265
|
+
fallback: Array<T extends ReadonlyArray<infer U> ? U : any>;
|
|
269
266
|
}[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"];
|
|
270
267
|
interface EachFunctionReturn<T extends any[]> {
|
|
271
268
|
/**
|
|
@@ -289,14 +286,7 @@ interface TestForFunctionReturn<
|
|
|
289
286
|
(name: string | Function, options: TestCollectorOptions, fn: (args: Arg, context: Context) => Awaitable<void>): void;
|
|
290
287
|
}
|
|
291
288
|
interface TestForFunction<ExtraContext> {
|
|
292
|
-
// test.for([1, 2, 3])
|
|
293
|
-
// test.for([[1, 2], [3, 4, 5]])
|
|
294
289
|
<T>(cases: ReadonlyArray<T>): TestForFunctionReturn<T, TestContext & ExtraContext>;
|
|
295
|
-
// test.for`
|
|
296
|
-
// a | b
|
|
297
|
-
// {1} | {2}
|
|
298
|
-
// {3} | {4}
|
|
299
|
-
// `
|
|
300
290
|
(strings: TemplateStringsArray, ...values: any[]): TestForFunctionReturn<any, TestContext & ExtraContext>;
|
|
301
291
|
}
|
|
302
292
|
interface SuiteForFunction {
|
|
@@ -312,8 +302,8 @@ interface TestCollectorCallable<C = object> {
|
|
|
312
302
|
<ExtraContext extends C>(name: string | Function, options?: TestCollectorOptions, fn?: TestFunction<ExtraContext>): void;
|
|
313
303
|
}
|
|
314
304
|
type ChainableTestAPI<ExtraContext = object> = ChainableFunction<"concurrent" | "sequential" | "only" | "skip" | "todo" | "fails", TestCollectorCallable<ExtraContext>, {
|
|
315
|
-
each: TestEachFunction
|
|
316
|
-
for: TestForFunction<ExtraContext
|
|
305
|
+
each: TestEachFunction;
|
|
306
|
+
for: TestForFunction<ExtraContext>;
|
|
317
307
|
}>;
|
|
318
308
|
type TestCollectorOptions = Omit<TestOptions, "shuffle">;
|
|
319
309
|
interface TestOptions {
|
|
@@ -371,10 +361,9 @@ interface ExtendedAPI<ExtraContext> {
|
|
|
371
361
|
runIf: (condition: any) => ChainableTestAPI<ExtraContext>;
|
|
372
362
|
}
|
|
373
363
|
type TestAPI<ExtraContext = object> = ChainableTestAPI<ExtraContext> & ExtendedAPI<ExtraContext> & {
|
|
374
|
-
extend: <T extends Record<string, any> = object>(fixtures: Fixtures<T, ExtraContext>) => TestAPI<{ [K in keyof T | keyof ExtraContext] : K extends keyof T ? T[K] : K extends keyof ExtraContext ? ExtraContext[K] : never }
|
|
375
|
-
scoped: (fixtures: Fixtures<Partial<ExtraContext>>) => void
|
|
364
|
+
extend: <T extends Record<string, any> = object>(fixtures: Fixtures<T, ExtraContext>) => TestAPI<{ [K in keyof T | keyof ExtraContext] : K extends keyof T ? T[K] : K extends keyof ExtraContext ? ExtraContext[K] : never }>;
|
|
365
|
+
scoped: (fixtures: Fixtures<Partial<ExtraContext>>) => void;
|
|
376
366
|
};
|
|
377
|
-
|
|
378
367
|
interface FixtureOptions {
|
|
379
368
|
/**
|
|
380
369
|
* Whether to automatically set up current fixture, even though it's not being used in tests.
|
|
@@ -421,12 +410,12 @@ interface SuiteCollectorCallable<ExtraContext = object> {
|
|
|
421
410
|
<OverrideExtraContext extends ExtraContext = ExtraContext>(name: string | Function, options: TestOptions, fn?: SuiteFactory<OverrideExtraContext>): SuiteCollector<OverrideExtraContext>;
|
|
422
411
|
}
|
|
423
412
|
type ChainableSuiteAPI<ExtraContext = object> = ChainableFunction<"concurrent" | "sequential" | "only" | "skip" | "todo" | "shuffle", SuiteCollectorCallable<ExtraContext>, {
|
|
424
|
-
each: TestEachFunction
|
|
425
|
-
for: SuiteForFunction
|
|
413
|
+
each: TestEachFunction;
|
|
414
|
+
for: SuiteForFunction;
|
|
426
415
|
}>;
|
|
427
416
|
type SuiteAPI<ExtraContext = object> = ChainableSuiteAPI<ExtraContext> & {
|
|
428
|
-
skipIf: (condition: any) => ChainableSuiteAPI<ExtraContext
|
|
429
|
-
runIf: (condition: any) => ChainableSuiteAPI<ExtraContext
|
|
417
|
+
skipIf: (condition: any) => ChainableSuiteAPI<ExtraContext>;
|
|
418
|
+
runIf: (condition: any) => ChainableSuiteAPI<ExtraContext>;
|
|
430
419
|
};
|
|
431
420
|
/**
|
|
432
421
|
* @deprecated
|
|
@@ -527,25 +516,18 @@ interface TestContext {
|
|
|
527
516
|
* @see {@link https://vitest.dev/guide/test-context#skip}
|
|
528
517
|
*/
|
|
529
518
|
readonly skip: {
|
|
530
|
-
(note?: string): never
|
|
531
|
-
(condition: boolean, note?: string): void
|
|
519
|
+
(note?: string): never;
|
|
520
|
+
(condition: boolean, note?: string): void;
|
|
532
521
|
};
|
|
533
522
|
/**
|
|
534
523
|
* Add a test annotation that will be displayed by your reporter.
|
|
535
524
|
* @see {@link https://vitest.dev/guide/test-context#annotate}
|
|
536
525
|
*/
|
|
537
526
|
readonly annotate: {
|
|
538
|
-
(message: string, type?: string, attachment?: TestAttachment): Promise<TestAnnotation
|
|
539
|
-
(message: string, attachment?: TestAttachment): Promise<TestAnnotation
|
|
527
|
+
(message: string, type?: string, attachment?: TestAttachment): Promise<TestAnnotation>;
|
|
528
|
+
(message: string, attachment?: TestAttachment): Promise<TestAnnotation>;
|
|
540
529
|
};
|
|
541
530
|
}
|
|
542
|
-
/**
|
|
543
|
-
* Context that's always available in the test function.
|
|
544
|
-
* @deprecated use `TestContext` instead
|
|
545
|
-
*/
|
|
546
|
-
interface TaskContext extends TestContext {}
|
|
547
|
-
/** @deprecated use `TestContext` instead */
|
|
548
|
-
type ExtendedContext = TaskContext & TestContext;
|
|
549
531
|
type OnTestFailedHandler = (context: TestContext) => Awaitable<void>;
|
|
550
532
|
type OnTestFinishedHandler = (context: TestContext) => Awaitable<void>;
|
|
551
533
|
interface TaskHook<HookListener> {
|
|
@@ -555,4 +537,4 @@ type SequenceHooks = "stack" | "list" | "parallel";
|
|
|
555
537
|
type SequenceSetupFiles = "list" | "parallel";
|
|
556
538
|
|
|
557
539
|
export { createChainable as c };
|
|
558
|
-
export type { AfterAllListener as A, BeforeAllListener as B, ChainableFunction as C,
|
|
540
|
+
export type { AfterAllListener as A, BeforeAllListener as B, ChainableFunction as C, TaskResult as D, TaskResultPack as E, File as F, TaskState as G, HookCleanupCallback as H, ImportDuration as I, TestAnnotation as J, TestAnnotationLocation as K, TestAttachment as L, TestContext as M, TestFunction as N, OnTestFailedHandler as O, TestOptions as P, RunMode as R, Suite as S, Task as T, Use as U, Test as a, AfterEachListener as b, BeforeEachListener as d, TaskHook as e, OnTestFinishedHandler as f, SuiteHooks as g, TaskUpdateEvent as h, TestAPI as i, SuiteAPI as j, SuiteCollector as k, Fixture as l, FixtureFn as m, FixtureOptions as n, Fixtures as o, HookListener as p, InferFixturesTypes as q, RuntimeContext as r, SequenceHooks as s, SequenceSetupFiles as t, SuiteFactory as u, TaskBase as v, TaskCustomOptions as w, TaskEventPack as x, TaskMeta as y, TaskPopulated as z };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DiffOptions } from '@vitest/utils/diff';
|
|
2
|
-
import { F as File, a as Test, S as Suite,
|
|
3
|
-
export { A as AfterAllListener, b as AfterEachListener, B as BeforeAllListener, d as BeforeEachListener,
|
|
2
|
+
import { F as File, a as Test, S as Suite, E as TaskResultPack, x as TaskEventPack, J as TestAnnotation, M as TestContext, I as ImportDuration, s as SequenceHooks, t as SequenceSetupFiles } from './tasks.d-Mq4HCGzK.js';
|
|
3
|
+
export { A as AfterAllListener, b as AfterEachListener, B as BeforeAllListener, d as BeforeEachListener, l as Fixture, m as FixtureFn, n as FixtureOptions, o as Fixtures, H as HookCleanupCallback, p as HookListener, q as InferFixturesTypes, O as OnTestFailedHandler, f as OnTestFinishedHandler, R as RunMode, r as RuntimeContext, j as SuiteAPI, k as SuiteCollector, u as SuiteFactory, g as SuiteHooks, T as Task, v as TaskBase, w as TaskCustomOptions, e as TaskHook, y as TaskMeta, z as TaskPopulated, D as TaskResult, G as TaskState, h as TaskUpdateEvent, i as TestAPI, K as TestAnnotationLocation, L as TestAttachment, N as TestFunction, P as TestOptions, U as Use } from './tasks.d-Mq4HCGzK.js';
|
|
4
4
|
import '@vitest/utils';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -14,14 +14,14 @@ interface VitestRunnerConfig {
|
|
|
14
14
|
testNamePattern?: RegExp;
|
|
15
15
|
allowOnly?: boolean;
|
|
16
16
|
sequence: {
|
|
17
|
-
shuffle?: boolean
|
|
18
|
-
concurrent?: boolean
|
|
19
|
-
seed: number
|
|
20
|
-
hooks: SequenceHooks
|
|
21
|
-
setupFiles: SequenceSetupFiles
|
|
17
|
+
shuffle?: boolean;
|
|
18
|
+
concurrent?: boolean;
|
|
19
|
+
seed: number;
|
|
20
|
+
hooks: SequenceHooks;
|
|
21
|
+
setupFiles: SequenceSetupFiles;
|
|
22
22
|
};
|
|
23
23
|
chaiConfig?: {
|
|
24
|
-
truncateThreshold?: number
|
|
24
|
+
truncateThreshold?: number;
|
|
25
25
|
};
|
|
26
26
|
maxConcurrency: number;
|
|
27
27
|
testTimeout: number;
|
|
@@ -69,8 +69,8 @@ interface VitestRunner {
|
|
|
69
69
|
* Called before actually running the test function. Already has "result" with "state" and "startTime".
|
|
70
70
|
*/
|
|
71
71
|
onBeforeTryTask?: (test: Test, options: {
|
|
72
|
-
retry: number
|
|
73
|
-
repeats: number
|
|
72
|
+
retry: number;
|
|
73
|
+
repeats: number;
|
|
74
74
|
}) => unknown;
|
|
75
75
|
/**
|
|
76
76
|
* When the task has finished running, but before cleanup hooks are called
|
|
@@ -84,8 +84,8 @@ interface VitestRunner {
|
|
|
84
84
|
* Called right after running the test function. Doesn't have new state yet. Will not be called, if the test function throws.
|
|
85
85
|
*/
|
|
86
86
|
onAfterTryTask?: (test: Test, options: {
|
|
87
|
-
retry: number
|
|
88
|
-
repeats: number
|
|
87
|
+
retry: number;
|
|
88
|
+
repeats: number;
|
|
89
89
|
}) => unknown;
|
|
90
90
|
/**
|
|
91
91
|
* Called before running a single suite. Doesn't have "result" yet.
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as Suite, F as File, T as Task, a as Test } from './tasks.d-
|
|
2
|
-
export { C as ChainableFunction, c as createChainable } from './tasks.d-
|
|
3
|
-
import { Arrayable } from '@vitest/utils';
|
|
1
|
+
import { S as Suite, F as File, T as Task, a as Test } from './tasks.d-Mq4HCGzK.js';
|
|
2
|
+
export { C as ChainableFunction, c as createChainable } from './tasks.d-Mq4HCGzK.js';
|
|
3
|
+
import { ParsedStack, Arrayable } from '@vitest/utils';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* If any tasks been marked as `only`, mark all other tasks as `skip`.
|
|
@@ -16,6 +16,7 @@ declare function createFileTask(filepath: string, root: string, projectName: str
|
|
|
16
16
|
* @param projectName The name of the test project
|
|
17
17
|
*/
|
|
18
18
|
declare function generateFileHash(file: string, projectName: string | undefined): string;
|
|
19
|
+
declare function findTestFileStackTrace(testFilePath: string, error: string): ParsedStack | undefined;
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* Return a function for running multiple async operations with limited concurrency.
|
|
@@ -30,10 +31,6 @@ declare function limitConcurrency(concurrency?: number): <
|
|
|
30
31
|
*/
|
|
31
32
|
declare function partitionSuiteChildren(suite: Suite): Task[][];
|
|
32
33
|
|
|
33
|
-
/**
|
|
34
|
-
* @deprecated use `isTestCase` instead
|
|
35
|
-
*/
|
|
36
|
-
declare function isAtomTest(s: Task): s is Test;
|
|
37
34
|
declare function isTestCase(s: Task): s is Test;
|
|
38
35
|
declare function getTests(suite: Arrayable<Task>): Test[];
|
|
39
36
|
declare function getTasks(tasks?: Arrayable<Task>): Task[];
|
|
@@ -44,4 +41,4 @@ declare function getNames(task: Task): string[];
|
|
|
44
41
|
declare function getFullName(task: Task, separator?: string): string;
|
|
45
42
|
declare function getTestName(task: Task, separator?: string): string;
|
|
46
43
|
|
|
47
|
-
export { calculateSuiteHash, createFileTask, generateFileHash, generateHash, getFullName, getNames, getSuites, getTasks, getTestName, getTests, hasFailed, hasTests, interpretTaskModes,
|
|
44
|
+
export { calculateSuiteHash, createFileTask, findTestFileStackTrace, generateFileHash, generateHash, getFullName, getNames, getSuites, getTasks, getTestName, getTests, hasFailed, hasTests, interpretTaskModes, isTestCase, limitConcurrency, partitionSuiteChildren, someTasksAreOnly };
|
package/dist/utils.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
import '@vitest/utils';
|
|
3
|
-
import '@vitest/utils/source-map';
|
|
1
|
+
export { a as calculateSuiteHash, c as createChainable, b as createFileTask, f as findTestFileStackTrace, g as generateFileHash, d as generateHash, e as getFullName, h as getNames, j as getSuites, k as getTasks, m as getTestName, n as getTests, o as hasFailed, q as hasTests, i as interpretTaskModes, r as isTestCase, l as limitConcurrency, p as partitionSuiteChildren, s as someTasksAreOnly } from './chunk-tasks.js';
|
|
4
2
|
import '@vitest/utils/error';
|
|
5
|
-
import '
|
|
3
|
+
import '@vitest/utils/source-map';
|
|
6
4
|
import 'pathe';
|
|
5
|
+
import '@vitest/utils';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest/runner",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.0-beta.10",
|
|
5
5
|
"description": "Vitest test runner",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"pathe": "^2.0.3",
|
|
42
42
|
"strip-literal": "^3.0.0",
|
|
43
|
-
"@vitest/utils": "
|
|
43
|
+
"@vitest/utils": "4.0.0-beta.10"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "rimraf dist && rollup -c",
|