@vitest/runner 2.1.5 → 2.2.0-beta.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/index.d.ts +2 -2
- package/dist/index.js +21 -11
- package/dist/{tasks-3ZnPj1LR.d.ts → tasks-F_411-nA.d.ts} +7 -1
- package/dist/types.d.ts +6 -2
- package/dist/utils.d.ts +2 -2
- package/package.json +2 -2
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-F_411-nA.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-F_411-nA.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
@@ -6,9 +6,10 @@ export { processError } from '@vitest/utils/error';
|
|
6
6
|
import 'pathe';
|
7
7
|
|
8
8
|
class PendingError extends Error {
|
9
|
-
constructor(message, task) {
|
9
|
+
constructor(message, task, note) {
|
10
10
|
super(message);
|
11
11
|
this.message = message;
|
12
|
+
this.note = note;
|
12
13
|
this.taskId = task.id;
|
13
14
|
}
|
14
15
|
code = "VITEST_PENDING";
|
@@ -54,9 +55,9 @@ function createTestContext(test, runner) {
|
|
54
55
|
throw new Error("done() callback is deprecated, use promise instead");
|
55
56
|
};
|
56
57
|
context.task = test;
|
57
|
-
context.skip = () => {
|
58
|
+
context.skip = (note) => {
|
58
59
|
test.pending = true;
|
59
|
-
throw new PendingError("test is skipped; abort execution", test);
|
60
|
+
throw new PendingError("test is skipped; abort execution", test, note);
|
60
61
|
};
|
61
62
|
context.onTestFailed = (fn) => {
|
62
63
|
test.onFailed || (test.onFailed = []);
|
@@ -95,14 +96,15 @@ function getHooks(key) {
|
|
95
96
|
return hooksMap.get(key);
|
96
97
|
}
|
97
98
|
|
98
|
-
function mergeContextFixtures(fixtures, context
|
99
|
-
const fixtureOptionKeys = ["auto"];
|
99
|
+
function mergeContextFixtures(fixtures, context, inject) {
|
100
|
+
const fixtureOptionKeys = ["auto", "injected"];
|
100
101
|
const fixtureArray = Object.entries(fixtures).map(
|
101
102
|
([prop, value]) => {
|
102
103
|
const fixtureItem = { value };
|
103
104
|
if (Array.isArray(value) && value.length >= 2 && isObject(value[1]) && Object.keys(value[1]).some((key) => fixtureOptionKeys.includes(key))) {
|
104
105
|
Object.assign(fixtureItem, value[1]);
|
105
|
-
|
106
|
+
const userValue = value[0];
|
107
|
+
fixtureItem.value = fixtureItem.injected ? inject(prop) ?? userValue : userValue;
|
106
108
|
}
|
107
109
|
fixtureItem.prop = prop;
|
108
110
|
fixtureItem.isFn = typeof fixtureItem.value === "function";
|
@@ -666,7 +668,14 @@ function createTaskCollector(fn, context) {
|
|
666
668
|
return condition ? this : this.skip;
|
667
669
|
};
|
668
670
|
taskFn.extend = function(fixtures) {
|
669
|
-
const _context = mergeContextFixtures(
|
671
|
+
const _context = mergeContextFixtures(
|
672
|
+
fixtures,
|
673
|
+
context || {},
|
674
|
+
(key) => {
|
675
|
+
var _a, _b;
|
676
|
+
return (_b = (_a = getRunner()).injectValue) == null ? void 0 : _b.call(_a, key);
|
677
|
+
}
|
678
|
+
);
|
670
679
|
return createTest(function fn2(name, optionsOrFn, optionsOrTest) {
|
671
680
|
getCurrentSuite().test.fn.call(
|
672
681
|
this,
|
@@ -1008,7 +1017,7 @@ async function callCleanupHooks(cleanups) {
|
|
1008
1017
|
);
|
1009
1018
|
}
|
1010
1019
|
async function runTest(test, runner) {
|
1011
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
1020
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
1012
1021
|
await ((_a = runner.onBeforeRunTask) == null ? void 0 : _a.call(runner, test));
|
1013
1022
|
if (test.mode !== "run") {
|
1014
1023
|
return;
|
@@ -1071,13 +1080,13 @@ async function runTest(test, runner) {
|
|
1071
1080
|
}
|
1072
1081
|
if (test.pending || ((_e = test.result) == null ? void 0 : _e.state) === "skip") {
|
1073
1082
|
test.mode = "skip";
|
1074
|
-
test.result = { state: "skip" };
|
1083
|
+
test.result = { state: "skip", note: (_f = test.result) == null ? void 0 : _f.note };
|
1075
1084
|
updateTask(test, runner);
|
1076
1085
|
setCurrentTest(void 0);
|
1077
1086
|
return;
|
1078
1087
|
}
|
1079
1088
|
try {
|
1080
|
-
await ((
|
1089
|
+
await ((_g = runner.onTaskFinished) == null ? void 0 : _g.call(runner, test));
|
1081
1090
|
} catch (e) {
|
1082
1091
|
failTask(test.result, e, runner.config.diffOptions);
|
1083
1092
|
}
|
@@ -1124,12 +1133,13 @@ async function runTest(test, runner) {
|
|
1124
1133
|
}
|
1125
1134
|
setCurrentTest(void 0);
|
1126
1135
|
test.result.duration = now() - start;
|
1127
|
-
await ((
|
1136
|
+
await ((_h = runner.onAfterRunTask) == null ? void 0 : _h.call(runner, test));
|
1128
1137
|
updateTask(test, runner);
|
1129
1138
|
}
|
1130
1139
|
function failTask(result, err, diffOptions) {
|
1131
1140
|
if (err instanceof PendingError) {
|
1132
1141
|
result.state = "skip";
|
1142
|
+
result.note = err.note;
|
1133
1143
|
return;
|
1134
1144
|
}
|
1135
1145
|
result.state = "fail";
|
@@ -3,6 +3,10 @@ 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;
|
6
10
|
/**
|
7
11
|
* Indicates whether the fixture is a function
|
8
12
|
*/
|
@@ -162,6 +166,8 @@ interface TaskResult {
|
|
162
166
|
* `repeats` option is set. This number also contains `retryCount`.
|
163
167
|
*/
|
164
168
|
repeatCount?: number;
|
169
|
+
/** @private */
|
170
|
+
note?: string;
|
165
171
|
}
|
166
172
|
/**
|
167
173
|
* The tuple representing a single task update.
|
@@ -457,7 +463,7 @@ interface TaskContext<Task extends Custom | Test = Custom | Test> {
|
|
457
463
|
* Mark tests as skipped. All execution after this call will be skipped.
|
458
464
|
* This function throws an error, so make sure you are not catching it accidentally.
|
459
465
|
*/
|
460
|
-
skip: () => void;
|
466
|
+
skip: (note?: string) => void;
|
461
467
|
}
|
462
468
|
type ExtendedContext<T extends Custom | Test> = TaskContext<T> & TestContext;
|
463
469
|
type OnTestFailedHandler = (result: TaskResult) => Awaitable<void>;
|
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-F_411-nA.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-F_411-nA.js';
|
4
4
|
import '@vitest/utils';
|
5
5
|
|
6
6
|
/**
|
@@ -123,6 +123,10 @@ interface VitestRunner {
|
|
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
|
*/
|
125
125
|
importFile: (filepath: string, source: VitestRunnerImportSource) => unknown;
|
126
|
+
/**
|
127
|
+
* Function that is called when the runner attempts to get the value when `test.extend` is used with `{ injected: true }`
|
128
|
+
*/
|
129
|
+
injectValue?: (key: string) => unknown;
|
126
130
|
/**
|
127
131
|
* Publicly available configuration.
|
128
132
|
*/
|
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-F_411-nA.js';
|
2
|
+
export { b as ChainableFunction, c as createChainable } from './tasks-F_411-nA.js';
|
3
3
|
import { Arrayable } from '@vitest/utils';
|
4
4
|
|
5
5
|
/**
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vitest/runner",
|
3
3
|
"type": "module",
|
4
|
-
"version": "2.1
|
4
|
+
"version": "2.2.0-beta.1",
|
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.1
|
42
|
+
"@vitest/utils": "2.2.0-beta.1"
|
43
43
|
},
|
44
44
|
"scripts": {
|
45
45
|
"build": "rimraf dist && rollup -c",
|