@vitest/runner 0.29.7 → 0.30.0
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 +105 -103
- package/dist/index.d.ts +15 -13
- package/dist/index.js +34 -13
- package/dist/{runner-b9659804.d.ts → runner-751eaed8.d.ts} +1 -1
- package/dist/{tasks-3fbb29e4.d.ts → tasks-c965d7f6.d.ts} +6 -31
- package/dist/types.d.ts +2 -2
- package/dist/utils.d.ts +12 -3
- package/dist/utils.js +1 -0
- package/package.json +3 -2
package/dist/chunk-tasks.js
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import { format, deepClone, stringify, getOwnProperties, getType, toArray } from '@vitest/utils';
|
2
|
+
import { unifiedDiff } from '@vitest/utils/diff';
|
2
3
|
|
3
4
|
function partitionSuiteChildren(suite) {
|
4
5
|
let tasksGroup = [];
|
@@ -16,106 +17,11 @@ function partitionSuiteChildren(suite) {
|
|
16
17
|
return tasksGroups;
|
17
18
|
}
|
18
19
|
|
19
|
-
function interpretTaskModes(suite, namePattern, onlyMode, parentIsOnly, allowOnly) {
|
20
|
-
const suiteIsOnly = parentIsOnly || suite.mode === "only";
|
21
|
-
suite.tasks.forEach((t) => {
|
22
|
-
const includeTask = suiteIsOnly || t.mode === "only";
|
23
|
-
if (onlyMode) {
|
24
|
-
if (t.type === "suite" && (includeTask || someTasksAreOnly(t))) {
|
25
|
-
if (t.mode === "only") {
|
26
|
-
checkAllowOnly(t, allowOnly);
|
27
|
-
t.mode = "run";
|
28
|
-
}
|
29
|
-
} else if (t.mode === "run" && !includeTask) {
|
30
|
-
t.mode = "skip";
|
31
|
-
} else if (t.mode === "only") {
|
32
|
-
checkAllowOnly(t, allowOnly);
|
33
|
-
t.mode = "run";
|
34
|
-
}
|
35
|
-
}
|
36
|
-
if (t.type === "test") {
|
37
|
-
if (namePattern && !getTaskFullName(t).match(namePattern))
|
38
|
-
t.mode = "skip";
|
39
|
-
} else if (t.type === "suite") {
|
40
|
-
if (t.mode === "skip")
|
41
|
-
skipAllTasks(t);
|
42
|
-
else
|
43
|
-
interpretTaskModes(t, namePattern, onlyMode, includeTask, allowOnly);
|
44
|
-
}
|
45
|
-
});
|
46
|
-
if (suite.mode === "run") {
|
47
|
-
if (suite.tasks.length && suite.tasks.every((i) => i.mode !== "run"))
|
48
|
-
suite.mode = "skip";
|
49
|
-
}
|
50
|
-
}
|
51
|
-
function getTaskFullName(task) {
|
52
|
-
return `${task.suite ? `${getTaskFullName(task.suite)} ` : ""}${task.name}`;
|
53
|
-
}
|
54
|
-
function someTasksAreOnly(suite) {
|
55
|
-
return suite.tasks.some((t) => t.mode === "only" || t.type === "suite" && someTasksAreOnly(t));
|
56
|
-
}
|
57
|
-
function skipAllTasks(suite) {
|
58
|
-
suite.tasks.forEach((t) => {
|
59
|
-
if (t.mode === "run") {
|
60
|
-
t.mode = "skip";
|
61
|
-
if (t.type === "suite")
|
62
|
-
skipAllTasks(t);
|
63
|
-
}
|
64
|
-
});
|
65
|
-
}
|
66
|
-
function checkAllowOnly(task, allowOnly) {
|
67
|
-
if (allowOnly)
|
68
|
-
return;
|
69
|
-
const error = new Error("[Vitest] Unexpected .only modifier. Remove it or pass --allowOnly argument to bypass this error");
|
70
|
-
task.result = {
|
71
|
-
state: "fail",
|
72
|
-
error,
|
73
|
-
errors: [error]
|
74
|
-
};
|
75
|
-
}
|
76
|
-
function generateHash(str) {
|
77
|
-
let hash = 0;
|
78
|
-
if (str.length === 0)
|
79
|
-
return `${hash}`;
|
80
|
-
for (let i = 0; i < str.length; i++) {
|
81
|
-
const char = str.charCodeAt(i);
|
82
|
-
hash = (hash << 5) - hash + char;
|
83
|
-
hash = hash & hash;
|
84
|
-
}
|
85
|
-
return `${hash}`;
|
86
|
-
}
|
87
|
-
function calculateSuiteHash(parent) {
|
88
|
-
parent.tasks.forEach((t, idx) => {
|
89
|
-
t.id = `${parent.id}_${idx}`;
|
90
|
-
if (t.type === "suite")
|
91
|
-
calculateSuiteHash(t);
|
92
|
-
});
|
93
|
-
}
|
94
|
-
|
95
|
-
function createChainable(keys, fn) {
|
96
|
-
function create(context) {
|
97
|
-
const chain2 = function(...args) {
|
98
|
-
return fn.apply(context, args);
|
99
|
-
};
|
100
|
-
Object.assign(chain2, fn);
|
101
|
-
chain2.withContext = () => chain2.bind(context);
|
102
|
-
for (const key of keys) {
|
103
|
-
Object.defineProperty(chain2, key, {
|
104
|
-
get() {
|
105
|
-
return create({ ...context, [key]: true });
|
106
|
-
}
|
107
|
-
});
|
108
|
-
}
|
109
|
-
return chain2;
|
110
|
-
}
|
111
|
-
const chain = create({});
|
112
|
-
chain.fn = fn;
|
113
|
-
return chain;
|
114
|
-
}
|
115
|
-
|
116
20
|
const IS_RECORD_SYMBOL = "@@__IMMUTABLE_RECORD__@@";
|
117
21
|
const IS_COLLECTION_SYMBOL = "@@__IMMUTABLE_ITERABLE__@@";
|
118
|
-
|
22
|
+
function isImmutable(v) {
|
23
|
+
return v && (v[IS_COLLECTION_SYMBOL] || v[IS_RECORD_SYMBOL]);
|
24
|
+
}
|
119
25
|
const OBJECT_PROTO = Object.getPrototypeOf({});
|
120
26
|
function getUnserializableMessage(err) {
|
121
27
|
if (err instanceof Error)
|
@@ -187,13 +93,12 @@ function processError(err, options = {}) {
|
|
187
93
|
const clonedActual = deepClone(err.actual);
|
188
94
|
const clonedExpected = deepClone(err.expected);
|
189
95
|
const { replacedActual, replacedExpected } = replaceAsymmetricMatcher(clonedActual, clonedExpected);
|
190
|
-
err.actual
|
191
|
-
|
192
|
-
const maxDiffSize = options.outputDiffMaxSize ?? 1e4;
|
96
|
+
if (err.showDiff || err.showDiff === void 0 && err.expected !== void 0 && err.actual !== void 0)
|
97
|
+
err.diff = unifiedDiff(replacedActual, replacedExpected, options);
|
193
98
|
if (typeof err.expected !== "string")
|
194
|
-
err.expected = stringify(err.expected, 10
|
99
|
+
err.expected = stringify(err.expected, 10);
|
195
100
|
if (typeof err.actual !== "string")
|
196
|
-
err.actual = stringify(err.actual, 10
|
101
|
+
err.actual = stringify(err.actual, 10);
|
197
102
|
try {
|
198
103
|
if (typeof err.message === "string")
|
199
104
|
err.message = normalizeErrorMessage(err.message);
|
@@ -250,6 +155,103 @@ function replaceAsymmetricMatcher(actual, expected, actualReplaced = /* @__PURE_
|
|
250
155
|
};
|
251
156
|
}
|
252
157
|
|
158
|
+
function interpretTaskModes(suite, namePattern, onlyMode, parentIsOnly, allowOnly) {
|
159
|
+
const suiteIsOnly = parentIsOnly || suite.mode === "only";
|
160
|
+
suite.tasks.forEach((t) => {
|
161
|
+
const includeTask = suiteIsOnly || t.mode === "only";
|
162
|
+
if (onlyMode) {
|
163
|
+
if (t.type === "suite" && (includeTask || someTasksAreOnly(t))) {
|
164
|
+
if (t.mode === "only") {
|
165
|
+
checkAllowOnly(t, allowOnly);
|
166
|
+
t.mode = "run";
|
167
|
+
}
|
168
|
+
} else if (t.mode === "run" && !includeTask) {
|
169
|
+
t.mode = "skip";
|
170
|
+
} else if (t.mode === "only") {
|
171
|
+
checkAllowOnly(t, allowOnly);
|
172
|
+
t.mode = "run";
|
173
|
+
}
|
174
|
+
}
|
175
|
+
if (t.type === "test") {
|
176
|
+
if (namePattern && !getTaskFullName(t).match(namePattern))
|
177
|
+
t.mode = "skip";
|
178
|
+
} else if (t.type === "suite") {
|
179
|
+
if (t.mode === "skip")
|
180
|
+
skipAllTasks(t);
|
181
|
+
else
|
182
|
+
interpretTaskModes(t, namePattern, onlyMode, includeTask, allowOnly);
|
183
|
+
}
|
184
|
+
});
|
185
|
+
if (suite.mode === "run") {
|
186
|
+
if (suite.tasks.length && suite.tasks.every((i) => i.mode !== "run"))
|
187
|
+
suite.mode = "skip";
|
188
|
+
}
|
189
|
+
}
|
190
|
+
function getTaskFullName(task) {
|
191
|
+
return `${task.suite ? `${getTaskFullName(task.suite)} ` : ""}${task.name}`;
|
192
|
+
}
|
193
|
+
function someTasksAreOnly(suite) {
|
194
|
+
return suite.tasks.some((t) => t.mode === "only" || t.type === "suite" && someTasksAreOnly(t));
|
195
|
+
}
|
196
|
+
function skipAllTasks(suite) {
|
197
|
+
suite.tasks.forEach((t) => {
|
198
|
+
if (t.mode === "run") {
|
199
|
+
t.mode = "skip";
|
200
|
+
if (t.type === "suite")
|
201
|
+
skipAllTasks(t);
|
202
|
+
}
|
203
|
+
});
|
204
|
+
}
|
205
|
+
function checkAllowOnly(task, allowOnly) {
|
206
|
+
if (allowOnly)
|
207
|
+
return;
|
208
|
+
const error = processError(new Error("[Vitest] Unexpected .only modifier. Remove it or pass --allowOnly argument to bypass this error"));
|
209
|
+
task.result = {
|
210
|
+
state: "fail",
|
211
|
+
error,
|
212
|
+
errors: [error]
|
213
|
+
};
|
214
|
+
}
|
215
|
+
function generateHash(str) {
|
216
|
+
let hash = 0;
|
217
|
+
if (str.length === 0)
|
218
|
+
return `${hash}`;
|
219
|
+
for (let i = 0; i < str.length; i++) {
|
220
|
+
const char = str.charCodeAt(i);
|
221
|
+
hash = (hash << 5) - hash + char;
|
222
|
+
hash = hash & hash;
|
223
|
+
}
|
224
|
+
return `${hash}`;
|
225
|
+
}
|
226
|
+
function calculateSuiteHash(parent) {
|
227
|
+
parent.tasks.forEach((t, idx) => {
|
228
|
+
t.id = `${parent.id}_${idx}`;
|
229
|
+
if (t.type === "suite")
|
230
|
+
calculateSuiteHash(t);
|
231
|
+
});
|
232
|
+
}
|
233
|
+
|
234
|
+
function createChainable(keys, fn) {
|
235
|
+
function create(context) {
|
236
|
+
const chain2 = function(...args) {
|
237
|
+
return fn.apply(context, args);
|
238
|
+
};
|
239
|
+
Object.assign(chain2, fn);
|
240
|
+
chain2.withContext = () => chain2.bind(context);
|
241
|
+
for (const key of keys) {
|
242
|
+
Object.defineProperty(chain2, key, {
|
243
|
+
get() {
|
244
|
+
return create({ ...context, [key]: true });
|
245
|
+
}
|
246
|
+
});
|
247
|
+
}
|
248
|
+
return chain2;
|
249
|
+
}
|
250
|
+
const chain = create({});
|
251
|
+
chain.fn = fn;
|
252
|
+
return chain;
|
253
|
+
}
|
254
|
+
|
253
255
|
function isAtomTest(s) {
|
254
256
|
return s.type === "test" || s.type === "custom";
|
255
257
|
}
|
package/dist/index.d.ts
CHANGED
@@ -1,25 +1,27 @@
|
|
1
|
-
import { V as VitestRunner } from './runner-
|
2
|
-
export {
|
3
|
-
import { T as Task, F as File, S as SuiteAPI, a as TestAPI, b as SuiteCollector, c as SuiteHooks,
|
4
|
-
export { D as DoneCallback,
|
1
|
+
import { V as VitestRunner } from './runner-751eaed8.js';
|
2
|
+
export { a as VitestRunnerConfig, c as VitestRunnerConstructor, b as VitestRunnerImportSource } from './runner-751eaed8.js';
|
3
|
+
import { T as Task, F as File, S as SuiteAPI, a as TestAPI, b as SuiteCollector, c as SuiteHooks, O as OnTestFailedHandler, d as Test } from './tasks-c965d7f6.js';
|
4
|
+
export { D as DoneCallback, m as HookCleanupCallback, H as HookListener, R as RunMode, o as RuntimeContext, q as SequenceHooks, r as SequenceSetupFiles, j as Suite, n as SuiteFactory, f as TaskBase, g as TaskCustom, h as TaskResult, i as TaskResultPack, e as TaskState, p as TestContext, k as TestFunction, l as TestOptions } from './tasks-c965d7f6.js';
|
5
5
|
import { Awaitable } from '@vitest/utils';
|
6
6
|
|
7
7
|
declare function updateTask(task: Task, runner: VitestRunner): void;
|
8
8
|
declare function startTests(paths: string[], runner: VitestRunner): Promise<File[]>;
|
9
9
|
|
10
|
-
declare const suite: SuiteAPI
|
11
|
-
declare const test: TestAPI
|
12
|
-
declare const describe: SuiteAPI
|
13
|
-
declare const it: TestAPI
|
10
|
+
declare const suite: SuiteAPI;
|
11
|
+
declare const test: TestAPI;
|
12
|
+
declare const describe: SuiteAPI;
|
13
|
+
declare const it: TestAPI;
|
14
14
|
declare function getCurrentSuite<ExtraContext = {}>(): SuiteCollector<ExtraContext>;
|
15
15
|
|
16
|
-
declare
|
17
|
-
declare
|
18
|
-
declare
|
19
|
-
declare
|
16
|
+
declare function beforeAll(fn: SuiteHooks['beforeAll'][0], timeout?: number): void;
|
17
|
+
declare function afterAll(fn: SuiteHooks['afterAll'][0], timeout?: number): void;
|
18
|
+
declare function beforeEach<ExtraContext = {}>(fn: SuiteHooks<ExtraContext>['beforeEach'][0], timeout?: number): void;
|
19
|
+
declare function afterEach<ExtraContext = {}>(fn: SuiteHooks<ExtraContext>['afterEach'][0], timeout?: number): void;
|
20
20
|
declare const onTestFailed: (fn: OnTestFailedHandler) => void;
|
21
21
|
|
22
22
|
declare function setFn(key: Test, fn: (() => Awaitable<void>)): void;
|
23
23
|
declare function getFn<Task = Test>(key: Task): (() => Awaitable<void>);
|
24
24
|
|
25
|
-
|
25
|
+
declare function getCurrentTest(): Test<{}> | undefined;
|
26
|
+
|
27
|
+
export { File, OnTestFailedHandler, SuiteAPI, SuiteCollector, SuiteHooks, Task, Test, TestAPI, VitestRunner, afterAll, afterEach, beforeAll, beforeEach, describe, getCurrentSuite, getCurrentTest, getFn, it, onTestFailed, setFn, startTests, suite, test, updateTask };
|
package/dist/index.js
CHANGED
@@ -2,6 +2,7 @@ import limit from 'p-limit';
|
|
2
2
|
import { getSafeTimers, format, isObject, objDisplay, objectAttr, noop, toArray, shuffle } from '@vitest/utils';
|
3
3
|
import { c as createChainable, g as generateHash, p as processError, a as calculateSuiteHash, s as someTasksAreOnly, i as interpretTaskModes, b as partitionSuiteChildren, h as hasTests, d as hasFailed } from './chunk-tasks.js';
|
4
4
|
import { relative } from 'pathe';
|
5
|
+
import '@vitest/utils/diff';
|
5
6
|
|
6
7
|
const fnMap = /* @__PURE__ */ new WeakMap();
|
7
8
|
const hooksMap = /* @__PURE__ */ new WeakMap();
|
@@ -248,6 +249,7 @@ function formatTitle(template, items, idx) {
|
|
248
249
|
formatted = formatted.replace(
|
249
250
|
/\$([$\w_.]+)/g,
|
250
251
|
(_, key) => objDisplay(objectAttr(items[0], key))
|
252
|
+
// https://github.com/chaijs/chai/pull/1490
|
251
253
|
);
|
252
254
|
}
|
253
255
|
return formatted;
|
@@ -285,7 +287,7 @@ async function collectTests(paths, runner) {
|
|
285
287
|
for (const filepath of paths) {
|
286
288
|
const path = relative(config.root, filepath);
|
287
289
|
const file = {
|
288
|
-
id: generateHash(path),
|
290
|
+
id: generateHash(`${path}${config.name || ""}`),
|
289
291
|
name: path,
|
290
292
|
type: "suite",
|
291
293
|
mode: "run",
|
@@ -405,13 +407,13 @@ async function sendTasksUpdate(runner) {
|
|
405
407
|
return p;
|
406
408
|
}
|
407
409
|
}
|
408
|
-
|
410
|
+
async function callCleanupHooks(cleanups) {
|
409
411
|
await Promise.all(cleanups.map(async (fn) => {
|
410
412
|
if (typeof fn !== "function")
|
411
413
|
return;
|
412
414
|
await fn();
|
413
415
|
}));
|
414
|
-
}
|
416
|
+
}
|
415
417
|
async function runTest(test, runner) {
|
416
418
|
var _a, _b, _c, _d, _e, _f;
|
417
419
|
await ((_a = runner.onBeforeRunTest) == null ? void 0 : _a.call(runner, test));
|
@@ -443,6 +445,12 @@ async function runTest(test, runner) {
|
|
443
445
|
throw new Error("Test function is not found. Did you add it using `setFn`?");
|
444
446
|
await fn();
|
445
447
|
}
|
448
|
+
if (test.promises) {
|
449
|
+
const result = await Promise.allSettled(test.promises);
|
450
|
+
const errors = result.map((r) => r.status === "rejected" ? r.reason : void 0).filter(Boolean);
|
451
|
+
if (errors.length)
|
452
|
+
throw errors;
|
453
|
+
}
|
446
454
|
await ((_d = runner.onAfterTryTest) == null ? void 0 : _d.call(runner, test, retryCount));
|
447
455
|
test.result.state = "pass";
|
448
456
|
} catch (e) {
|
@@ -479,10 +487,13 @@ async function runTest(test, runner) {
|
|
479
487
|
}
|
480
488
|
function failTask(result, err) {
|
481
489
|
result.state = "fail";
|
482
|
-
const
|
483
|
-
|
484
|
-
|
485
|
-
|
490
|
+
const errors = Array.isArray(err) ? err : [err];
|
491
|
+
for (const e of errors) {
|
492
|
+
const error = processError(e);
|
493
|
+
result.error ?? (result.error = error);
|
494
|
+
result.errors ?? (result.errors = []);
|
495
|
+
result.errors.push(error);
|
496
|
+
}
|
486
497
|
}
|
487
498
|
function markTasksAsSkipped(suite, runner) {
|
488
499
|
suite.tasks.forEach((t) => {
|
@@ -597,11 +608,21 @@ async function startTests(paths, runner) {
|
|
597
608
|
return files;
|
598
609
|
}
|
599
610
|
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
611
|
+
function getDefaultHookTimeout() {
|
612
|
+
return getRunner().config.hookTimeout;
|
613
|
+
}
|
614
|
+
function beforeAll(fn, timeout) {
|
615
|
+
return getCurrentSuite().on("beforeAll", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true));
|
616
|
+
}
|
617
|
+
function afterAll(fn, timeout) {
|
618
|
+
return getCurrentSuite().on("afterAll", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true));
|
619
|
+
}
|
620
|
+
function beforeEach(fn, timeout) {
|
621
|
+
return getCurrentSuite().on("beforeEach", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true));
|
622
|
+
}
|
623
|
+
function afterEach(fn, timeout) {
|
624
|
+
return getCurrentSuite().on("afterEach", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true));
|
625
|
+
}
|
605
626
|
const onTestFailed = createTestHook("onTestFailed", (test, handler) => {
|
606
627
|
test.onFailed || (test.onFailed = []);
|
607
628
|
test.onFailed.push(handler);
|
@@ -615,4 +636,4 @@ function createTestHook(name, handler) {
|
|
615
636
|
};
|
616
637
|
}
|
617
638
|
|
618
|
-
export { afterAll, afterEach, beforeAll, beforeEach, describe, getCurrentSuite, getFn, it, onTestFailed, setFn, startTests, suite, test, updateTask };
|
639
|
+
export { afterAll, afterEach, beforeAll, beforeEach, describe, getCurrentSuite, getCurrentTest, getFn, it, onTestFailed, setFn, startTests, suite, test, updateTask };
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { q as SequenceHooks, r as SequenceSetupFiles, F as File,
|
1
|
+
import { q as SequenceHooks, r as SequenceSetupFiles, F as File, d as Test, j as Suite, h as TaskResult, p as TestContext } from './tasks-c965d7f6.js';
|
2
2
|
|
3
3
|
interface VitestRunnerConfig {
|
4
4
|
root: string;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Awaitable } from '@vitest/utils';
|
1
|
+
import { ErrorWithDiff, Awaitable } from '@vitest/utils';
|
2
2
|
|
3
3
|
type ChainableFunction<T extends string, Args extends any[], R = any, E = {}> = {
|
4
4
|
(...args: Args): R;
|
@@ -9,35 +9,6 @@ type ChainableFunction<T extends string, Args extends any[], R = any, E = {}> =
|
|
9
9
|
} & E;
|
10
10
|
declare function createChainable<T extends string, Args extends any[], R = any, E = {}>(keys: T[], fn: (this: Record<T, boolean | undefined>, ...args: Args) => R): ChainableFunction<T, Args, R, E>;
|
11
11
|
|
12
|
-
interface ParsedStack {
|
13
|
-
method: string;
|
14
|
-
file: string;
|
15
|
-
line: number;
|
16
|
-
column: number;
|
17
|
-
}
|
18
|
-
interface ErrorWithDiff extends Error {
|
19
|
-
name: string;
|
20
|
-
nameStr?: string;
|
21
|
-
stack?: string;
|
22
|
-
stackStr?: string;
|
23
|
-
stacks?: ParsedStack[];
|
24
|
-
showDiff?: boolean;
|
25
|
-
actual?: any;
|
26
|
-
expected?: any;
|
27
|
-
operator?: string;
|
28
|
-
type?: string;
|
29
|
-
frame?: string;
|
30
|
-
}
|
31
|
-
declare function serializeError(val: any, seen?: WeakMap<object, any>): any;
|
32
|
-
interface ProcessErrorOptions {
|
33
|
-
outputDiffMaxSize?: number;
|
34
|
-
}
|
35
|
-
declare function processError(err: any, options?: ProcessErrorOptions): any;
|
36
|
-
declare function replaceAsymmetricMatcher(actual: any, expected: any, actualReplaced?: WeakSet<object>, expectedReplaced?: WeakSet<object>): {
|
37
|
-
replacedActual: any;
|
38
|
-
replacedExpected: any;
|
39
|
-
};
|
40
|
-
|
41
12
|
type RunMode = 'run' | 'skip' | 'only' | 'todo';
|
42
13
|
type TaskState = RunMode | 'pass' | 'fail';
|
43
14
|
interface TaskBase {
|
@@ -88,6 +59,10 @@ interface Test<ExtraContext = {}> extends TaskBase {
|
|
88
59
|
fails?: boolean;
|
89
60
|
context: TestContext & ExtraContext;
|
90
61
|
onFailed?: OnTestFailedHandler[];
|
62
|
+
/**
|
63
|
+
* Store promises (from async expects) to wait for them before finishing the test
|
64
|
+
*/
|
65
|
+
promises?: Promise<any>[];
|
91
66
|
}
|
92
67
|
type Task = Test | Suite | TaskCustom | File;
|
93
68
|
type DoneCallback = (error?: any) => void;
|
@@ -193,4 +168,4 @@ type OnTestFailedHandler = (result: TaskResult) => Awaitable<void>;
|
|
193
168
|
type SequenceHooks = 'stack' | 'list' | 'parallel';
|
194
169
|
type SequenceSetupFiles = 'list' | 'parallel';
|
195
170
|
|
196
|
-
export { ChainableFunction as C, DoneCallback as D,
|
171
|
+
export { ChainableFunction as C, DoneCallback as D, File as F, HookListener as H, OnTestFailedHandler as O, RunMode as R, SuiteAPI as S, Task as T, TestAPI as a, SuiteCollector as b, SuiteHooks as c, Test as d, TaskState as e, TaskBase as f, TaskCustom as g, TaskResult as h, TaskResultPack as i, Suite as j, TestFunction as k, TestOptions as l, HookCleanupCallback as m, SuiteFactory as n, RuntimeContext as o, TestContext as p, SequenceHooks as q, SequenceSetupFiles as r, createChainable as s };
|
package/dist/types.d.ts
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
export { D as DoneCallback, F as File,
|
2
|
-
export { V as VitestRunner, a as VitestRunnerConfig, c as VitestRunnerConstructor, b as VitestRunnerImportSource } from './runner-
|
1
|
+
export { D as DoneCallback, F as File, m as HookCleanupCallback, H as HookListener, O as OnTestFailedHandler, R as RunMode, o as RuntimeContext, q as SequenceHooks, r as SequenceSetupFiles, j as Suite, S as SuiteAPI, b as SuiteCollector, n as SuiteFactory, c as SuiteHooks, T as Task, f as TaskBase, g as TaskCustom, h as TaskResult, i as TaskResultPack, e as TaskState, d as Test, a as TestAPI, p as TestContext, k as TestFunction, l as TestOptions } from './tasks-c965d7f6.js';
|
2
|
+
export { V as VitestRunner, a as VitestRunnerConfig, c as VitestRunnerConstructor, b as VitestRunnerImportSource } from './runner-751eaed8.js';
|
3
3
|
import '@vitest/utils';
|
package/dist/utils.d.ts
CHANGED
@@ -1,6 +1,15 @@
|
|
1
|
-
import {
|
2
|
-
export { C as ChainableFunction,
|
1
|
+
import { j as Suite, T as Task, d as Test, g as TaskCustom } from './tasks-c965d7f6.js';
|
2
|
+
export { C as ChainableFunction, s as createChainable } from './tasks-c965d7f6.js';
|
3
3
|
import { Arrayable } from '@vitest/utils';
|
4
|
+
export { ErrorWithDiff, ParsedStack } from '@vitest/utils';
|
5
|
+
import { DiffOptions } from '@vitest/utils/diff';
|
6
|
+
|
7
|
+
declare function serializeError(val: any, seen?: WeakMap<object, any>): any;
|
8
|
+
declare function processError(err: any, options?: DiffOptions): any;
|
9
|
+
declare function replaceAsymmetricMatcher(actual: any, expected: any, actualReplaced?: WeakSet<object>, expectedReplaced?: WeakSet<object>): {
|
10
|
+
replacedActual: any;
|
11
|
+
replacedExpected: any;
|
12
|
+
};
|
4
13
|
|
5
14
|
/**
|
6
15
|
* If any tasks been marked as `only`, mark all other tasks as `skip`.
|
@@ -22,4 +31,4 @@ declare function hasTests(suite: Arrayable<Suite>): boolean;
|
|
22
31
|
declare function hasFailed(suite: Arrayable<Task>): boolean;
|
23
32
|
declare function getNames(task: Task): string[];
|
24
33
|
|
25
|
-
export { calculateSuiteHash, generateHash, getNames, getSuites, getTasks, getTests, hasFailed, hasTests, interpretTaskModes, partitionSuiteChildren, someTasksAreOnly };
|
34
|
+
export { calculateSuiteHash, generateHash, getNames, getSuites, getTasks, getTests, hasFailed, hasTests, interpretTaskModes, partitionSuiteChildren, processError, replaceAsymmetricMatcher, serializeError, someTasksAreOnly };
|
package/dist/utils.js
CHANGED
@@ -1,2 +1,3 @@
|
|
1
1
|
export { a as calculateSuiteHash, c as createChainable, g as generateHash, k as getNames, j as getSuites, f as getTasks, e as getTests, d as hasFailed, h as hasTests, i as interpretTaskModes, b as partitionSuiteChildren, p as processError, r as replaceAsymmetricMatcher, l as serializeError, s as someTasksAreOnly } from './chunk-tasks.js';
|
2
2
|
import '@vitest/utils';
|
3
|
+
import '@vitest/utils/diff';
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vitest/runner",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.
|
4
|
+
"version": "0.30.0",
|
5
5
|
"description": "Vitest test runner",
|
6
6
|
"license": "MIT",
|
7
7
|
"repository": {
|
@@ -33,9 +33,10 @@
|
|
33
33
|
"*.d.ts"
|
34
34
|
],
|
35
35
|
"dependencies": {
|
36
|
+
"concordance": "^5.0.4",
|
36
37
|
"p-limit": "^4.0.0",
|
37
38
|
"pathe": "^1.1.0",
|
38
|
-
"@vitest/utils": "0.
|
39
|
+
"@vitest/utils": "0.30.0"
|
39
40
|
},
|
40
41
|
"scripts": {
|
41
42
|
"build": "rimraf dist && rollup -c",
|