@vitest/runner 3.0.0-beta.1 → 3.0.0-beta.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/chunk-tasks.js +24 -17
- package/dist/index.d.ts +6 -6
- package/dist/index.js +9 -4
- package/dist/{tasks-D_Ah6OyC.d.ts → tasks-B64RTJlW.d.ts} +25 -35
- package/dist/types.d.ts +9 -8
- package/dist/utils.d.ts +9 -3
- package/dist/utils.js +1 -1
- package/package.json +2 -2
package/dist/chunk-tasks.js
CHANGED
@@ -31,7 +31,7 @@ function createChainable(keys, fn) {
|
|
31
31
|
|
32
32
|
function interpretTaskModes(file, namePattern, testLocations, onlyMode, parentIsOnly, allowOnly) {
|
33
33
|
const matchedLocations = [];
|
34
|
-
const traverseSuite = (suite, parentIsOnly2) => {
|
34
|
+
const traverseSuite = (suite, parentIsOnly2, parentMatchedWithLocation) => {
|
35
35
|
const suiteIsOnly = parentIsOnly2 || suite.mode === "only";
|
36
36
|
suite.tasks.forEach((t) => {
|
37
37
|
const includeTask = suiteIsOnly || t.mode === "only";
|
@@ -48,33 +48,37 @@ function interpretTaskModes(file, namePattern, testLocations, onlyMode, parentIs
|
|
48
48
|
t.mode = "run";
|
49
49
|
}
|
50
50
|
}
|
51
|
+
let hasLocationMatch = parentMatchedWithLocation;
|
52
|
+
if (testLocations !== void 0 && testLocations.length !== 0) {
|
53
|
+
if (t.location && (testLocations == null ? void 0 : testLocations.includes(t.location.line))) {
|
54
|
+
t.mode = "run";
|
55
|
+
matchedLocations.push(t.location.line);
|
56
|
+
hasLocationMatch = true;
|
57
|
+
} else if (parentMatchedWithLocation) {
|
58
|
+
t.mode = "run";
|
59
|
+
} else if (t.type === "test") {
|
60
|
+
t.mode = "skip";
|
61
|
+
}
|
62
|
+
}
|
51
63
|
if (t.type === "test") {
|
52
64
|
if (namePattern && !getTaskFullName(t).match(namePattern)) {
|
53
65
|
t.mode = "skip";
|
54
66
|
}
|
55
|
-
if (testLocations !== void 0 && testLocations.length !== 0) {
|
56
|
-
if (t.location && (testLocations == null ? void 0 : testLocations.includes(t.location.line))) {
|
57
|
-
t.mode = "run";
|
58
|
-
matchedLocations.push(t.location.line);
|
59
|
-
} else {
|
60
|
-
t.mode = "skip";
|
61
|
-
}
|
62
|
-
}
|
63
67
|
} else if (t.type === "suite") {
|
64
68
|
if (t.mode === "skip") {
|
65
69
|
skipAllTasks(t);
|
66
70
|
} else {
|
67
|
-
traverseSuite(t, includeTask);
|
71
|
+
traverseSuite(t, includeTask, hasLocationMatch);
|
68
72
|
}
|
69
73
|
}
|
70
74
|
});
|
71
|
-
if (suite.mode === "run") {
|
72
|
-
if (suite.tasks.length && suite.tasks.every((i) => i.mode !== "run")) {
|
75
|
+
if (suite.mode === "run" || suite.mode === "queued") {
|
76
|
+
if (suite.tasks.length && suite.tasks.every((i) => i.mode !== "run" && i.mode !== "queued")) {
|
73
77
|
suite.mode = "skip";
|
74
78
|
}
|
75
79
|
}
|
76
80
|
};
|
77
|
-
traverseSuite(file, parentIsOnly);
|
81
|
+
traverseSuite(file, parentIsOnly, false);
|
78
82
|
const nonMatching = testLocations == null ? void 0 : testLocations.filter((loc) => !matchedLocations.includes(loc));
|
79
83
|
if (nonMatching && nonMatching.length !== 0) {
|
80
84
|
const message = nonMatching.length === 1 ? `line ${nonMatching[0]}` : `lines ${nonMatching.join(", ")}`;
|
@@ -102,7 +106,7 @@ function someTasksAreOnly(suite) {
|
|
102
106
|
}
|
103
107
|
function skipAllTasks(suite) {
|
104
108
|
suite.tasks.forEach((t) => {
|
105
|
-
if (t.mode === "run") {
|
109
|
+
if (t.mode === "run" || t.mode === "queued") {
|
106
110
|
t.mode = "skip";
|
107
111
|
if (t.type === "suite") {
|
108
112
|
skipAllTasks(t);
|
@@ -147,10 +151,10 @@ function calculateSuiteHash(parent) {
|
|
147
151
|
function createFileTask(filepath, root, projectName, pool) {
|
148
152
|
const path = relative(root, filepath);
|
149
153
|
const file = {
|
150
|
-
id:
|
154
|
+
id: generateFileHash(path, projectName),
|
151
155
|
name: path,
|
152
156
|
type: "suite",
|
153
|
-
mode: "
|
157
|
+
mode: "queued",
|
154
158
|
filepath,
|
155
159
|
tasks: [],
|
156
160
|
meta: /* @__PURE__ */ Object.create(null),
|
@@ -161,6 +165,9 @@ function createFileTask(filepath, root, projectName, pool) {
|
|
161
165
|
file.file = file;
|
162
166
|
return file;
|
163
167
|
}
|
168
|
+
function generateFileHash(file, projectName) {
|
169
|
+
return generateHash(`${file}${projectName || ""}`);
|
170
|
+
}
|
164
171
|
|
165
172
|
function limitConcurrency(concurrency = Infinity) {
|
166
173
|
let count = 0;
|
@@ -277,4 +284,4 @@ function getTestName(task, separator = " > ") {
|
|
277
284
|
return getNames(task).slice(1).join(separator);
|
278
285
|
}
|
279
286
|
|
280
|
-
export { calculateSuiteHash as a, createFileTask as b, createChainable as c,
|
287
|
+
export { calculateSuiteHash as a, createFileTask as b, createChainable as c, generateHash as d, getFullName as e, getNames as f, generateFileHash as g, getSuites as h, interpretTaskModes as i, getTasks as j, getTestName as k, limitConcurrency as l, getTests as m, hasFailed as n, hasTests as o, partitionSuiteChildren as p, isAtomTest as q, isTestCase as r, someTasksAreOnly as s };
|
package/dist/index.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
import { B as BeforeAllListener, A as AfterAllListener, b as BeforeEachListener, d as AfterEachListener, e as TaskHook, O as OnTestFailedHandler, f as OnTestFinishedHandler, a as Test, g 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, b as BeforeEachListener, d as AfterEachListener, e as TaskHook, O as OnTestFailedHandler, f as OnTestFinishedHandler, a as Test, g 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-B64RTJlW.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-B64RTJlW.js';
|
3
3
|
import { Awaitable } from '@vitest/utils';
|
4
|
-
import { VitestRunner,
|
4
|
+
import { VitestRunner, FileSpecification } from './types.js';
|
5
5
|
export { CancelReason, VitestRunnerConfig, VitestRunnerConstructor, VitestRunnerImportSource } from './types.js';
|
6
6
|
export { processError } from '@vitest/utils/error';
|
7
7
|
import '@vitest/utils/diff';
|
@@ -126,8 +126,8 @@ declare function setHooks(key: Suite, hooks: SuiteHooks): void;
|
|
126
126
|
declare function getHooks(key: Suite): SuiteHooks;
|
127
127
|
|
128
128
|
declare function updateTask(task: Task, runner: VitestRunner): void;
|
129
|
-
declare function startTests(specs: string[] |
|
130
|
-
declare function publicCollect(specs: string[] |
|
129
|
+
declare function startTests(specs: string[] | FileSpecification[], runner: VitestRunner): Promise<File[]>;
|
130
|
+
declare function publicCollect(specs: string[] | FileSpecification[], runner: VitestRunner): Promise<File[]>;
|
131
131
|
|
132
132
|
/**
|
133
133
|
* Creates a suite of tests, allowing for grouping and hierarchical organization of tests.
|
@@ -256,4 +256,4 @@ declare function createTaskCollector(fn: (...args: any[]) => any, context?: Reco
|
|
256
256
|
|
257
257
|
declare function getCurrentTest<T extends Test | undefined>(): T;
|
258
258
|
|
259
|
-
export { AfterAllListener, AfterEachListener, BeforeAllListener, BeforeEachListener, Custom, TestAPI as CustomAPI, File,
|
259
|
+
export { AfterAllListener, AfterEachListener, BeforeAllListener, BeforeEachListener, Custom, TestAPI as CustomAPI, File, FileSpecification, OnTestFailedHandler, OnTestFinishedHandler, Suite, SuiteAPI, SuiteCollector, SuiteHooks, Task, TaskHook, Test, TestAPI, VitestRunner, afterAll, afterEach, beforeAll, beforeEach, publicCollect as collectTests, createTaskCollector, describe, getCurrentSuite, getCurrentTest, getFn, getHooks, it, onTestFailed, onTestFinished, setFn, setHooks, startTests, suite, test, updateTask };
|
package/dist/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { getSafeTimers, isObject, createDefer, isNegativeNaN, format, objDisplay, objectAttr, toArray, assertTypes, shuffle } from '@vitest/utils';
|
2
2
|
import { parseSingleStack } from '@vitest/utils/source-map';
|
3
|
-
import { c as createChainable, b as createFileTask, a as calculateSuiteHash, s as someTasksAreOnly, i as interpretTaskModes, l as limitConcurrency, p as partitionSuiteChildren,
|
3
|
+
import { c as createChainable, b as createFileTask, a as calculateSuiteHash, s as someTasksAreOnly, i as interpretTaskModes, l as limitConcurrency, p as partitionSuiteChildren, o as hasTests, n as hasFailed } from './chunk-tasks.js';
|
4
4
|
import { processError } from '@vitest/utils/error';
|
5
5
|
export { processError } from '@vitest/utils/error';
|
6
6
|
import 'pathe';
|
@@ -37,7 +37,6 @@ function withTimeout(fn, timeout, isHook = false) {
|
|
37
37
|
const { setTimeout, clearTimeout } = getSafeTimers();
|
38
38
|
return function runWithTimeout(...args) {
|
39
39
|
return Promise.race([
|
40
|
-
fn(...args),
|
41
40
|
new Promise((resolve, reject) => {
|
42
41
|
var _a;
|
43
42
|
const timer = setTimeout(() => {
|
@@ -45,6 +44,9 @@ function withTimeout(fn, timeout, isHook = false) {
|
|
45
44
|
reject(new Error(makeTimeoutMsg(isHook, timeout)));
|
46
45
|
}, timeout);
|
47
46
|
(_a = timer.unref) == null ? void 0 : _a.call(timer);
|
47
|
+
}),
|
48
|
+
Promise.resolve(fn(...args)).then((result) => {
|
49
|
+
return new Promise((resolve) => setTimeout(resolve, 0, result));
|
48
50
|
})
|
49
51
|
]);
|
50
52
|
};
|
@@ -908,6 +910,9 @@ async function collectTests(specs, runner) {
|
|
908
910
|
false,
|
909
911
|
config.allowOnly
|
910
912
|
);
|
913
|
+
if (file.mode === "queued") {
|
914
|
+
file.mode = "run";
|
915
|
+
}
|
911
916
|
files.push(file);
|
912
917
|
}
|
913
918
|
return files;
|
@@ -1042,7 +1047,7 @@ async function callCleanupHooks(cleanups) {
|
|
1042
1047
|
async function runTest(test, runner) {
|
1043
1048
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
1044
1049
|
await ((_a = runner.onBeforeRunTask) == null ? void 0 : _a.call(runner, test));
|
1045
|
-
if (test.mode !== "run") {
|
1050
|
+
if (test.mode !== "run" && test.mode !== "queued") {
|
1046
1051
|
return;
|
1047
1052
|
}
|
1048
1053
|
if (((_b = test.result) == null ? void 0 : _b.state) === "fail") {
|
@@ -1249,7 +1254,7 @@ async function runSuite(suite, runner) {
|
|
1249
1254
|
} catch (e) {
|
1250
1255
|
failTask(suite.result, e, runner.config.diffOptions);
|
1251
1256
|
}
|
1252
|
-
if (suite.mode === "run") {
|
1257
|
+
if (suite.mode === "run" || suite.mode === "queued") {
|
1253
1258
|
if (!runner.config.passWithNoTests && !hasTests(suite)) {
|
1254
1259
|
suite.result.state = "fail";
|
1255
1260
|
if (!((_c = suite.result.errors) == null ? void 0 : _c.length)) {
|
@@ -3,10 +3,6 @@ import { ErrorWithDiff, Awaitable } from '@vitest/utils';
|
|
3
3
|
interface FixtureItem extends FixtureOptions {
|
4
4
|
prop: string;
|
5
5
|
value: any;
|
6
|
-
/**
|
7
|
-
* Indicated if the injected value should be preferred over the fixture value
|
8
|
-
*/
|
9
|
-
injected?: boolean;
|
10
6
|
/**
|
11
7
|
* Indicates whether the fixture is a function
|
12
8
|
*/
|
@@ -24,7 +20,7 @@ type ChainableFunction<T extends string, F extends (...args: any) => any, C = ob
|
|
24
20
|
} & C;
|
25
21
|
declare function createChainable<T extends string, Args extends any[], R = any>(keys: T[], fn: (this: Record<T, any>, ...args: Args) => R): ChainableFunction<T, (...args: Args) => R>;
|
26
22
|
|
27
|
-
type RunMode = 'run' | 'skip' | 'only' | 'todo';
|
23
|
+
type RunMode = 'run' | 'skip' | 'only' | 'todo' | 'queued';
|
28
24
|
type TaskState = RunMode | 'pass' | 'fail';
|
29
25
|
interface TaskBase {
|
30
26
|
/**
|
@@ -44,6 +40,7 @@ interface TaskBase {
|
|
44
40
|
* - **only**: only this task and other tasks with `only` mode will run
|
45
41
|
* - **todo**: task is marked as a todo, alias for `skip`
|
46
42
|
* - **run**: task will run or already ran
|
43
|
+
* - **queued**: task will start running next. It can only exist on the File
|
47
44
|
*/
|
48
45
|
mode: RunMode;
|
49
46
|
/**
|
@@ -105,14 +102,6 @@ interface TaskPopulated extends TaskBase {
|
|
105
102
|
* Whether the task should succeed if it fails. If the task fails, it will be marked as passed.
|
106
103
|
*/
|
107
104
|
fails?: boolean;
|
108
|
-
/**
|
109
|
-
* Hooks that will run if the task fails. The order depends on the `sequence.hooks` option.
|
110
|
-
*/
|
111
|
-
onFailed?: OnTestFailedHandler[];
|
112
|
-
/**
|
113
|
-
* Hooks that will run after the task finishes. The order depends on the `sequence.hooks` option.
|
114
|
-
*/
|
115
|
-
onFinished?: OnTestFinishedHandler[];
|
116
105
|
/**
|
117
106
|
* Store promises (from async expects) to wait for them before finishing the test
|
118
107
|
*/
|
@@ -136,7 +125,7 @@ interface TaskResult {
|
|
136
125
|
state: TaskState;
|
137
126
|
/**
|
138
127
|
* Errors that occurred during the task execution. It is possible to have several errors
|
139
|
-
* if `expect.soft()` failed multiple times.
|
128
|
+
* if `expect.soft()` failed multiple times or `retry` was triggered.
|
140
129
|
*/
|
141
130
|
errors?: ErrorWithDiff[];
|
142
131
|
/**
|
@@ -221,18 +210,13 @@ interface File extends Suite {
|
|
221
210
|
* The time it took to import the setup file.
|
222
211
|
*/
|
223
212
|
setupDuration?: number;
|
224
|
-
/**
|
225
|
-
* Whether the file is initiated without running any tests.
|
226
|
-
* This is done to populate state on the server side by Vitest.
|
227
|
-
*/
|
228
|
-
local?: boolean;
|
229
213
|
}
|
230
214
|
interface Test<ExtraContext = object> extends TaskPopulated {
|
231
215
|
type: 'test';
|
232
216
|
/**
|
233
217
|
* Test context that will be passed to the test function.
|
234
218
|
*/
|
235
|
-
context:
|
219
|
+
context: TestContext & ExtraContext;
|
236
220
|
}
|
237
221
|
/**
|
238
222
|
* @deprecated Use `Test` instead. `type: 'custom'` is not used since 2.2
|
@@ -243,7 +227,7 @@ type Task = Test | Suite | File;
|
|
243
227
|
* @deprecated Vitest doesn't provide `done()` anymore
|
244
228
|
*/
|
245
229
|
type DoneCallback = (error?: any) => void;
|
246
|
-
type TestFunction<ExtraContext = object> = (context:
|
230
|
+
type TestFunction<ExtraContext = object> = (context: TestContext & ExtraContext) => Awaitable<any> | void;
|
247
231
|
type ExtractEachCallbackArgs<T extends ReadonlyArray<any>> = {
|
248
232
|
1: [T[0]];
|
249
233
|
2: [T[0], T[1]];
|
@@ -276,8 +260,8 @@ interface TestForFunctionReturn<Arg, Context> {
|
|
276
260
|
(name: string | Function, options: TestCollectorOptions, fn: (args: Arg, context: Context) => Awaitable<void>): void;
|
277
261
|
}
|
278
262
|
interface TestForFunction<ExtraContext> {
|
279
|
-
<T>(cases: ReadonlyArray<T>): TestForFunctionReturn<T,
|
280
|
-
(strings: TemplateStringsArray, ...values: any[]): TestForFunctionReturn<any,
|
263
|
+
<T>(cases: ReadonlyArray<T>): TestForFunctionReturn<T, TestContext & ExtraContext>;
|
264
|
+
(strings: TemplateStringsArray, ...values: any[]): TestForFunctionReturn<any, TestContext & ExtraContext>;
|
281
265
|
}
|
282
266
|
interface TestCollectorCallable<C = object> {
|
283
267
|
/**
|
@@ -357,12 +341,16 @@ interface FixtureOptions {
|
|
357
341
|
* Whether to automatically set up current fixture, even though it's not being used in tests.
|
358
342
|
*/
|
359
343
|
auto?: boolean;
|
344
|
+
/**
|
345
|
+
* Indicated if the injected value from the config should be preferred over the fixture value
|
346
|
+
*/
|
347
|
+
injected?: boolean;
|
360
348
|
}
|
361
349
|
type Use<T> = (value: T) => Promise<void>;
|
362
350
|
type FixtureFn<T, K extends keyof T, ExtraContext> = (context: Omit<T, K> & ExtraContext, use: Use<T[K]>) => Promise<void>;
|
363
351
|
type Fixture<T, K extends keyof T, ExtraContext = object> = ((...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);
|
364
352
|
type Fixtures<T extends Record<string, any>, ExtraContext = object> = {
|
365
|
-
[K in keyof T]: Fixture<T, K, ExtraContext &
|
353
|
+
[K in keyof T]: Fixture<T, K, ExtraContext & TestContext> | [Fixture<T, K, ExtraContext & TestContext>, FixtureOptions?];
|
366
354
|
};
|
367
355
|
type InferFixturesTypes<T> = T extends TestAPI<infer C> ? C : T;
|
368
356
|
interface SuiteCollectorCallable<ExtraContext = object> {
|
@@ -395,10 +383,10 @@ interface AfterAllListener {
|
|
395
383
|
(suite: Readonly<Suite | File>): Awaitable<unknown>;
|
396
384
|
}
|
397
385
|
interface BeforeEachListener<ExtraContext = object> {
|
398
|
-
(context:
|
386
|
+
(context: TestContext & ExtraContext, suite: Readonly<Suite>): Awaitable<unknown>;
|
399
387
|
}
|
400
388
|
interface AfterEachListener<ExtraContext = object> {
|
401
|
-
(context:
|
389
|
+
(context: TestContext & ExtraContext, suite: Readonly<Suite>): Awaitable<unknown>;
|
402
390
|
}
|
403
391
|
interface SuiteHooks<ExtraContext = object> {
|
404
392
|
beforeAll: BeforeAllListener[];
|
@@ -424,7 +412,7 @@ interface TaskCustomOptions extends TestOptions {
|
|
424
412
|
* If nothing is provided, the runner will try to get the function using `getFn(task)`.
|
425
413
|
* If the runner cannot find the function, the task will be marked as failed.
|
426
414
|
*/
|
427
|
-
handler?: (context:
|
415
|
+
handler?: (context: TestContext) => Awaitable<void>;
|
428
416
|
}
|
429
417
|
interface SuiteCollector<ExtraContext = object> {
|
430
418
|
readonly name: string;
|
@@ -447,11 +435,6 @@ interface RuntimeContext {
|
|
447
435
|
* User's custom test context.
|
448
436
|
*/
|
449
437
|
interface TestContext {
|
450
|
-
}
|
451
|
-
/**
|
452
|
-
* Context that's always available in the test function.
|
453
|
-
*/
|
454
|
-
interface TaskContext<Task extends Test = Test> {
|
455
438
|
/**
|
456
439
|
* Metadata of the current test
|
457
440
|
*/
|
@@ -470,9 +453,16 @@ interface TaskContext<Task extends Test = Test> {
|
|
470
453
|
*/
|
471
454
|
skip: (note?: string) => void;
|
472
455
|
}
|
473
|
-
|
474
|
-
|
475
|
-
|
456
|
+
/**
|
457
|
+
* Context that's always available in the test function.
|
458
|
+
* @deprecated use `TestContext` instead
|
459
|
+
*/
|
460
|
+
interface TaskContext extends TestContext {
|
461
|
+
}
|
462
|
+
/** @deprecated use `TestContext` instead */
|
463
|
+
type ExtendedContext = TaskContext & TestContext;
|
464
|
+
type OnTestFailedHandler = (context: TestContext) => Awaitable<void>;
|
465
|
+
type OnTestFinishedHandler = (context: TestContext) => Awaitable<void>;
|
476
466
|
interface TaskHook<HookListener> {
|
477
467
|
(fn: HookListener, timeout?: number): void;
|
478
468
|
}
|
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, S as Suite, G as TaskResultPack,
|
3
|
-
export { A as AfterAllListener, d as AfterEachListener, B as BeforeAllListener, b as BeforeEachListener, g as Custom, 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, f 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, e as TaskHook, x as TaskMeta, y as TaskPopulated, z as TaskResult, J as TaskState, j as TestAPI,
|
2
|
+
import { r as SequenceHooks, s as SequenceSetupFiles, F as File, T as Task, a as Test, S as Suite, G as TaskResultPack, K as TestContext } from './tasks-B64RTJlW.js';
|
3
|
+
export { A as AfterAllListener, d as AfterEachListener, B as BeforeAllListener, b as BeforeEachListener, g as Custom, j as CustomAPI, 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, O as OnTestFailedHandler, f as OnTestFinishedHandler, R as RunMode, q as RuntimeContext, i as SuiteAPI, k as SuiteCollector, t as SuiteFactory, h as SuiteHooks, u as TaskBase, v as TaskContext, w as TaskCustomOptions, e as TaskHook, x as TaskMeta, y as TaskPopulated, z as TaskResult, J as TaskState, j as TestAPI, L as TestFunction, M as TestOptions, U as Use } from './tasks-B64RTJlW.js';
|
4
4
|
import '@vitest/utils';
|
5
5
|
|
6
6
|
/**
|
@@ -30,7 +30,10 @@ interface VitestRunnerConfig {
|
|
30
30
|
includeTaskLocation?: boolean;
|
31
31
|
diffOptions?: DiffOptions;
|
32
32
|
}
|
33
|
-
|
33
|
+
/**
|
34
|
+
* Possible options to run a single file in a test.
|
35
|
+
*/
|
36
|
+
interface FileSpecification {
|
34
37
|
filepath: string;
|
35
38
|
testLocations: number[] | undefined;
|
36
39
|
}
|
@@ -118,11 +121,9 @@ interface VitestRunner {
|
|
118
121
|
* Called when new context for a test is defined. Useful if you want to add custom properties to the context.
|
119
122
|
* If you only want to define custom context, consider using "beforeAll" in "setupFiles" instead.
|
120
123
|
*
|
121
|
-
*
|
122
|
-
*
|
123
|
-
* @see https://vitest.dev/advanced/runner.html#your-task-function
|
124
|
+
* @see https://vitest.dev/advanced/runner#your-task-function
|
124
125
|
*/
|
125
|
-
extendTaskContext?:
|
126
|
+
extendTaskContext?: (context: TestContext) => TestContext;
|
126
127
|
/**
|
127
128
|
* Called when test and setup files are imported. Can be called in two situations: when collecting tests and when importing setup files.
|
128
129
|
*/
|
@@ -141,4 +142,4 @@ interface VitestRunner {
|
|
141
142
|
pool?: string;
|
142
143
|
}
|
143
144
|
|
144
|
-
export { type CancelReason,
|
145
|
+
export { type CancelReason, File, type FileSpecification, SequenceHooks, SequenceSetupFiles, Suite, Task, TaskResultPack, Test, TestContext, 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 } from './tasks-
|
2
|
-
export { C as ChainableFunction, c as createChainable } from './tasks-
|
1
|
+
import { S as Suite, F as File, T as Task, a as Test } from './tasks-B64RTJlW.js';
|
2
|
+
export { C as ChainableFunction, c as createChainable } from './tasks-B64RTJlW.js';
|
3
3
|
import { Arrayable } from '@vitest/utils';
|
4
4
|
|
5
5
|
/**
|
@@ -10,6 +10,12 @@ declare function someTasksAreOnly(suite: Suite): boolean;
|
|
10
10
|
declare function generateHash(str: string): string;
|
11
11
|
declare function calculateSuiteHash(parent: Suite): void;
|
12
12
|
declare function createFileTask(filepath: string, root: string, projectName: string | undefined, pool?: string): File;
|
13
|
+
/**
|
14
|
+
* Generate a unique ID for a file based on its path and project name
|
15
|
+
* @param file File relative to the root of the project to keep ID the same between different machines
|
16
|
+
* @param projectName The name of the test project
|
17
|
+
*/
|
18
|
+
declare function generateFileHash(file: string, projectName: string | undefined): string;
|
13
19
|
|
14
20
|
/**
|
15
21
|
* Return a function for running multiple async operations with limited concurrency.
|
@@ -35,4 +41,4 @@ declare function getNames(task: Task): string[];
|
|
35
41
|
declare function getFullName(task: Task, separator?: string): string;
|
36
42
|
declare function getTestName(task: Task, separator?: string): string;
|
37
43
|
|
38
|
-
export { calculateSuiteHash, createFileTask, generateHash, getFullName, getNames, getSuites, getTasks, getTestName, getTests, hasFailed, hasTests, interpretTaskModes, isAtomTest, isTestCase, limitConcurrency, partitionSuiteChildren, someTasksAreOnly };
|
44
|
+
export { calculateSuiteHash, createFileTask, generateFileHash, generateHash, getFullName, getNames, getSuites, getTasks, getTestName, getTests, hasFailed, hasTests, interpretTaskModes, isAtomTest, isTestCase, limitConcurrency, partitionSuiteChildren, someTasksAreOnly };
|
package/dist/utils.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
export { a as calculateSuiteHash, c as createChainable, b as createFileTask, g as
|
1
|
+
export { a as calculateSuiteHash, c as createChainable, b as createFileTask, g as generateFileHash, d as generateHash, e as getFullName, f as getNames, h as getSuites, j as getTasks, k as getTestName, m as getTests, n as hasFailed, o as hasTests, i as interpretTaskModes, q as isAtomTest, r as isTestCase, l 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": "3.0.0-beta.
|
4
|
+
"version": "3.0.0-beta.3",
|
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": "3.0.0-beta.
|
42
|
+
"@vitest/utils": "3.0.0-beta.3"
|
43
43
|
},
|
44
44
|
"scripts": {
|
45
45
|
"build": "rimraf dist && rollup -c",
|