@vitest/runner 2.0.0-beta.2 → 2.0.0-beta.4
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 +18 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +19 -25
- package/dist/{tasks-Ck0GpLiZ.d.ts → tasks-Cjrz1dUg.d.ts} +2 -2
- package/dist/types.d.ts +6 -2
- package/dist/utils.d.ts +4 -3
- package/dist/utils.js +2 -1
- package/package.json +2 -2
package/dist/chunk-tasks.js
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import { processError } from '@vitest/utils/error';
|
2
|
+
import { relative } from 'pathe';
|
2
3
|
import { toArray } from '@vitest/utils';
|
3
4
|
|
4
5
|
function partitionSuiteChildren(suite) {
|
@@ -91,6 +92,22 @@ function calculateSuiteHash(parent) {
|
|
91
92
|
calculateSuiteHash(t);
|
92
93
|
});
|
93
94
|
}
|
95
|
+
function createFileTask(filepath, root, projectName) {
|
96
|
+
const path = relative(root, filepath);
|
97
|
+
const file = {
|
98
|
+
id: generateHash(`${path}${projectName || ""}`),
|
99
|
+
name: path,
|
100
|
+
type: "suite",
|
101
|
+
mode: "run",
|
102
|
+
filepath,
|
103
|
+
tasks: [],
|
104
|
+
meta: /* @__PURE__ */ Object.create(null),
|
105
|
+
projectName,
|
106
|
+
file: void 0
|
107
|
+
};
|
108
|
+
file.file = file;
|
109
|
+
return file;
|
110
|
+
}
|
94
111
|
|
95
112
|
function createChainable(keys, fn) {
|
96
113
|
function create(context) {
|
@@ -170,4 +187,4 @@ function getNames(task) {
|
|
170
187
|
return names;
|
171
188
|
}
|
172
189
|
|
173
|
-
export {
|
190
|
+
export { createFileTask as a, getTests as b, calculateSuiteHash as c, getTasks as d, getSuites as e, hasFailed as f, generateHash as g, hasTests as h, interpretTaskModes as i, getNames as j, createChainable as k, partitionSuiteChildren as p, someTasksAreOnly as s };
|
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, h as SuiteHooks, O as OnTestFailedHandler, i as OnTestFinishedHandler, a as Test, C as Custom, S as Suite } from './tasks-
|
4
|
-
export { D as DoneCallback, E as ExtendedContext, t as Fixture, s as FixtureFn, r as FixtureOptions, u as Fixtures, v as HookCleanupCallback, H as HookListener, I as InferFixturesTypes, R as RunMode, y as RuntimeContext, B as SequenceHooks, G as SequenceSetupFiles, x as SuiteFactory, k as TaskBase, A as TaskContext, w as TaskCustomOptions, m as TaskMeta, l as TaskPopulated, n as TaskResult, o as TaskResultPack, j as TaskState, z as TestContext, p as TestFunction, q 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, h as SuiteHooks, O as OnTestFailedHandler, i as OnTestFinishedHandler, a as Test, C as Custom, S as Suite } from './tasks-Cjrz1dUg.js';
|
4
|
+
export { D as DoneCallback, E as ExtendedContext, t as Fixture, s as FixtureFn, r as FixtureOptions, u as Fixtures, v as HookCleanupCallback, H as HookListener, I as InferFixturesTypes, R as RunMode, y as RuntimeContext, B as SequenceHooks, G as SequenceSetupFiles, x as SuiteFactory, k as TaskBase, A as TaskContext, w as TaskCustomOptions, m as TaskMeta, l as TaskPopulated, n as TaskResult, o as TaskResultPack, j as TaskState, z as TestContext, p as TestFunction, q as TestOptions, U as Use } from './tasks-Cjrz1dUg.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
@@ -2,9 +2,9 @@ import limit from 'p-limit';
|
|
2
2
|
import { getSafeTimers, isObject, createDefer, format, objDisplay, objectAttr, toArray, shuffle } from '@vitest/utils';
|
3
3
|
import { processError } from '@vitest/utils/error';
|
4
4
|
export { processError } from '@vitest/utils/error';
|
5
|
-
import {
|
6
|
-
import { relative } from 'pathe';
|
5
|
+
import { k as createChainable, a as createFileTask, c as calculateSuiteHash, s as someTasksAreOnly, i as interpretTaskModes, p as partitionSuiteChildren, h as hasTests, f as hasFailed } from './chunk-tasks.js';
|
7
6
|
import { parseSingleStack } from '@vitest/utils/source-map';
|
7
|
+
import 'pathe';
|
8
8
|
|
9
9
|
const fnMap = /* @__PURE__ */ new WeakMap();
|
10
10
|
const fixtureMap = /* @__PURE__ */ new WeakMap();
|
@@ -212,7 +212,7 @@ function getUsedProps(fn) {
|
|
212
212
|
throw new Error(`The first argument inside a fixture must use object destructuring pattern, e.g. ({ test } => {}). Instead, received "${first}".`);
|
213
213
|
const _first = first.slice(1, -1).replace(/\s/g, "");
|
214
214
|
const props = splitByComma(_first).map((prop) => {
|
215
|
-
return prop.replace(
|
215
|
+
return prop.replace(/:.*|=.*/g, "");
|
216
216
|
});
|
217
217
|
const last = props.at(-1);
|
218
218
|
if (last && last.startsWith("..."))
|
@@ -414,7 +414,8 @@ function createSuiteCollector(name, factory = () => {
|
|
414
414
|
file: void 0,
|
415
415
|
shuffle,
|
416
416
|
tasks: [],
|
417
|
-
meta: /* @__PURE__ */ Object.create(null)
|
417
|
+
meta: /* @__PURE__ */ Object.create(null),
|
418
|
+
concurrent: suiteOptions == null ? void 0 : suiteOptions.concurrent
|
418
419
|
};
|
419
420
|
if (runner && includeLocation && runner.config.includeTaskLocation) {
|
420
421
|
const limit = Error.stackTraceLimit;
|
@@ -462,8 +463,10 @@ function createSuite() {
|
|
462
463
|
);
|
463
464
|
if (currentSuite == null ? void 0 : currentSuite.options)
|
464
465
|
options = { ...currentSuite.options, ...options };
|
465
|
-
options.concurrent
|
466
|
-
options.sequential
|
466
|
+
const isConcurrent = options.concurrent || this.concurrent && !this.sequential;
|
467
|
+
const isSequential = options.sequential || this.sequential && !this.concurrent;
|
468
|
+
options.concurrent = isConcurrent && !isSequential;
|
469
|
+
options.sequential = isSequential && !isConcurrent;
|
467
470
|
return createSuiteCollector(formatName(name), factory, mode, this.shuffle, this.each, options);
|
468
471
|
}
|
469
472
|
suiteFn.each = function(cases, ...args) {
|
@@ -557,7 +560,7 @@ function formatTitle(template, items, idx) {
|
|
557
560
|
let formatted = format(template, ...items.slice(0, count));
|
558
561
|
if (isObject(items[0])) {
|
559
562
|
formatted = formatted.replace(
|
560
|
-
/\$([$\
|
563
|
+
/\$([$\w.]+)/g,
|
561
564
|
// https://github.com/chaijs/chai/pull/1490
|
562
565
|
(_, key) => {
|
563
566
|
var _a, _b;
|
@@ -613,22 +616,12 @@ async function runSetupFiles(config, runner) {
|
|
613
616
|
|
614
617
|
const now$1 = Date.now;
|
615
618
|
async function collectTests(paths, runner) {
|
619
|
+
var _a;
|
616
620
|
const files = [];
|
617
621
|
const config = runner.config;
|
618
622
|
for (const filepath of paths) {
|
619
|
-
const
|
620
|
-
|
621
|
-
id: generateHash(`${path}${config.name || ""}`),
|
622
|
-
name: path,
|
623
|
-
type: "suite",
|
624
|
-
mode: "run",
|
625
|
-
filepath,
|
626
|
-
tasks: [],
|
627
|
-
meta: /* @__PURE__ */ Object.create(null),
|
628
|
-
projectName: config.name,
|
629
|
-
file: void 0
|
630
|
-
};
|
631
|
-
file.file = file;
|
623
|
+
const file = createFileTask(filepath, config.root, config.name);
|
624
|
+
(_a = runner.onCollectStart) == null ? void 0 : _a.call(runner, file);
|
632
625
|
clearCollectorContext(filepath, runner);
|
633
626
|
try {
|
634
627
|
const setupStart = now$1();
|
@@ -665,8 +658,8 @@ async function collectTests(paths, runner) {
|
|
665
658
|
const hasOnlyTasks = someTasksAreOnly(file);
|
666
659
|
interpretTaskModes(file, config.testNamePattern, hasOnlyTasks, false, config.allowOnly);
|
667
660
|
file.tasks.forEach((task) => {
|
668
|
-
var
|
669
|
-
if (((
|
661
|
+
var _a2;
|
662
|
+
if (((_a2 = task.suite) == null ? void 0 : _a2.id) === "")
|
670
663
|
delete task.suite;
|
671
664
|
});
|
672
665
|
files.push(file);
|
@@ -921,8 +914,7 @@ async function runSuite(suite, runner) {
|
|
921
914
|
} else {
|
922
915
|
for (let tasksGroup of partitionSuiteChildren(suite)) {
|
923
916
|
if (tasksGroup[0].concurrent === true) {
|
924
|
-
|
925
|
-
await Promise.all(tasksGroup.map((c) => mutex(() => runSuiteChild(c, runner))));
|
917
|
+
await Promise.all(tasksGroup.map((c) => runSuiteChild(c, runner)));
|
926
918
|
} else {
|
927
919
|
const { sequence } = runner.config;
|
928
920
|
if (sequence.shuffle || suite.shuffle) {
|
@@ -963,14 +955,16 @@ async function runSuite(suite, runner) {
|
|
963
955
|
await ((_d = runner.onAfterRunSuite) == null ? void 0 : _d.call(runner, suite));
|
964
956
|
}
|
965
957
|
}
|
958
|
+
let limitMaxConcurrency;
|
966
959
|
async function runSuiteChild(c, runner) {
|
967
960
|
if (c.type === "test" || c.type === "custom")
|
968
|
-
return runTest(c, runner);
|
961
|
+
return limitMaxConcurrency(() => runTest(c, runner));
|
969
962
|
else if (c.type === "suite")
|
970
963
|
return runSuite(c, runner);
|
971
964
|
}
|
972
965
|
async function runFiles(files, runner) {
|
973
966
|
var _a, _b;
|
967
|
+
limitMaxConcurrency ?? (limitMaxConcurrency = limit(runner.config.maxConcurrency));
|
974
968
|
for (const file of files) {
|
975
969
|
if (!file.tasks.length && !runner.config.passWithNoTests) {
|
976
970
|
if (!((_b = (_a = file.result) == null ? void 0 : _a.errors) == null ? void 0 : _b.length)) {
|
@@ -72,7 +72,7 @@ interface Suite extends TaskBase {
|
|
72
72
|
}
|
73
73
|
interface File extends Suite {
|
74
74
|
filepath: string;
|
75
|
-
projectName: string;
|
75
|
+
projectName: string | undefined;
|
76
76
|
collectDuration?: number;
|
77
77
|
setupDuration?: number;
|
78
78
|
}
|
@@ -145,7 +145,7 @@ interface TestOptions {
|
|
145
145
|
*/
|
146
146
|
repeats?: number;
|
147
147
|
/**
|
148
|
-
* Whether tests run concurrently.
|
148
|
+
* Whether suites and tests run concurrently.
|
149
149
|
* Tests inherit `concurrent` from `describe()` and nested `describe()` will inherit from parent's `concurrent`.
|
150
150
|
*/
|
151
151
|
concurrent?: boolean;
|
package/dist/types.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { B as SequenceHooks, G as SequenceSetupFiles, F as File, T as Task, S as Suite, o as TaskResultPack, a as Test, C as Custom, A as TaskContext, E as ExtendedContext } from './tasks-
|
2
|
-
export { g as CustomAPI, D as DoneCallback, t as Fixture, s as FixtureFn, r as FixtureOptions, u as Fixtures, v as HookCleanupCallback, H as HookListener, I as InferFixturesTypes, O as OnTestFailedHandler, i as OnTestFinishedHandler, R as RunMode, y as RuntimeContext, d as SuiteAPI, f as SuiteCollector, x as SuiteFactory, h as SuiteHooks, k as TaskBase, w as TaskCustomOptions, m as TaskMeta, l as TaskPopulated, n as TaskResult, j as TaskState, e as TestAPI, z as TestContext, p as TestFunction, q as TestOptions, U as Use } from './tasks-
|
1
|
+
import { B as SequenceHooks, G as SequenceSetupFiles, F as File, T as Task, S as Suite, o as TaskResultPack, a as Test, C as Custom, A as TaskContext, E as ExtendedContext } from './tasks-Cjrz1dUg.js';
|
2
|
+
export { g as CustomAPI, D as DoneCallback, t as Fixture, s as FixtureFn, r as FixtureOptions, u as Fixtures, v as HookCleanupCallback, H as HookListener, I as InferFixturesTypes, O as OnTestFailedHandler, i as OnTestFinishedHandler, R as RunMode, y as RuntimeContext, d as SuiteAPI, f as SuiteCollector, x as SuiteFactory, h as SuiteHooks, k as TaskBase, w as TaskCustomOptions, m as TaskMeta, l as TaskPopulated, n as TaskResult, j as TaskState, e as TestAPI, z as TestContext, p as TestFunction, q as TestOptions, U as Use } from './tasks-Cjrz1dUg.js';
|
3
3
|
import { DiffOptions } from '@vitest/utils/diff';
|
4
4
|
import '@vitest/utils';
|
5
5
|
|
@@ -37,6 +37,10 @@ interface VitestRunner {
|
|
37
37
|
* First thing that's getting called before actually collecting and running tests.
|
38
38
|
*/
|
39
39
|
onBeforeCollect?: (paths: string[]) => unknown;
|
40
|
+
/**
|
41
|
+
* Called after the file task was created but not collected yet.
|
42
|
+
*/
|
43
|
+
onCollectStart?: (file: File) => unknown;
|
40
44
|
/**
|
41
45
|
* Called after collecting tests and before "onBeforeRun".
|
42
46
|
*/
|
package/dist/utils.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { S as Suite, 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-Cjrz1dUg.js';
|
2
|
+
export { b as ChainableFunction, c as createChainable } from './tasks-Cjrz1dUg.js';
|
3
3
|
import { Arrayable } from '@vitest/utils';
|
4
4
|
|
5
5
|
/**
|
@@ -9,6 +9,7 @@ declare function interpretTaskModes(suite: Suite, namePattern?: string | RegExp,
|
|
9
9
|
declare function someTasksAreOnly(suite: Suite): boolean;
|
10
10
|
declare function generateHash(str: string): string;
|
11
11
|
declare function calculateSuiteHash(parent: Suite): void;
|
12
|
+
declare function createFileTask(filepath: string, root: string, projectName: string): File;
|
12
13
|
|
13
14
|
/**
|
14
15
|
* Partition in tasks groups by consecutive concurrent
|
@@ -22,4 +23,4 @@ declare function hasTests(suite: Arrayable<Suite>): boolean;
|
|
22
23
|
declare function hasFailed(suite: Arrayable<Task>): boolean;
|
23
24
|
declare function getNames(task: Task): string[];
|
24
25
|
|
25
|
-
export { calculateSuiteHash, generateHash, getNames, getSuites, getTasks, getTests, hasFailed, hasTests, interpretTaskModes, partitionSuiteChildren, someTasksAreOnly };
|
26
|
+
export { calculateSuiteHash, createFileTask, generateHash, getNames, getSuites, getTasks, getTests, hasFailed, hasTests, interpretTaskModes, partitionSuiteChildren, someTasksAreOnly };
|
package/dist/utils.js
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
-
export { c as calculateSuiteHash,
|
1
|
+
export { c as calculateSuiteHash, k as createChainable, a as createFileTask, g as generateHash, j as getNames, e as getSuites, d as getTasks, b as getTests, f as hasFailed, h as hasTests, i as interpretTaskModes, p as partitionSuiteChildren, s as someTasksAreOnly } from './chunk-tasks.js';
|
2
2
|
import '@vitest/utils/error';
|
3
|
+
import 'pathe';
|
3
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": "2.0.0-beta.
|
4
|
+
"version": "2.0.0-beta.4",
|
5
5
|
"description": "Vitest test runner",
|
6
6
|
"license": "MIT",
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
@@ -40,7 +40,7 @@
|
|
40
40
|
"dependencies": {
|
41
41
|
"p-limit": "^5.0.0",
|
42
42
|
"pathe": "^1.1.2",
|
43
|
-
"@vitest/utils": "2.0.0-beta.
|
43
|
+
"@vitest/utils": "2.0.0-beta.4"
|
44
44
|
},
|
45
45
|
"scripts": {
|
46
46
|
"build": "rimraf dist && rollup -c",
|