@vitest/runner 3.0.7 → 3.0.8
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 +27 -15
- package/dist/{tasks-CAp19cBR.d.ts → tasks-CPSpEF1h.d.ts} +1 -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,5 +1,5 @@
|
|
1
|
-
import { A as AfterAllListener, b as AfterEachListener, B as BeforeAllListener, d as BeforeEachListener, e as TaskHook, O as OnTestFailedHandler, f as OnTestFinishedHandler, a as Test, g as Custom, S as Suite, h as SuiteHooks, F as File, i as TaskUpdateEvent, T as Task, j as TestAPI, k as SuiteAPI, l as SuiteCollector } from './tasks-
|
2
|
-
export { D as DoneCallback, E as ExtendedContext, m as Fixture, n as FixtureFn, o as FixtureOptions, p as Fixtures, H as HookCleanupCallback, q as HookListener, I as InferFixturesTypes, R as RunMode, r as RuntimeContext, s as SequenceHooks, t as SequenceSetupFiles, u as SuiteFactory, v as TaskBase, w as TaskContext, x as TaskCustomOptions, y as TaskEventPack, z as TaskMeta, G as TaskPopulated, J as TaskResult, K as TaskResultPack, L as TaskState, M as TestContext, N as TestFunction, P as TestOptions, U as Use } from './tasks-
|
1
|
+
import { A as AfterAllListener, b as AfterEachListener, B as BeforeAllListener, d as BeforeEachListener, e as TaskHook, O as OnTestFailedHandler, f as OnTestFinishedHandler, a as Test, g as Custom, S as Suite, h as SuiteHooks, F as File, i as TaskUpdateEvent, T as Task, j as TestAPI, k as SuiteAPI, l as SuiteCollector } from './tasks-CPSpEF1h.js';
|
2
|
+
export { D as DoneCallback, E as ExtendedContext, m as Fixture, n as FixtureFn, o as FixtureOptions, p as Fixtures, H as HookCleanupCallback, q as HookListener, I as InferFixturesTypes, R as RunMode, r as RuntimeContext, s as SequenceHooks, t as SequenceSetupFiles, u as SuiteFactory, v as TaskBase, w as TaskContext, x as TaskCustomOptions, y as TaskEventPack, z as TaskMeta, G as TaskPopulated, J as TaskResult, K as TaskResultPack, L as TaskState, M as TestContext, N as TestFunction, P as TestOptions, U as Use } from './tasks-CPSpEF1h.js';
|
3
3
|
import { Awaitable } from '@vitest/utils';
|
4
4
|
import { FileSpecification, VitestRunner } from './types.js';
|
5
5
|
export { CancelReason, VitestRunnerConfig, VitestRunnerConstructor, VitestRunnerImportSource } from './types.js';
|
package/dist/index.js
CHANGED
@@ -357,8 +357,10 @@ function getRunner() {
|
|
357
357
|
}
|
358
358
|
function createDefaultSuite(runner2) {
|
359
359
|
const config = runner2.config.sequence;
|
360
|
-
|
360
|
+
const collector = suite("", { concurrent: config.concurrent }, () => {
|
361
361
|
});
|
362
|
+
delete collector.suite;
|
363
|
+
return collector;
|
362
364
|
}
|
363
365
|
function clearCollectorContext(filepath, currentRunner) {
|
364
366
|
if (!defaultSuite) {
|
@@ -423,10 +425,11 @@ function createSuiteCollector(name, factory = () => {
|
|
423
425
|
let suite2;
|
424
426
|
initSuite(true);
|
425
427
|
const task = function(name2 = "", options = {}) {
|
428
|
+
var _a;
|
426
429
|
const task2 = {
|
427
430
|
id: "",
|
428
431
|
name: name2,
|
429
|
-
suite: void 0,
|
432
|
+
suite: (_a = collectorContext.currentSuite) == null ? void 0 : _a.suite,
|
430
433
|
each: options.each,
|
431
434
|
fails: options.fails,
|
432
435
|
context: void 0,
|
@@ -488,6 +491,7 @@ function createSuiteCollector(name, factory = () => {
|
|
488
491
|
type: "collector",
|
489
492
|
name,
|
490
493
|
mode,
|
494
|
+
suite: suite2,
|
491
495
|
options: suiteOptions,
|
492
496
|
test: test2,
|
493
497
|
tasks,
|
@@ -500,6 +504,7 @@ function createSuiteCollector(name, factory = () => {
|
|
500
504
|
getHooks(suite2)[name2].push(...fn);
|
501
505
|
}
|
502
506
|
function initSuite(includeLocation) {
|
507
|
+
var _a;
|
503
508
|
if (typeof suiteOptions === "number") {
|
504
509
|
suiteOptions = { timeout: suiteOptions };
|
505
510
|
}
|
@@ -507,6 +512,7 @@ function createSuiteCollector(name, factory = () => {
|
|
507
512
|
id: "",
|
508
513
|
type: "suite",
|
509
514
|
name,
|
515
|
+
suite: (_a = collectorContext.currentSuite) == null ? void 0 : _a.suite,
|
510
516
|
mode,
|
511
517
|
each,
|
512
518
|
file: void 0,
|
@@ -545,7 +551,6 @@ function createSuiteCollector(name, factory = () => {
|
|
545
551
|
suite2.file = file;
|
546
552
|
suite2.tasks = allChildren;
|
547
553
|
allChildren.forEach((task2) => {
|
548
|
-
task2.suite = suite2;
|
549
554
|
task2.file = file;
|
550
555
|
});
|
551
556
|
return suite2;
|
@@ -804,11 +809,18 @@ function findTestFileStackTrace(error, each) {
|
|
804
809
|
function getDefaultHookTimeout() {
|
805
810
|
return getRunner().config.hookTimeout;
|
806
811
|
}
|
807
|
-
|
812
|
+
const CLEANUP_TIMEOUT_KEY = Symbol.for("VITEST_CLEANUP_TIMEOUT");
|
813
|
+
function getBeforeHookCleanupCallback(hook, result) {
|
814
|
+
if (typeof result === "function") {
|
815
|
+
const timeout = CLEANUP_TIMEOUT_KEY in hook && typeof hook[CLEANUP_TIMEOUT_KEY] === "number" ? hook[CLEANUP_TIMEOUT_KEY] : getDefaultHookTimeout();
|
816
|
+
return withTimeout(result, timeout, true);
|
817
|
+
}
|
818
|
+
}
|
819
|
+
function beforeAll(fn, timeout = getDefaultHookTimeout()) {
|
808
820
|
assertTypes(fn, '"beforeAll" callback', ["function"]);
|
809
821
|
return getCurrentSuite().on(
|
810
822
|
"beforeAll",
|
811
|
-
withTimeout(fn, timeout
|
823
|
+
Object.assign(withTimeout(fn, timeout, true), { [CLEANUP_TIMEOUT_KEY]: timeout })
|
812
824
|
);
|
813
825
|
}
|
814
826
|
function afterAll(fn, timeout) {
|
@@ -818,11 +830,14 @@ function afterAll(fn, timeout) {
|
|
818
830
|
withTimeout(fn, timeout ?? getDefaultHookTimeout(), true)
|
819
831
|
);
|
820
832
|
}
|
821
|
-
function beforeEach(fn, timeout) {
|
833
|
+
function beforeEach(fn, timeout = getDefaultHookTimeout()) {
|
822
834
|
assertTypes(fn, '"beforeEach" callback', ["function"]);
|
823
835
|
return getCurrentSuite().on(
|
824
836
|
"beforeEach",
|
825
|
-
|
837
|
+
Object.assign(
|
838
|
+
withTimeout(withFixtures(fn), timeout ?? getDefaultHookTimeout(), true),
|
839
|
+
{ [CLEANUP_TIMEOUT_KEY]: timeout }
|
840
|
+
)
|
826
841
|
);
|
827
842
|
}
|
828
843
|
function afterEach(fn, timeout) {
|
@@ -925,12 +940,6 @@ async function collectTests(specs, runner) {
|
|
925
940
|
};
|
926
941
|
}
|
927
942
|
calculateSuiteHash(file);
|
928
|
-
file.tasks.forEach((task) => {
|
929
|
-
var _a2;
|
930
|
-
if (((_a2 = task.suite) == null ? void 0 : _a2.id) === "") {
|
931
|
-
delete task.suite;
|
932
|
-
}
|
933
|
-
});
|
934
943
|
const hasOnlyTasks = someTasksAreOnly(file);
|
935
944
|
interpretTaskModes(
|
936
945
|
file,
|
@@ -1031,13 +1040,16 @@ async function callSuiteHook(suite, currentTask, name, runner, args) {
|
|
1031
1040
|
if (hooks.length > 0) {
|
1032
1041
|
updateSuiteHookState(currentTask, name, "run", runner);
|
1033
1042
|
}
|
1043
|
+
async function runHook(hook) {
|
1044
|
+
return getBeforeHookCleanupCallback(hook, await hook(...args));
|
1045
|
+
}
|
1034
1046
|
if (sequence === "parallel") {
|
1035
1047
|
callbacks.push(
|
1036
|
-
...await Promise.all(hooks.map((hook) => hook
|
1048
|
+
...await Promise.all(hooks.map((hook) => runHook(hook)))
|
1037
1049
|
);
|
1038
1050
|
} else {
|
1039
1051
|
for (const hook of hooks) {
|
1040
|
-
callbacks.push(await hook
|
1052
|
+
callbacks.push(await runHook(hook));
|
1041
1053
|
}
|
1042
1054
|
}
|
1043
1055
|
if (hooks.length > 0) {
|
@@ -433,6 +433,7 @@ interface SuiteCollector<ExtraContext = object> {
|
|
433
433
|
type: 'collector';
|
434
434
|
test: TestAPI<ExtraContext>;
|
435
435
|
tasks: (Suite | Test<ExtraContext> | SuiteCollector<ExtraContext>)[];
|
436
|
+
suite?: Suite;
|
436
437
|
task: (name: string, options?: TaskCustomOptions) => Test<ExtraContext>;
|
437
438
|
collect: (file: File) => Promise<Suite>;
|
438
439
|
clear: () => void;
|
package/dist/types.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { DiffOptions } from '@vitest/utils/diff';
|
2
|
-
import { F as File, T as Task, a as Test, S as Suite, K as TaskResultPack, y as TaskEventPack, M as TestContext, s as SequenceHooks, t as SequenceSetupFiles } from './tasks-
|
3
|
-
export { A as AfterAllListener, b as AfterEachListener, B as BeforeAllListener, d as BeforeEachListener, g as Custom, j as CustomAPI, D as DoneCallback, E as ExtendedContext, m as Fixture, n as FixtureFn, o as FixtureOptions, p as Fixtures, H as HookCleanupCallback, q as HookListener, I as InferFixturesTypes, O as OnTestFailedHandler, f as OnTestFinishedHandler, R as RunMode, r as RuntimeContext, k as SuiteAPI, l as SuiteCollector, u as SuiteFactory, h as SuiteHooks, v as TaskBase, w as TaskContext, x as TaskCustomOptions, e as TaskHook, z as TaskMeta, G as TaskPopulated, J as TaskResult, L as TaskState, i as TaskUpdateEvent, j as TestAPI, N as TestFunction, P as TestOptions, U as Use } from './tasks-
|
2
|
+
import { F as File, T as Task, a as Test, S as Suite, K as TaskResultPack, y as TaskEventPack, M as TestContext, s as SequenceHooks, t as SequenceSetupFiles } from './tasks-CPSpEF1h.js';
|
3
|
+
export { A as AfterAllListener, b as AfterEachListener, B as BeforeAllListener, d as BeforeEachListener, g as Custom, j as CustomAPI, D as DoneCallback, E as ExtendedContext, m as Fixture, n as FixtureFn, o as FixtureOptions, p as Fixtures, H as HookCleanupCallback, q as HookListener, I as InferFixturesTypes, O as OnTestFailedHandler, f as OnTestFinishedHandler, R as RunMode, r as RuntimeContext, k as SuiteAPI, l as SuiteCollector, u as SuiteFactory, h as SuiteHooks, v as TaskBase, w as TaskContext, x as TaskCustomOptions, e as TaskHook, z as TaskMeta, G as TaskPopulated, J as TaskResult, L as TaskState, i as TaskUpdateEvent, j as TestAPI, N as TestFunction, P as TestOptions, U as Use } from './tasks-CPSpEF1h.js';
|
4
4
|
import '@vitest/utils';
|
5
5
|
|
6
6
|
/**
|
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-CPSpEF1h.js';
|
2
|
+
export { C as ChainableFunction, c as createChainable } from './tasks-CPSpEF1h.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": "3.0.
|
4
|
+
"version": "3.0.8",
|
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": "^2.0.3",
|
42
|
-
"@vitest/utils": "3.0.
|
42
|
+
"@vitest/utils": "3.0.8"
|
43
43
|
},
|
44
44
|
"scripts": {
|
45
45
|
"build": "rimraf dist && rollup -c",
|