@vitest/runner 2.1.1 → 2.1.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/index.d.ts +2 -2
- package/dist/index.js +45 -27
- package/dist/{tasks--RurNSkd.d.ts → tasks-SNKRxoD7.d.ts} +6 -0
- package/dist/types.d.ts +2 -2
- package/dist/utils.d.ts +2 -2
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { VitestRunner } from './types.js';
|
2
2
|
export { CancelReason, VitestRunnerConfig, VitestRunnerConstructor, VitestRunnerImportSource } from './types.js';
|
3
|
-
import { T as Task, F as File, d as SuiteAPI, e as TestAPI, f as SuiteCollector, g as CustomAPI, B as BeforeAllListener, A as AfterAllListener, h as BeforeEachListener, i as AfterEachListener, j as TaskHook, O as OnTestFailedHandler, k as OnTestFinishedHandler, a as Test, C as Custom, S as Suite, l as SuiteHooks } from './tasks
|
4
|
-
export { D as DoneCallback, L as ExtendedContext, w as Fixture, v as FixtureFn, u as FixtureOptions, x as Fixtures, y as HookCleanupCallback, H as HookListener, I as InferFixturesTypes, R as RunMode, G as RuntimeContext, M as SequenceHooks, N as SequenceSetupFiles, E as SuiteFactory, n as TaskBase, K as TaskContext, z as TaskCustomOptions, p as TaskMeta, o as TaskPopulated, q as TaskResult, r as TaskResultPack, m as TaskState, J as TestContext, s as TestFunction, t as TestOptions, U as Use } from './tasks
|
3
|
+
import { T as Task, F as File, d as SuiteAPI, e as TestAPI, f as SuiteCollector, g as CustomAPI, B as BeforeAllListener, A as AfterAllListener, h as BeforeEachListener, i as AfterEachListener, j as TaskHook, O as OnTestFailedHandler, k as OnTestFinishedHandler, a as Test, C as Custom, S as Suite, l as SuiteHooks } from './tasks-SNKRxoD7.js';
|
4
|
+
export { D as DoneCallback, L as ExtendedContext, w as Fixture, v as FixtureFn, u as FixtureOptions, x as Fixtures, y as HookCleanupCallback, H as HookListener, I as InferFixturesTypes, R as RunMode, G as RuntimeContext, M as SequenceHooks, N as SequenceSetupFiles, E as SuiteFactory, n as TaskBase, K as TaskContext, z as TaskCustomOptions, p as TaskMeta, o as TaskPopulated, q as TaskResult, r as TaskResultPack, m as TaskState, J as TestContext, s as TestFunction, t as TestOptions, U as Use } from './tasks-SNKRxoD7.js';
|
5
5
|
import { Awaitable } from '@vitest/utils';
|
6
6
|
export { processError } from '@vitest/utils/error';
|
7
7
|
import '@vitest/utils/diff';
|
package/dist/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { getSafeTimers, isObject, createDefer, isNegativeNaN, format, objDisplay, objectAttr, toArray, shuffle } from '@vitest/utils';
|
1
|
+
import { getSafeTimers, isObject, createDefer, isNegativeNaN, format, objDisplay, objectAttr, toArray, shuffle, assertTypes } from '@vitest/utils';
|
2
2
|
import { processError } from '@vitest/utils/error';
|
3
3
|
export { processError } from '@vitest/utils/error';
|
4
4
|
import { l as createChainable, a as createFileTask, c as calculateSuiteHash, s as someTasksAreOnly, i as interpretTaskModes, m as limitConcurrency, p as partitionSuiteChildren, h as hasTests, j as hasFailed } from './chunk-tasks.js';
|
@@ -224,7 +224,11 @@ function resolveDeps(fixtures, depSet = /* @__PURE__ */ new Set(), pendingFixtur
|
|
224
224
|
return pendingFixtures;
|
225
225
|
}
|
226
226
|
function getUsedProps(fn) {
|
227
|
-
|
227
|
+
let fnString = fn.toString();
|
228
|
+
if (/__async\(this, (?:null|arguments|\[[_0-9, ]*\]), function\*/.test(fnString)) {
|
229
|
+
fnString = fnString.split("__async(this,")[1];
|
230
|
+
}
|
231
|
+
const match = fnString.match(/[^(]*\(([^)]*)/);
|
228
232
|
if (!match) {
|
229
233
|
return [];
|
230
234
|
}
|
@@ -544,11 +548,13 @@ function createSuite() {
|
|
544
548
|
factoryOrOptions,
|
545
549
|
optionsOrFactory
|
546
550
|
);
|
551
|
+
const isConcurrentSpecified = options.concurrent || this.concurrent || options.sequential === false;
|
552
|
+
const isSequentialSpecified = options.sequential || this.sequential || options.concurrent === false;
|
547
553
|
if (currentSuite == null ? void 0 : currentSuite.options) {
|
548
554
|
options = { ...currentSuite.options, ...options };
|
549
555
|
}
|
550
|
-
const isConcurrent =
|
551
|
-
const isSequential =
|
556
|
+
const isConcurrent = isConcurrentSpecified || options.concurrent && !isSequentialSpecified;
|
557
|
+
const isSequential = isSequentialSpecified || options.sequential && !isConcurrentSpecified;
|
552
558
|
options.concurrent = isConcurrent && !isSequential;
|
553
559
|
options.sequential = isSequential && !isConcurrent;
|
554
560
|
return createSuiteCollector(
|
@@ -1017,6 +1023,24 @@ async function runTest(test, runner) {
|
|
1017
1023
|
} catch (e) {
|
1018
1024
|
failTask(test.result, e, runner.config.diffOptions);
|
1019
1025
|
}
|
1026
|
+
try {
|
1027
|
+
await callTaskHooks(test, test.onFinished || [], "stack");
|
1028
|
+
} catch (e) {
|
1029
|
+
failTask(test.result, e, runner.config.diffOptions);
|
1030
|
+
}
|
1031
|
+
if (test.result.state === "fail") {
|
1032
|
+
try {
|
1033
|
+
await callTaskHooks(
|
1034
|
+
test,
|
1035
|
+
test.onFailed || [],
|
1036
|
+
runner.config.sequence.hooks
|
1037
|
+
);
|
1038
|
+
} catch (e) {
|
1039
|
+
failTask(test.result, e, runner.config.diffOptions);
|
1040
|
+
}
|
1041
|
+
}
|
1042
|
+
delete test.onFailed;
|
1043
|
+
delete test.onFinished;
|
1020
1044
|
if (test.result.state === "pass") {
|
1021
1045
|
break;
|
1022
1046
|
}
|
@@ -1027,22 +1051,6 @@ async function runTest(test, runner) {
|
|
1027
1051
|
updateTask(test, runner);
|
1028
1052
|
}
|
1029
1053
|
}
|
1030
|
-
try {
|
1031
|
-
await callTaskHooks(test, test.onFinished || [], "stack");
|
1032
|
-
} catch (e) {
|
1033
|
-
failTask(test.result, e, runner.config.diffOptions);
|
1034
|
-
}
|
1035
|
-
if (test.result.state === "fail") {
|
1036
|
-
try {
|
1037
|
-
await callTaskHooks(
|
1038
|
-
test,
|
1039
|
-
test.onFailed || [],
|
1040
|
-
runner.config.sequence.hooks
|
1041
|
-
);
|
1042
|
-
} catch (e) {
|
1043
|
-
failTask(test.result, e, runner.config.diffOptions);
|
1044
|
-
}
|
1045
|
-
}
|
1046
1054
|
if (test.fails) {
|
1047
1055
|
if (test.result.state === "pass") {
|
1048
1056
|
const error = processError(new Error("Expect test to fail"));
|
@@ -1102,13 +1110,18 @@ async function runSuite(suite, runner) {
|
|
1102
1110
|
suite.result.state = "todo";
|
1103
1111
|
} else {
|
1104
1112
|
try {
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1113
|
+
try {
|
1114
|
+
beforeAllCleanups = await callSuiteHook(
|
1115
|
+
suite,
|
1116
|
+
suite,
|
1117
|
+
"beforeAll",
|
1118
|
+
runner,
|
1119
|
+
[suite]
|
1120
|
+
);
|
1121
|
+
} catch (e) {
|
1122
|
+
markTasksAsSkipped(suite, runner);
|
1123
|
+
throw e;
|
1124
|
+
}
|
1112
1125
|
if (runner.runSuite) {
|
1113
1126
|
await runner.runSuite(suite);
|
1114
1127
|
} else {
|
@@ -1211,24 +1224,28 @@ function getDefaultHookTimeout() {
|
|
1211
1224
|
return getRunner().config.hookTimeout;
|
1212
1225
|
}
|
1213
1226
|
function beforeAll(fn, timeout) {
|
1227
|
+
assertTypes(fn, '"beforeAll" callback', ["function"]);
|
1214
1228
|
return getCurrentSuite().on(
|
1215
1229
|
"beforeAll",
|
1216
1230
|
withTimeout(fn, timeout ?? getDefaultHookTimeout(), true)
|
1217
1231
|
);
|
1218
1232
|
}
|
1219
1233
|
function afterAll(fn, timeout) {
|
1234
|
+
assertTypes(fn, '"afterAll" callback', ["function"]);
|
1220
1235
|
return getCurrentSuite().on(
|
1221
1236
|
"afterAll",
|
1222
1237
|
withTimeout(fn, timeout ?? getDefaultHookTimeout(), true)
|
1223
1238
|
);
|
1224
1239
|
}
|
1225
1240
|
function beforeEach(fn, timeout) {
|
1241
|
+
assertTypes(fn, '"beforeEach" callback', ["function"]);
|
1226
1242
|
return getCurrentSuite().on(
|
1227
1243
|
"beforeEach",
|
1228
1244
|
withTimeout(withFixtures(fn), timeout ?? getDefaultHookTimeout(), true)
|
1229
1245
|
);
|
1230
1246
|
}
|
1231
1247
|
function afterEach(fn, timeout) {
|
1248
|
+
assertTypes(fn, '"afterEach" callback', ["function"]);
|
1232
1249
|
return getCurrentSuite().on(
|
1233
1250
|
"afterEach",
|
1234
1251
|
withTimeout(withFixtures(fn), timeout ?? getDefaultHookTimeout(), true)
|
@@ -1254,6 +1271,7 @@ const onTestFinished = createTestHook(
|
|
1254
1271
|
);
|
1255
1272
|
function createTestHook(name, handler) {
|
1256
1273
|
return (fn, timeout) => {
|
1274
|
+
assertTypes(fn, `"${name}" callback`, ["function"]);
|
1257
1275
|
const current = getCurrentTest();
|
1258
1276
|
if (!current) {
|
1259
1277
|
throw new Error(`Hook ${name}() can only be called inside a test`);
|
@@ -432,8 +432,14 @@ interface RuntimeContext {
|
|
432
432
|
tasks: (SuiteCollector | Test)[];
|
433
433
|
currentSuite: SuiteCollector | null;
|
434
434
|
}
|
435
|
+
/**
|
436
|
+
* User's custom test context.
|
437
|
+
*/
|
435
438
|
interface TestContext {
|
436
439
|
}
|
440
|
+
/**
|
441
|
+
* Context that's always available in the test function.
|
442
|
+
*/
|
437
443
|
interface TaskContext<Task extends Custom | Test = Custom | Test> {
|
438
444
|
/**
|
439
445
|
* Metadata of the current test
|
package/dist/types.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { M as SequenceHooks, N as SequenceSetupFiles, F as File, T as Task, a as Test, C as Custom, S as Suite, r as TaskResultPack, K as TaskContext, L as ExtendedContext } from './tasks
|
2
|
-
export { A as AfterAllListener, i as AfterEachListener, B as BeforeAllListener, h as BeforeEachListener, g as CustomAPI, D as DoneCallback, w as Fixture, v as FixtureFn, u as FixtureOptions, x as Fixtures, y as HookCleanupCallback, H as HookListener, I as InferFixturesTypes, O as OnTestFailedHandler, k as OnTestFinishedHandler, R as RunMode, G as RuntimeContext, d as SuiteAPI, f as SuiteCollector, E as SuiteFactory, l as SuiteHooks, n as TaskBase, z as TaskCustomOptions, j as TaskHook, p as TaskMeta, o as TaskPopulated, q as TaskResult, m as TaskState, e as TestAPI, J as TestContext, s as TestFunction, t as TestOptions, U as Use } from './tasks
|
1
|
+
import { M as SequenceHooks, N as SequenceSetupFiles, F as File, T as Task, a as Test, C as Custom, S as Suite, r as TaskResultPack, K as TaskContext, L as ExtendedContext } from './tasks-SNKRxoD7.js';
|
2
|
+
export { A as AfterAllListener, i as AfterEachListener, B as BeforeAllListener, h as BeforeEachListener, g as CustomAPI, D as DoneCallback, w as Fixture, v as FixtureFn, u as FixtureOptions, x as Fixtures, y as HookCleanupCallback, H as HookListener, I as InferFixturesTypes, O as OnTestFailedHandler, k as OnTestFinishedHandler, R as RunMode, G as RuntimeContext, d as SuiteAPI, f as SuiteCollector, E as SuiteFactory, l as SuiteHooks, n as TaskBase, z as TaskCustomOptions, j as TaskHook, p as TaskMeta, o as TaskPopulated, q as TaskResult, m as TaskState, e as TestAPI, J as TestContext, s as TestFunction, t as TestOptions, U as Use } from './tasks-SNKRxoD7.js';
|
3
3
|
import { DiffOptions } from '@vitest/utils/diff';
|
4
4
|
import '@vitest/utils';
|
5
5
|
|
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-SNKRxoD7.js';
|
2
|
+
export { b as ChainableFunction, c as createChainable } from './tasks-SNKRxoD7.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.1.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": "2.1.
|
42
|
+
"@vitest/utils": "2.1.3"
|
43
43
|
},
|
44
44
|
"scripts": {
|
45
45
|
"build": "rimraf dist && rollup -c",
|