@vitest/runner 2.0.0-beta.9 → 2.0.1
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-tasks.js +77 -24
- package/dist/index.d.ts +6 -5
- package/dist/index.js +342 -154
- package/dist/{tasks-Cjrz1dUg.d.ts → tasks-WAKtRuk9.d.ts} +28 -4
- package/dist/types.d.ts +11 -3
- package/dist/utils.d.ts +10 -4
- package/dist/utils.js +1 -1
- package/package.json +2 -3
@@ -64,17 +64,26 @@ interface TaskResult {
|
|
64
64
|
retryCount?: number;
|
65
65
|
repeatCount?: number;
|
66
66
|
}
|
67
|
-
type TaskResultPack = [
|
67
|
+
type TaskResultPack = [
|
68
|
+
id: string,
|
69
|
+
result: TaskResult | undefined,
|
70
|
+
meta: TaskMeta
|
71
|
+
];
|
68
72
|
interface Suite extends TaskBase {
|
69
73
|
file: File;
|
70
74
|
type: 'suite';
|
71
75
|
tasks: Task[];
|
72
76
|
}
|
73
77
|
interface File extends Suite {
|
78
|
+
pool?: string;
|
74
79
|
filepath: string;
|
75
80
|
projectName: string | undefined;
|
76
81
|
collectDuration?: number;
|
77
82
|
setupDuration?: number;
|
83
|
+
/**
|
84
|
+
* Whether the file is initiated without running any tests.
|
85
|
+
*/
|
86
|
+
local?: boolean;
|
78
87
|
}
|
79
88
|
interface Test<ExtraContext = {}> extends TaskPopulated {
|
80
89
|
type: 'test';
|
@@ -114,6 +123,14 @@ interface TestEachFunction {
|
|
114
123
|
<T>(cases: ReadonlyArray<T>): EachFunctionReturn<T[]>;
|
115
124
|
(...args: [TemplateStringsArray, ...any]): EachFunctionReturn<any[]>;
|
116
125
|
}
|
126
|
+
interface TestForFunctionReturn<Arg, Context> {
|
127
|
+
(name: string | Function, fn: (arg: Arg, context: Context) => Awaitable<void>): void;
|
128
|
+
(name: string | Function, options: TestOptions, fn: (args: Arg, context: Context) => Awaitable<void>): void;
|
129
|
+
}
|
130
|
+
interface TestForFunction<ExtraContext> {
|
131
|
+
<T>(cases: ReadonlyArray<T>): TestForFunctionReturn<T, ExtendedContext<Test> & ExtraContext>;
|
132
|
+
(strings: TemplateStringsArray, ...values: any[]): TestForFunctionReturn<any, ExtendedContext<Test> & ExtraContext>;
|
133
|
+
}
|
117
134
|
interface TestCollectorCallable<C = {}> {
|
118
135
|
/**
|
119
136
|
* @deprecated Use options as the second argument instead
|
@@ -124,6 +141,7 @@ interface TestCollectorCallable<C = {}> {
|
|
124
141
|
}
|
125
142
|
type ChainableTestAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'sequential' | 'only' | 'skip' | 'todo' | 'fails', TestCollectorCallable<ExtraContext>, {
|
126
143
|
each: TestEachFunction;
|
144
|
+
for: TestForFunction<ExtraContext>;
|
127
145
|
}>;
|
128
146
|
interface TestOptions {
|
129
147
|
/**
|
@@ -193,7 +211,7 @@ interface FixtureOptions {
|
|
193
211
|
}
|
194
212
|
type Use<T> = (value: T) => Promise<void>;
|
195
213
|
type FixtureFn<T, K extends keyof T, ExtraContext> = (context: Omit<T, K> & ExtraContext, use: Use<T[K]>) => Promise<void>;
|
196
|
-
type Fixture<T, K extends keyof T, ExtraContext = {}> = ((...args: any) => any) extends T[K] ?
|
214
|
+
type Fixture<T, K extends keyof T, ExtraContext = {}> = ((...args: any) => any) extends T[K] ? T[K] extends any ? FixtureFn<T, K, Omit<ExtraContext, Exclude<keyof T, K>>> : never : T[K] | (T[K] extends any ? FixtureFn<T, K, Omit<ExtraContext, Exclude<keyof T, K>>> : never);
|
197
215
|
type Fixtures<T extends Record<string, any>, ExtraContext = {}> = {
|
198
216
|
[K in keyof T]: Fixture<T, K, ExtraContext & ExtendedContext<Test>> | [Fixture<T, K, ExtraContext & ExtendedContext<Test>>, FixtureOptions?];
|
199
217
|
};
|
@@ -218,8 +236,14 @@ type HookCleanupCallback = (() => Awaitable<unknown>) | void;
|
|
218
236
|
interface SuiteHooks<ExtraContext = {}> {
|
219
237
|
beforeAll: HookListener<[Readonly<Suite | File>], HookCleanupCallback>[];
|
220
238
|
afterAll: HookListener<[Readonly<Suite | File>]>[];
|
221
|
-
beforeEach: HookListener<[
|
222
|
-
|
239
|
+
beforeEach: HookListener<[
|
240
|
+
ExtendedContext<Test | Custom> & ExtraContext,
|
241
|
+
Readonly<Suite>
|
242
|
+
], HookCleanupCallback>[];
|
243
|
+
afterEach: HookListener<[
|
244
|
+
ExtendedContext<Test | Custom> & ExtraContext,
|
245
|
+
Readonly<Suite>
|
246
|
+
]>[];
|
223
247
|
}
|
224
248
|
interface TaskCustomOptions extends TestOptions {
|
225
249
|
concurrent?: boolean;
|
package/dist/types.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { B as SequenceHooks, G as SequenceSetupFiles, F as File, T as Task, S as Suite, o as TaskResultPack, a as Test, C as Custom, A as TaskContext, E as ExtendedContext } from './tasks-
|
2
|
-
export { g as CustomAPI, D as DoneCallback, t as Fixture, s as FixtureFn, r as FixtureOptions, u as Fixtures, v as HookCleanupCallback, H as HookListener, I as InferFixturesTypes, O as OnTestFailedHandler, i as OnTestFinishedHandler, R as RunMode, y as RuntimeContext, d as SuiteAPI, f as SuiteCollector, x as SuiteFactory, h as SuiteHooks, k as TaskBase, w as TaskCustomOptions, m as TaskMeta, l as TaskPopulated, n as TaskResult, j as TaskState, e as TestAPI, z as TestContext, p as TestFunction, q as TestOptions, U as Use } from './tasks-
|
1
|
+
import { B as SequenceHooks, G as SequenceSetupFiles, F as File, T as Task, S as Suite, o as TaskResultPack, a as Test, C as Custom, A as TaskContext, E as ExtendedContext } from './tasks-WAKtRuk9.js';
|
2
|
+
export { g as CustomAPI, D as DoneCallback, t as Fixture, s as FixtureFn, r as FixtureOptions, u as Fixtures, v as HookCleanupCallback, H as HookListener, I as InferFixturesTypes, O as OnTestFailedHandler, i as OnTestFinishedHandler, R as RunMode, y as RuntimeContext, d as SuiteAPI, f as SuiteCollector, x as SuiteFactory, h as SuiteHooks, k as TaskBase, w as TaskCustomOptions, m as TaskMeta, l as TaskPopulated, n as TaskResult, j as TaskState, e as TestAPI, z as TestContext, p as TestFunction, q as TestOptions, U as Use } from './tasks-WAKtRuk9.js';
|
3
3
|
import { DiffOptions } from '@vitest/utils/diff';
|
4
4
|
import '@vitest/utils';
|
5
5
|
|
@@ -31,7 +31,7 @@ type VitestRunnerImportSource = 'collect' | 'setup';
|
|
31
31
|
interface VitestRunnerConstructor {
|
32
32
|
new (config: VitestRunnerConfig): VitestRunner;
|
33
33
|
}
|
34
|
-
type CancelReason = 'keyboard-input' | 'test-failure' | string & Record<string, never
|
34
|
+
type CancelReason = 'keyboard-input' | 'test-failure' | (string & Record<string, never>);
|
35
35
|
interface VitestRunner {
|
36
36
|
/**
|
37
37
|
* First thing that's getting called before actually collecting and running tests.
|
@@ -62,6 +62,10 @@ interface VitestRunner {
|
|
62
62
|
retry: number;
|
63
63
|
repeats: number;
|
64
64
|
}) => unknown;
|
65
|
+
/**
|
66
|
+
* When the task has finished running, but before cleanup hooks are called
|
67
|
+
*/
|
68
|
+
onTaskFinished?: (test: Task) => unknown;
|
65
69
|
/**
|
66
70
|
* Called after result and state are set.
|
67
71
|
*/
|
@@ -120,6 +124,10 @@ interface VitestRunner {
|
|
120
124
|
* Publicly available configuration.
|
121
125
|
*/
|
122
126
|
config: VitestRunnerConfig;
|
127
|
+
/**
|
128
|
+
* The name of the current pool. Can affect how stack trace is inferred on the server side.
|
129
|
+
*/
|
130
|
+
pool?: string;
|
123
131
|
}
|
124
132
|
|
125
133
|
export { type CancelReason, Custom, ExtendedContext, File, SequenceHooks, SequenceSetupFiles, Suite, Task, TaskContext, TaskResultPack, Test, type VitestRunner, type VitestRunnerConfig, type VitestRunnerConstructor, type VitestRunnerImportSource };
|
package/dist/utils.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { S as Suite, F as File, T as Task, a as Test, C as Custom } from './tasks-
|
2
|
-
export { b as ChainableFunction, c as createChainable } from './tasks-
|
1
|
+
import { S as Suite, F as File, T as Task, a as Test, C as Custom } from './tasks-WAKtRuk9.js';
|
2
|
+
export { b as ChainableFunction, c as createChainable } from './tasks-WAKtRuk9.js';
|
3
3
|
import { Arrayable } from '@vitest/utils';
|
4
4
|
|
5
5
|
/**
|
@@ -9,13 +9,14 @@ declare function interpretTaskModes(suite: Suite, namePattern?: string | RegExp,
|
|
9
9
|
declare function someTasksAreOnly(suite: Suite): boolean;
|
10
10
|
declare function generateHash(str: string): string;
|
11
11
|
declare function calculateSuiteHash(parent: Suite): void;
|
12
|
-
declare function createFileTask(filepath: string, root: string, projectName: string): File;
|
12
|
+
declare function createFileTask(filepath: string, root: string, projectName: string, pool?: string): File;
|
13
13
|
|
14
14
|
/**
|
15
15
|
* Partition in tasks groups by consecutive concurrent
|
16
16
|
*/
|
17
17
|
declare function partitionSuiteChildren(suite: Suite): Task[][];
|
18
18
|
|
19
|
+
declare function isAtomTest(s: Task): s is Test | Custom;
|
19
20
|
declare function getTests(suite: Arrayable<Task>): (Test | Custom)[];
|
20
21
|
declare function getTasks(tasks?: Arrayable<Task>): Task[];
|
21
22
|
declare function getSuites(suite: Arrayable<Task>): Suite[];
|
@@ -23,4 +24,9 @@ declare function hasTests(suite: Arrayable<Suite>): boolean;
|
|
23
24
|
declare function hasFailed(suite: Arrayable<Task>): boolean;
|
24
25
|
declare function getNames(task: Task): string[];
|
25
26
|
|
26
|
-
|
27
|
+
/**
|
28
|
+
* Return a function for running multiple async operations with limited concurrency.
|
29
|
+
*/
|
30
|
+
declare function limitConcurrency(concurrency?: number): <Args extends unknown[], T>(func: (...args: Args) => PromiseLike<T> | T, ...args: Args) => Promise<T>;
|
31
|
+
|
32
|
+
export { calculateSuiteHash, createFileTask, generateHash, getNames, getSuites, getTasks, getTests, hasFailed, hasTests, interpretTaskModes, isAtomTest, limitConcurrency, partitionSuiteChildren, someTasksAreOnly };
|
package/dist/utils.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
export { c as calculateSuiteHash,
|
1
|
+
export { c as calculateSuiteHash, l as createChainable, a as createFileTask, g as generateHash, k as getNames, f as getSuites, e as getTasks, d as getTests, j as hasFailed, h as hasTests, i as interpretTaskModes, b as isAtomTest, m as limitConcurrency, p as partitionSuiteChildren, s as someTasksAreOnly } from './chunk-tasks.js';
|
2
2
|
import '@vitest/utils/error';
|
3
3
|
import 'pathe';
|
4
4
|
import '@vitest/utils';
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vitest/runner",
|
3
3
|
"type": "module",
|
4
|
-
"version": "2.0.
|
4
|
+
"version": "2.0.1",
|
5
5
|
"description": "Vitest test runner",
|
6
6
|
"license": "MIT",
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
@@ -38,9 +38,8 @@
|
|
38
38
|
"dist"
|
39
39
|
],
|
40
40
|
"dependencies": {
|
41
|
-
"p-limit": "^5.0.0",
|
42
41
|
"pathe": "^1.1.2",
|
43
|
-
"@vitest/utils": "2.0.
|
42
|
+
"@vitest/utils": "2.0.1"
|
44
43
|
},
|
45
44
|
"scripts": {
|
46
45
|
"build": "rimraf dist && rollup -c",
|