@vitest/runner 2.2.0-beta.1 → 2.2.0-beta.2
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 +7 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/{tasks-F_411-nA.d.ts → tasks-CgWT5bp6.d.ts} +16 -7
- package/dist/types.d.ts +3 -3
- package/dist/utils.d.ts +5 -2
- package/package.json +2 -2
package/dist/chunk-tasks.js
CHANGED
@@ -179,17 +179,20 @@ function partitionSuiteChildren(suite) {
|
|
179
179
|
}
|
180
180
|
|
181
181
|
function isAtomTest(s) {
|
182
|
+
return isTestCase(s);
|
183
|
+
}
|
184
|
+
function isTestCase(s) {
|
182
185
|
return s.type === "test" || s.type === "custom";
|
183
186
|
}
|
184
187
|
function getTests(suite) {
|
185
188
|
const tests = [];
|
186
189
|
const arraySuites = toArray(suite);
|
187
190
|
for (const s of arraySuites) {
|
188
|
-
if (
|
191
|
+
if (isTestCase(s)) {
|
189
192
|
tests.push(s);
|
190
193
|
} else {
|
191
194
|
for (const task of s.tasks) {
|
192
|
-
if (
|
195
|
+
if (isTestCase(task)) {
|
193
196
|
tests.push(task);
|
194
197
|
} else {
|
195
198
|
const taskTests = getTests(task);
|
@@ -204,7 +207,7 @@ function getTests(suite) {
|
|
204
207
|
}
|
205
208
|
function getTasks(tasks = []) {
|
206
209
|
return toArray(tasks).flatMap(
|
207
|
-
(s) =>
|
210
|
+
(s) => isTestCase(s) ? [s] : [s, ...getTasks(s.tasks)]
|
208
211
|
);
|
209
212
|
}
|
210
213
|
function getSuites(suite) {
|
@@ -214,7 +217,7 @@ function getSuites(suite) {
|
|
214
217
|
}
|
215
218
|
function hasTests(suite) {
|
216
219
|
return toArray(suite).some(
|
217
|
-
(s) => s.tasks.some((c) =>
|
220
|
+
(s) => s.tasks.some((c) => isTestCase(c) || hasTests(c))
|
218
221
|
);
|
219
222
|
}
|
220
223
|
function hasFailed(suite) {
|
package/dist/index.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { B as BeforeAllListener, A as AfterAllListener, d as BeforeEachListener, e as AfterEachListener, f as TaskHook, O as OnTestFailedHandler, g as OnTestFinishedHandler, a as Test, C as Custom, S as Suite, h as SuiteHooks, T as Task, F as File, i as SuiteAPI, j as TestAPI, k as SuiteCollector } from './tasks-
|
2
|
-
export { D as DoneCallback, E as ExtendedContext, l as Fixture, m as FixtureFn, n as FixtureOptions, o as Fixtures, H as HookCleanupCallback, p as HookListener, I as InferFixturesTypes, R as RunMode, q as RuntimeContext, r as SequenceHooks, s as SequenceSetupFiles, t as SuiteFactory, u as TaskBase, v as TaskContext, w as TaskCustomOptions, x as TaskMeta, y as TaskPopulated, z as TaskResult, G as TaskResultPack, J as TaskState, K as TestContext, L as TestFunction, M as TestOptions, U as Use } from './tasks-
|
1
|
+
import { B as BeforeAllListener, A as AfterAllListener, d as BeforeEachListener, e as AfterEachListener, f as TaskHook, O as OnTestFailedHandler, g as OnTestFinishedHandler, a as Test, C as Custom, S as Suite, h as SuiteHooks, T as Task, F as File, i as SuiteAPI, j as TestAPI, k as SuiteCollector } from './tasks-CgWT5bp6.js';
|
2
|
+
export { D as DoneCallback, E as ExtendedContext, l as Fixture, m as FixtureFn, n as FixtureOptions, o as Fixtures, H as HookCleanupCallback, p as HookListener, I as InferFixturesTypes, R as RunMode, q as RuntimeContext, r as SequenceHooks, s as SequenceSetupFiles, t as SuiteFactory, u as TaskBase, v as TaskContext, w as TaskCustomOptions, x as TaskMeta, y as TaskPopulated, z as TaskResult, G as TaskResultPack, J as TaskState, K as TestContext, L as TestFunction, M as TestOptions, U as Use } from './tasks-CgWT5bp6.js';
|
3
3
|
import { Awaitable } from '@vitest/utils';
|
4
4
|
import { VitestRunner } from './types.js';
|
5
5
|
export { CancelReason, VitestRunnerConfig, VitestRunnerConstructor, VitestRunnerImportSource } from './types.js';
|
package/dist/index.js
CHANGED
@@ -403,7 +403,7 @@ function createSuiteCollector(name, factory = () => {
|
|
403
403
|
each: options.each,
|
404
404
|
fails: options.fails,
|
405
405
|
context: void 0,
|
406
|
-
type: "
|
406
|
+
type: "test",
|
407
407
|
file: void 0,
|
408
408
|
retry: options.retry ?? runner.config.retry,
|
409
409
|
repeats: options.repeats,
|
@@ -234,14 +234,23 @@ interface Test<ExtraContext = object> extends TaskPopulated {
|
|
234
234
|
*/
|
235
235
|
context: TaskContext<Test> & ExtraContext & TestContext;
|
236
236
|
}
|
237
|
+
/**
|
238
|
+
* @deprecated Use `Test` instead. `type: 'custom'` is not used since 2.2
|
239
|
+
*/
|
237
240
|
interface Custom<ExtraContext = object> extends TaskPopulated {
|
241
|
+
/**
|
242
|
+
* @deprecated use `test` instead. `custom` is not used since 2.2
|
243
|
+
*/
|
238
244
|
type: 'custom';
|
239
245
|
/**
|
240
246
|
* Task context that will be passed to the test function.
|
241
247
|
*/
|
242
|
-
context: TaskContext<
|
248
|
+
context: TaskContext<Test> & ExtraContext & TestContext;
|
243
249
|
}
|
244
250
|
type Task = Test | Suite | Custom | File;
|
251
|
+
/**
|
252
|
+
* @deprecated Vitest doesn't provide `done()` anymore
|
253
|
+
*/
|
245
254
|
type DoneCallback = (error?: any) => void;
|
246
255
|
type TestFunction<ExtraContext = object> = (context: ExtendedContext<Test> & ExtraContext) => Awaitable<any> | void;
|
247
256
|
type ExtractEachCallbackArgs<T extends ReadonlyArray<any>> = {
|
@@ -390,10 +399,10 @@ interface AfterAllListener {
|
|
390
399
|
(suite: Readonly<Suite | File>): Awaitable<unknown>;
|
391
400
|
}
|
392
401
|
interface BeforeEachListener<ExtraContext = object> {
|
393
|
-
(context: ExtendedContext<Test
|
402
|
+
(context: ExtendedContext<Test> & ExtraContext, suite: Readonly<Suite>): Awaitable<unknown>;
|
394
403
|
}
|
395
404
|
interface AfterEachListener<ExtraContext = object> {
|
396
|
-
(context: ExtendedContext<Test
|
405
|
+
(context: ExtendedContext<Test> & ExtraContext, suite: Readonly<Suite>): Awaitable<unknown>;
|
397
406
|
}
|
398
407
|
interface SuiteHooks<ExtraContext = object> {
|
399
408
|
beforeAll: BeforeAllListener[];
|
@@ -419,7 +428,7 @@ interface TaskCustomOptions extends TestOptions {
|
|
419
428
|
* If nothing is provided, the runner will try to get the function using `getFn(task)`.
|
420
429
|
* If the runner cannot find the function, the task will be marked as failed.
|
421
430
|
*/
|
422
|
-
handler?: (context: TaskContext<
|
431
|
+
handler?: (context: TaskContext<Test>) => Awaitable<void>;
|
423
432
|
}
|
424
433
|
interface SuiteCollector<ExtraContext = object> {
|
425
434
|
readonly name: string;
|
@@ -428,7 +437,7 @@ interface SuiteCollector<ExtraContext = object> {
|
|
428
437
|
type: 'collector';
|
429
438
|
test: TestAPI<ExtraContext>;
|
430
439
|
tasks: (Suite | Custom<ExtraContext> | Test<ExtraContext> | SuiteCollector<ExtraContext>)[];
|
431
|
-
task: (name: string, options?: TaskCustomOptions) =>
|
440
|
+
task: (name: string, options?: TaskCustomOptions) => Test<ExtraContext>;
|
432
441
|
collect: (file: File) => Promise<Suite>;
|
433
442
|
clear: () => void;
|
434
443
|
on: <T extends keyof SuiteHooks<ExtraContext>>(name: T, ...fn: SuiteHooks<ExtraContext>[T]) => void;
|
@@ -446,7 +455,7 @@ interface TestContext {
|
|
446
455
|
/**
|
447
456
|
* Context that's always available in the test function.
|
448
457
|
*/
|
449
|
-
interface TaskContext<Task extends
|
458
|
+
interface TaskContext<Task extends Test = Test> {
|
450
459
|
/**
|
451
460
|
* Metadata of the current test
|
452
461
|
*/
|
@@ -465,7 +474,7 @@ interface TaskContext<Task extends Custom | Test = Custom | Test> {
|
|
465
474
|
*/
|
466
475
|
skip: (note?: string) => void;
|
467
476
|
}
|
468
|
-
type ExtendedContext<T extends
|
477
|
+
type ExtendedContext<T extends Test> = TaskContext<T> & TestContext;
|
469
478
|
type OnTestFailedHandler = (result: TaskResult) => Awaitable<void>;
|
470
479
|
type OnTestFinishedHandler = (result: TaskResult) => Awaitable<void>;
|
471
480
|
interface TaskHook<HookListener> {
|
package/dist/types.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { DiffOptions } from '@vitest/utils/diff';
|
2
|
-
import { r as SequenceHooks, s as SequenceSetupFiles, F as File, T as Task, a as Test, C as Custom, S as Suite, G as TaskResultPack, v as TaskContext, E as ExtendedContext } from './tasks-
|
3
|
-
export { A as AfterAllListener, e as AfterEachListener, B as BeforeAllListener, d as BeforeEachListener, j as CustomAPI, D as DoneCallback, l as Fixture, m as FixtureFn, n as FixtureOptions, o as Fixtures, H as HookCleanupCallback, p as HookListener, I as InferFixturesTypes, O as OnTestFailedHandler, g as OnTestFinishedHandler, R as RunMode, q as RuntimeContext, i as SuiteAPI, k as SuiteCollector, t as SuiteFactory, h as SuiteHooks, u as TaskBase, w as TaskCustomOptions, f as TaskHook, x as TaskMeta, y as TaskPopulated, z as TaskResult, J as TaskState, j as TestAPI, K as TestContext, L as TestFunction, M as TestOptions, U as Use } from './tasks-
|
2
|
+
import { r as SequenceHooks, s as SequenceSetupFiles, F as File, T as Task, a as Test, C as Custom, S as Suite, G as TaskResultPack, v as TaskContext, E as ExtendedContext } from './tasks-CgWT5bp6.js';
|
3
|
+
export { A as AfterAllListener, e as AfterEachListener, B as BeforeAllListener, d as BeforeEachListener, j as CustomAPI, D as DoneCallback, l as Fixture, m as FixtureFn, n as FixtureOptions, o as Fixtures, H as HookCleanupCallback, p as HookListener, I as InferFixturesTypes, O as OnTestFailedHandler, g as OnTestFinishedHandler, R as RunMode, q as RuntimeContext, i as SuiteAPI, k as SuiteCollector, t as SuiteFactory, h as SuiteHooks, u as TaskBase, w as TaskCustomOptions, f as TaskHook, x as TaskMeta, y as TaskPopulated, z as TaskResult, J as TaskState, j as TestAPI, K as TestContext, L as TestFunction, M as TestOptions, U as Use } from './tasks-CgWT5bp6.js';
|
4
4
|
import '@vitest/utils';
|
5
5
|
|
6
6
|
/**
|
@@ -118,7 +118,7 @@ interface VitestRunner {
|
|
118
118
|
*
|
119
119
|
* @see https://vitest.dev/advanced/runner.html#your-task-function
|
120
120
|
*/
|
121
|
-
extendTaskContext?: <T extends Test
|
121
|
+
extendTaskContext?: <T extends Test>(context: TaskContext<T>) => ExtendedContext<T>;
|
122
122
|
/**
|
123
123
|
* Called when test and setup files are imported. Can be called in two situations: when collecting tests and when importing setup files.
|
124
124
|
*/
|
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-CgWT5bp6.js';
|
2
|
+
export { b as ChainableFunction, c as createChainable } from './tasks-CgWT5bp6.js';
|
3
3
|
import { Arrayable } from '@vitest/utils';
|
4
4
|
|
5
5
|
/**
|
@@ -21,6 +21,9 @@ declare function limitConcurrency(concurrency?: number): <Args extends unknown[]
|
|
21
21
|
*/
|
22
22
|
declare function partitionSuiteChildren(suite: Suite): Task[][];
|
23
23
|
|
24
|
+
/**
|
25
|
+
* @deprecated use `isTestCase` instead
|
26
|
+
*/
|
24
27
|
declare function isAtomTest(s: Task): s is Test | Custom;
|
25
28
|
declare function getTests(suite: Arrayable<Task>): (Test | Custom)[];
|
26
29
|
declare function getTasks(tasks?: Arrayable<Task>): Task[];
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vitest/runner",
|
3
3
|
"type": "module",
|
4
|
-
"version": "2.2.0-beta.
|
4
|
+
"version": "2.2.0-beta.2",
|
5
5
|
"description": "Vitest test runner",
|
6
6
|
"license": "MIT",
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
@@ -39,7 +39,7 @@
|
|
39
39
|
],
|
40
40
|
"dependencies": {
|
41
41
|
"pathe": "^1.1.2",
|
42
|
-
"@vitest/utils": "2.2.0-beta.
|
42
|
+
"@vitest/utils": "2.2.0-beta.2"
|
43
43
|
},
|
44
44
|
"scripts": {
|
45
45
|
"build": "rimraf dist && rollup -c",
|