@vitest/runner 4.1.5 → 5.0.0-beta.2
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-artifact.js +63 -39
- package/dist/index.d.ts +8 -3
- package/dist/index.js +1 -1
- package/dist/{tasks.d-Bh0IjN67.d.ts → tasks.d-B4a0-8OW.d.ts} +23 -10
- package/dist/types.d.ts +1 -1
- package/dist/utils.d.ts +8 -4
- package/dist/utils.js +1 -1
- package/package.json +2 -2
package/dist/chunk-artifact.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { processError } from '@vitest/utils/error';
|
|
2
2
|
import { isObject, filterOutComments, ordinal, createDefer, assertTypes, toArray, isNegativeNaN, unique, objectAttr, shuffle } from '@vitest/utils/helpers';
|
|
3
3
|
import { getSafeTimers } from '@vitest/utils/timers';
|
|
4
|
-
import { format, formatRegExp,
|
|
4
|
+
import { format, formatRegExp, truncateString, inspect } from '@vitest/utils/display';
|
|
5
5
|
import { parseSingleStack } from '@vitest/utils/source-map';
|
|
6
6
|
import { relative } from 'pathe';
|
|
7
7
|
|
|
@@ -41,6 +41,20 @@ class AroundHookTeardownError extends Error {
|
|
|
41
41
|
class AroundHookMultipleCallsError extends Error {
|
|
42
42
|
name = "AroundHookMultipleCallsError";
|
|
43
43
|
}
|
|
44
|
+
// `test.fails` doesn't flip the test result when this error is thrown
|
|
45
|
+
class TestSyntaxError extends Error {
|
|
46
|
+
name = "TestSyntaxError";
|
|
47
|
+
constructor(message) {
|
|
48
|
+
super(message);
|
|
49
|
+
// use custom property so this survives when the error
|
|
50
|
+
// is serialized on `packages/expect` side (e.g. for `expect.soft`)
|
|
51
|
+
// and `packages/runner` can still detect it during `test.fails` handling
|
|
52
|
+
Object.defineProperty(this, "__vitest_test_syntax_error__", {
|
|
53
|
+
value: true,
|
|
54
|
+
enumerable: false
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
44
58
|
|
|
45
59
|
// use WeakMap here to make the Test and Suite object serializable
|
|
46
60
|
const fnMap = new WeakMap();
|
|
@@ -1060,17 +1074,17 @@ function calculateSuiteHash(parent) {
|
|
|
1060
1074
|
}
|
|
1061
1075
|
});
|
|
1062
1076
|
}
|
|
1063
|
-
function createFileTask(filepath, root, projectName, pool, viteEnvironment) {
|
|
1077
|
+
function createFileTask(filepath, root, projectName, pool, viteEnvironment, meta) {
|
|
1064
1078
|
const path = relative(root, filepath);
|
|
1065
1079
|
const file = {
|
|
1066
|
-
id: generateFileHash(path, projectName),
|
|
1080
|
+
id: generateFileHash(path, projectName, meta),
|
|
1067
1081
|
name: path,
|
|
1068
1082
|
fullName: path,
|
|
1069
1083
|
type: "suite",
|
|
1070
1084
|
mode: "queued",
|
|
1071
1085
|
filepath,
|
|
1072
1086
|
tasks: [],
|
|
1073
|
-
meta: Object.create(null),
|
|
1087
|
+
meta: Object.assign(Object.create(null), meta),
|
|
1074
1088
|
projectName,
|
|
1075
1089
|
file: undefined,
|
|
1076
1090
|
pool,
|
|
@@ -1085,8 +1099,14 @@ function createFileTask(filepath, root, projectName, pool, viteEnvironment) {
|
|
|
1085
1099
|
* @param projectName The name of the test project
|
|
1086
1100
|
*/
|
|
1087
1101
|
/* @__NO_SIDE_EFFECTS__ */
|
|
1088
|
-
function generateFileHash(file, projectName) {
|
|
1089
|
-
|
|
1102
|
+
function generateFileHash(file, projectName, meta) {
|
|
1103
|
+
const seed = [
|
|
1104
|
+
file,
|
|
1105
|
+
projectName || "",
|
|
1106
|
+
meta?.typecheck ? "__typecheck__" : "",
|
|
1107
|
+
meta?.__vitest_label__ || ""
|
|
1108
|
+
].join("\0");
|
|
1109
|
+
return generateHash(seed);
|
|
1090
1110
|
}
|
|
1091
1111
|
function findTestFileStackTrace(testFilePath, error) {
|
|
1092
1112
|
// first line is the error message
|
|
@@ -1727,11 +1747,25 @@ function createSuiteCollector(name, factory = () => {}, mode, each, suiteOptions
|
|
|
1727
1747
|
return acc;
|
|
1728
1748
|
}, {});
|
|
1729
1749
|
const testOwnMeta = options.meta;
|
|
1750
|
+
const parentOptions = collectorContext.currentSuite?.options;
|
|
1730
1751
|
options = {
|
|
1752
|
+
...parentOptions,
|
|
1731
1753
|
...tagsOptions,
|
|
1732
1754
|
...options
|
|
1733
1755
|
};
|
|
1734
1756
|
const timeout = options.timeout ?? runner.config.testTimeout;
|
|
1757
|
+
// TODO: should this be `parentTask.meta`?
|
|
1758
|
+
// currently we don't inherit
|
|
1759
|
+
// file.meta -> task.meta
|
|
1760
|
+
// file.meta -> suite.meta (see initSuite)
|
|
1761
|
+
// but we do inherit
|
|
1762
|
+
// suite.meta -> task.meta
|
|
1763
|
+
// suite.meta -> suite.meta
|
|
1764
|
+
// and also
|
|
1765
|
+
// file.tags -> task.tags
|
|
1766
|
+
// file.tags -> suite.tags
|
|
1767
|
+
// suite.tags -> suite.tags
|
|
1768
|
+
// suite.tags -> task.tags
|
|
1735
1769
|
const parentMeta = currentSuite?.meta;
|
|
1736
1770
|
const tagMeta = tagsOptions.meta;
|
|
1737
1771
|
const testMeta = Object.create(null);
|
|
@@ -1768,7 +1802,7 @@ function createSuiteCollector(name, factory = () => {}, mode, each, suiteOptions
|
|
|
1768
1802
|
if (task.mode === "run" && !handler) {
|
|
1769
1803
|
task.mode = "todo";
|
|
1770
1804
|
}
|
|
1771
|
-
if (options.concurrent
|
|
1805
|
+
if (options.concurrent ?? runner.config.sequence.concurrent) {
|
|
1772
1806
|
task.concurrent = true;
|
|
1773
1807
|
}
|
|
1774
1808
|
task.shuffle = suiteOptions?.shuffle;
|
|
@@ -1800,20 +1834,11 @@ function createSuiteCollector(name, factory = () => {}, mode, each, suiteOptions
|
|
|
1800
1834
|
return task;
|
|
1801
1835
|
};
|
|
1802
1836
|
const test = createTest(function(name, optionsOrFn, timeoutOrTest) {
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
if (
|
|
1806
|
-
options = Object.assign({}, suiteOptions, options);
|
|
1807
|
-
}
|
|
1808
|
-
// inherit concurrent / sequential from suite
|
|
1809
|
-
const concurrent = this.concurrent ?? (!this.sequential && options?.concurrent);
|
|
1810
|
-
if (options.concurrent != null && concurrent != null) {
|
|
1837
|
+
const { options, handler } = parseArguments(optionsOrFn, timeoutOrTest);
|
|
1838
|
+
const concurrent = this.concurrent ?? options?.concurrent;
|
|
1839
|
+
if (concurrent != null) {
|
|
1811
1840
|
options.concurrent = concurrent;
|
|
1812
1841
|
}
|
|
1813
|
-
const sequential = this.sequential ?? (!this.concurrent && options?.sequential);
|
|
1814
|
-
if (options.sequential != null && sequential != null) {
|
|
1815
|
-
options.sequential = sequential;
|
|
1816
|
-
}
|
|
1817
1842
|
const test = task(formatName(name), {
|
|
1818
1843
|
...this,
|
|
1819
1844
|
...options,
|
|
@@ -1919,8 +1944,6 @@ function createSuite() {
|
|
|
1919
1944
|
}
|
|
1920
1945
|
const currentSuite = collectorContext.currentSuite || defaultSuite;
|
|
1921
1946
|
let { options, handler: factory } = parseArguments(factoryOrOptions, optionsOrFactory);
|
|
1922
|
-
const isConcurrentSpecified = options.concurrent || this.concurrent || options.sequential === false;
|
|
1923
|
-
const isSequentialSpecified = options.sequential || this.sequential || options.concurrent === false;
|
|
1924
1947
|
const { meta: parentMeta, ...parentOptions } = currentSuite?.options || {};
|
|
1925
1948
|
// inherit options from current suite
|
|
1926
1949
|
options = {
|
|
@@ -1936,14 +1959,9 @@ function createSuite() {
|
|
|
1936
1959
|
if (mode === "run" && !factory) {
|
|
1937
1960
|
mode = "todo";
|
|
1938
1961
|
}
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
if (isConcurrent != null) {
|
|
1943
|
-
options.concurrent = isConcurrent && !isSequential;
|
|
1944
|
-
}
|
|
1945
|
-
if (isSequential != null) {
|
|
1946
|
-
options.sequential = isSequential && !isConcurrent;
|
|
1962
|
+
const concurrent = this.concurrent ?? options.concurrent;
|
|
1963
|
+
if (concurrent != null) {
|
|
1964
|
+
options.concurrent = concurrent;
|
|
1947
1965
|
}
|
|
1948
1966
|
if (parentMeta) {
|
|
1949
1967
|
options.meta = Object.assign(Object.create(null), parentMeta, options.meta);
|
|
@@ -1982,6 +2000,8 @@ function createSuite() {
|
|
|
1982
2000
|
};
|
|
1983
2001
|
};
|
|
1984
2002
|
suiteFn.for = function(cases, ...args) {
|
|
2003
|
+
const context = getChainableContext(this);
|
|
2004
|
+
const suite = context.withContext();
|
|
1985
2005
|
if (Array.isArray(cases) && args.length) {
|
|
1986
2006
|
cases = formatTemplateString(cases, args);
|
|
1987
2007
|
}
|
|
@@ -1997,7 +2017,6 @@ function createSuite() {
|
|
|
1997
2017
|
suiteFn.runIf = (condition) => condition ? suite : suite.skip;
|
|
1998
2018
|
return createChainable([
|
|
1999
2019
|
"concurrent",
|
|
2000
|
-
"sequential",
|
|
2001
2020
|
"shuffle",
|
|
2002
2021
|
"skip",
|
|
2003
2022
|
"only",
|
|
@@ -2152,7 +2171,6 @@ function createTaskCollector(fn) {
|
|
|
2152
2171
|
taskFn.aroundAll = aroundAll;
|
|
2153
2172
|
const _test = createChainable([
|
|
2154
2173
|
"concurrent",
|
|
2155
|
-
"sequential",
|
|
2156
2174
|
"skip",
|
|
2157
2175
|
"only",
|
|
2158
2176
|
"todo",
|
|
@@ -2185,6 +2203,7 @@ function formatTitle(template, items, idx) {
|
|
|
2185
2203
|
}
|
|
2186
2204
|
});
|
|
2187
2205
|
}
|
|
2206
|
+
const inspectOptions = { truncate: runner.config.taskTitleValueFormatTruncate };
|
|
2188
2207
|
const isObjectItem = isObject(items[0]);
|
|
2189
2208
|
function formatAttribute(s) {
|
|
2190
2209
|
return s.replace(/\$([$\w.]+)/g, (_, key) => {
|
|
@@ -2194,7 +2213,11 @@ function formatTitle(template, items, idx) {
|
|
|
2194
2213
|
}
|
|
2195
2214
|
const arrayElement = isArrayKey ? objectAttr(items, key) : undefined;
|
|
2196
2215
|
const value = isObjectItem ? objectAttr(items[0], key, arrayElement) : arrayElement;
|
|
2197
|
-
|
|
2216
|
+
// print string without quotes
|
|
2217
|
+
if (typeof value === "string") {
|
|
2218
|
+
return truncateString(value, inspectOptions.truncate);
|
|
2219
|
+
}
|
|
2220
|
+
return inspect(value, inspectOptions);
|
|
2198
2221
|
});
|
|
2199
2222
|
}
|
|
2200
2223
|
let output = "";
|
|
@@ -2205,7 +2228,7 @@ function formatTitle(template, items, idx) {
|
|
|
2205
2228
|
// format "%"
|
|
2206
2229
|
(match) => {
|
|
2207
2230
|
if (i < count) {
|
|
2208
|
-
output += format(match[0], items[i++]);
|
|
2231
|
+
output += format([match[0], items[i++]], inspectOptions);
|
|
2209
2232
|
} else {
|
|
2210
2233
|
output += match[0];
|
|
2211
2234
|
}
|
|
@@ -2263,7 +2286,7 @@ function withTimeout(fn, timeout, isHook = false, stackTraceError, onTimeout) {
|
|
|
2263
2286
|
return fn;
|
|
2264
2287
|
}
|
|
2265
2288
|
const { setTimeout, clearTimeout } = getSafeTimers();
|
|
2266
|
-
// this function name is used to filter error in test/
|
|
2289
|
+
// this function name is used to filter error in test/e2e/test/fails.test.ts
|
|
2267
2290
|
return (function runWithTimeout(...args) {
|
|
2268
2291
|
const startTime = now$2();
|
|
2269
2292
|
const runner = getRunner();
|
|
@@ -2437,7 +2460,7 @@ async function collectTests(specs, runner) {
|
|
|
2437
2460
|
const testIds = typeof spec === "string" ? undefined : spec.testIds;
|
|
2438
2461
|
const testTagsFilter = typeof spec === "object" && spec.testTagsFilter ? createTagsFilter(spec.testTagsFilter, config.tags) : undefined;
|
|
2439
2462
|
const fileTags = typeof spec === "string" ? [] : spec.fileTags || [];
|
|
2440
|
-
const file = createFileTask(filepath, config.root, config.name, runner.pool, runner.viteEnvironment);
|
|
2463
|
+
const file = createFileTask(filepath, config.root, config.name, runner.pool, runner.viteEnvironment, { __vitest_label__: config.mergeReportsLabel });
|
|
2441
2464
|
file.tags = fileTags;
|
|
2442
2465
|
file.shuffle = config.sequence.shuffle;
|
|
2443
2466
|
try {
|
|
@@ -3035,13 +3058,13 @@ async function runTest(test, runner) {
|
|
|
3035
3058
|
updateTask("test-retried", test, runner);
|
|
3036
3059
|
}
|
|
3037
3060
|
}
|
|
3038
|
-
// if test is marked to be failed, flip the result
|
|
3061
|
+
// if test is marked to be failed, flip the result unless `TestSyntaxError` is present
|
|
3039
3062
|
if (test.fails) {
|
|
3040
3063
|
if (test.result.state === "pass") {
|
|
3041
3064
|
const error = processError(new Error("Expect test to fail"));
|
|
3042
3065
|
test.result.state = "fail";
|
|
3043
3066
|
test.result.errors = [error];
|
|
3044
|
-
} else {
|
|
3067
|
+
} else if (!test.result.errors?.some((e) => e.__vitest_test_syntax_error__)) {
|
|
3045
3068
|
test.result.state = "pass";
|
|
3046
3069
|
test.result.errors = undefined;
|
|
3047
3070
|
}
|
|
@@ -3144,7 +3167,8 @@ async function runSuite(suite, runner) {
|
|
|
3144
3167
|
} else {
|
|
3145
3168
|
for (let tasksGroup of partitionSuiteChildren(suite)) {
|
|
3146
3169
|
if (tasksGroup[0].concurrent === true) {
|
|
3147
|
-
|
|
3170
|
+
const groupLimiter = limitConcurrency(runner.config.maxConcurrency);
|
|
3171
|
+
await Promise.all(tasksGroup.map((c) => groupLimiter(() => runSuiteChild(c, runner))));
|
|
3148
3172
|
} else {
|
|
3149
3173
|
const { sequence } = runner.config;
|
|
3150
3174
|
if (suite.shuffle) {
|
|
@@ -3454,4 +3478,4 @@ function manageArtifactAttachment(attachment) {
|
|
|
3454
3478
|
}
|
|
3455
3479
|
}
|
|
3456
3480
|
|
|
3457
|
-
export { createTagsFilter as A, createTaskName as B, findTestFileStackTrace as C, generateFileHash as D, generateHash as E, getFullName as F, getNames as G, getSuites as H, getTasks as I, getTestName as J, getTests as K, hasFailed as L, hasTests as M, interpretTaskModes as N, isTestCase as O, limitConcurrency as P, matchesTags as Q, partitionSuiteChildren as R, someTasksAreOnly as S,
|
|
3481
|
+
export { createTagsFilter as A, createTaskName as B, findTestFileStackTrace as C, generateFileHash as D, generateHash as E, getFullName as F, getNames as G, getSuites as H, getTasks as I, getTestName as J, getTests as K, hasFailed as L, hasTests as M, interpretTaskModes as N, isTestCase as O, limitConcurrency as P, matchesTags as Q, partitionSuiteChildren as R, someTasksAreOnly as S, TestSyntaxError as T, validateTags as U, afterAll as a, afterEach as b, aroundAll as c, aroundEach as d, beforeAll as e, beforeEach as f, createTaskCollector as g, describe as h, getCurrentSuite as i, getCurrentTest as j, getFn as k, getHooks as l, it as m, onTestFinished as n, onTestFailed as o, publicCollect as p, setHooks as q, recordArtifact as r, setFn as s, startTests as t, suite as u, test as v, updateTask as w, calculateSuiteHash as x, createChainable as y, createFileTask as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { A as AfterAllListener,
|
|
1
|
+
import { d as TestArtifact, b as Test, S as Suite, e as SuiteHooks, f as FileSpecification, g as VitestRunner, F as File, h as TaskUpdateEvent, T as Task, i as TestAPI, j as SuiteAPI, k as SuiteCollector } from './tasks.d-B4a0-8OW.js';
|
|
2
|
+
export { A as AfterAllListener, l as AfterEachListener, m as AroundAllListener, n as AroundEachListener, B as BeforeAllListener, o as BeforeEachListener, p as BrowserTraceArtifact, q as CancelReason, r as FailureScreenshotArtifact, s as Fixture, t as FixtureFn, u as FixtureOptions, v as Fixtures, I as ImportDuration, w as InferFixturesTypes, O as OnTestFailedHandler, x as OnTestFinishedHandler, R as Retry, y as RunMode, z as RuntimeContext, D as SequenceHooks, E as SequenceSetupFiles, G as SerializableRetry, H as SuiteFactory, J as SuiteOptions, K as TaskBase, L as TaskCustomOptions, M as TaskEventPack, N as TaskHook, P as TaskMeta, Q as TaskPopulated, U as TaskResult, W as TaskResultPack, X as TaskState, Y as TestAnnotation, Z as TestAnnotationArtifact, _ as TestAnnotationLocation, $ as TestArtifactBase, a0 as TestArtifactLocation, a1 as TestArtifactRegistry, a2 as TestAttachment, a3 as TestContext, a4 as TestFunction, a5 as TestOptions, a as TestTagDefinition, a6 as TestTags, a7 as Use, a8 as VisualRegressionArtifact, V as VitestRunnerConfig, a9 as VitestRunnerConstructor, aa as VitestRunnerImportSource, ab as afterAll, ac as afterEach, ad as aroundAll, ae as aroundEach, af as beforeAll, ag as beforeEach, ah as onTestFailed, ai as onTestFinished } from './tasks.d-B4a0-8OW.js';
|
|
3
3
|
import { Awaitable } from '@vitest/utils';
|
|
4
4
|
import '@vitest/utils/diff';
|
|
5
5
|
|
|
@@ -40,6 +40,11 @@ import '@vitest/utils/diff';
|
|
|
40
40
|
*/
|
|
41
41
|
declare function recordArtifact<Artifact extends TestArtifact>(task: Test, artifact: Artifact): Promise<Artifact>;
|
|
42
42
|
|
|
43
|
+
declare class TestSyntaxError extends Error {
|
|
44
|
+
name: string;
|
|
45
|
+
constructor(message: string);
|
|
46
|
+
}
|
|
47
|
+
|
|
43
48
|
declare function setFn(key: Test, fn: () => Awaitable<void>): void;
|
|
44
49
|
declare function getFn<Task = Test>(key: Task): () => Awaitable<void>;
|
|
45
50
|
declare function setHooks(key: Suite, hooks: SuiteHooks): void;
|
|
@@ -176,4 +181,4 @@ declare function createTaskCollector(fn: (...args: any[]) => any): TestAPI;
|
|
|
176
181
|
|
|
177
182
|
declare function getCurrentTest<T extends Test | undefined>(): T;
|
|
178
183
|
|
|
179
|
-
export { File, FileSpecification, Suite, SuiteAPI, SuiteCollector, SuiteHooks, Task, TaskUpdateEvent, Test, TestAPI, TestArtifact, VitestRunner, publicCollect as collectTests, createTaskCollector, describe, getCurrentSuite, getCurrentTest, getFn, getHooks, it, recordArtifact, setFn, setHooks, startTests, suite, test, updateTask };
|
|
184
|
+
export { File, FileSpecification, Suite, SuiteAPI, SuiteCollector, SuiteHooks, Task, TaskUpdateEvent, Test, TestAPI, TestArtifact, TestSyntaxError, VitestRunner, publicCollect as collectTests, createTaskCollector, describe, getCurrentSuite, getCurrentTest, getFn, getHooks, it, recordArtifact, setFn, setHooks, startTests, suite, test, updateTask };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { a as afterAll, b as afterEach, c as aroundAll, d as aroundEach, e as beforeAll, f as beforeEach, p as collectTests, g as createTaskCollector, h as describe, i as getCurrentSuite, j as getCurrentTest, k as getFn, l as getHooks, m as it, o as onTestFailed, n as onTestFinished, r as recordArtifact, s as setFn, q as setHooks, t as startTests, u as suite, v as test, w as updateTask } from './chunk-artifact.js';
|
|
1
|
+
export { T as TestSyntaxError, a as afterAll, b as afterEach, c as aroundAll, d as aroundEach, e as beforeAll, f as beforeEach, p as collectTests, g as createTaskCollector, h as describe, i as getCurrentSuite, j as getCurrentTest, k as getFn, l as getHooks, m as it, o as onTestFailed, n as onTestFinished, r as recordArtifact, s as setFn, q as setHooks, t as startTests, u as suite, v as test, w as updateTask } from './chunk-artifact.js';
|
|
2
2
|
import '@vitest/utils/error';
|
|
3
3
|
import '@vitest/utils/helpers';
|
|
4
4
|
import '@vitest/utils/timers';
|
|
@@ -21,6 +21,7 @@ interface VitestRunnerConfig {
|
|
|
21
21
|
chaiConfig: {
|
|
22
22
|
truncateThreshold?: number;
|
|
23
23
|
} | undefined;
|
|
24
|
+
taskTitleValueFormatTruncate: number;
|
|
24
25
|
maxConcurrency: number;
|
|
25
26
|
testTimeout: number;
|
|
26
27
|
hookTimeout: number;
|
|
@@ -30,6 +31,7 @@ interface VitestRunnerConfig {
|
|
|
30
31
|
tags: TestTagDefinition[];
|
|
31
32
|
tagsFilter: string[] | undefined;
|
|
32
33
|
strictTags: boolean;
|
|
34
|
+
mergeReportsLabel: string | undefined;
|
|
33
35
|
}
|
|
34
36
|
/**
|
|
35
37
|
* Possible options to run a single file in a test.
|
|
@@ -401,6 +403,13 @@ type ChainableFunction<
|
|
|
401
403
|
> = F & { [x in T] : ChainableFunction<T, F, C> } & {
|
|
402
404
|
fn: (this: Record<T, any>, ...args: Parameters<F>) => ReturnType<F>;
|
|
403
405
|
} & C;
|
|
406
|
+
type TypedChainableFunction<
|
|
407
|
+
T,
|
|
408
|
+
F extends (...args: any) => any,
|
|
409
|
+
C = object
|
|
410
|
+
> = F & { [x in keyof T] : TypedChainableFunction<T, F, C> } & {
|
|
411
|
+
fn: (this: Record<keyof T, any>, ...args: Parameters<F>) => ReturnType<F>;
|
|
412
|
+
} & C;
|
|
404
413
|
declare function createChainable<
|
|
405
414
|
T extends string,
|
|
406
415
|
Args extends any[],
|
|
@@ -710,7 +719,8 @@ interface TestCollectorCallable<C = object> {
|
|
|
710
719
|
<ExtraContext extends C>(name: string | Function, fn?: TestFunction<ExtraContext>, options?: number): void;
|
|
711
720
|
<ExtraContext extends C>(name: string | Function, options?: TestCollectorOptions, fn?: TestFunction<ExtraContext>): void;
|
|
712
721
|
}
|
|
713
|
-
type
|
|
722
|
+
type ChainableTestContextMap = Pick<Required<TestOptions>, "concurrent" | "only" | "skip" | "todo" | "fails">;
|
|
723
|
+
type ChainableTestAPI<ExtraContext = object> = TypedChainableFunction<ChainableTestContextMap, TestCollectorCallable<ExtraContext>, {
|
|
714
724
|
each: TestEachFunction;
|
|
715
725
|
for: TestForFunction<ExtraContext>;
|
|
716
726
|
}>;
|
|
@@ -790,11 +800,6 @@ interface TestOptions {
|
|
|
790
800
|
*/
|
|
791
801
|
concurrent?: boolean;
|
|
792
802
|
/**
|
|
793
|
-
* Whether tests run sequentially.
|
|
794
|
-
* Tests inherit `sequential` from `describe()` and nested `describe()` will inherit from parent's `sequential`.
|
|
795
|
-
*/
|
|
796
|
-
sequential?: boolean;
|
|
797
|
-
/**
|
|
798
803
|
* Whether the test should be skipped.
|
|
799
804
|
*/
|
|
800
805
|
skip?: boolean;
|
|
@@ -1190,7 +1195,8 @@ interface SuiteCollectorCallable<ExtraContext = object> {
|
|
|
1190
1195
|
<OverrideExtraContext extends ExtraContext = ExtraContext>(name: string | Function, fn?: SuiteFactory<OverrideExtraContext>, options?: number): SuiteCollector<OverrideExtraContext>;
|
|
1191
1196
|
<OverrideExtraContext extends ExtraContext = ExtraContext>(name: string | Function, options: SuiteOptions, fn?: SuiteFactory<OverrideExtraContext>): SuiteCollector<OverrideExtraContext>;
|
|
1192
1197
|
}
|
|
1193
|
-
type
|
|
1198
|
+
type ChainableSuiteContextMap = Pick<Required<SuiteOptions>, "concurrent" | "only" | "skip" | "todo" | "shuffle">;
|
|
1199
|
+
type ChainableSuiteAPI<ExtraContext = object> = TypedChainableFunction<ChainableSuiteContextMap, SuiteCollectorCallable<ExtraContext>, {
|
|
1194
1200
|
each: TestEachFunction;
|
|
1195
1201
|
for: SuiteForFunction;
|
|
1196
1202
|
}>;
|
|
@@ -1412,6 +1418,13 @@ interface VisualRegressionArtifact extends TestArtifactBase {
|
|
|
1412
1418
|
message: string;
|
|
1413
1419
|
attachments: VisualRegressionArtifactAttachment[];
|
|
1414
1420
|
}
|
|
1421
|
+
/**
|
|
1422
|
+
* @experimental
|
|
1423
|
+
*/
|
|
1424
|
+
interface BrowserTraceArtifact extends TestArtifactBase {
|
|
1425
|
+
type: "internal:browserTrace";
|
|
1426
|
+
data: unknown;
|
|
1427
|
+
}
|
|
1415
1428
|
interface FailureScreenshotArtifactAttachment extends TestAttachment {
|
|
1416
1429
|
path: string;
|
|
1417
1430
|
/** Original file system path to the screenshot, before attachment resolution */
|
|
@@ -1507,7 +1520,7 @@ interface TestArtifactRegistry {}
|
|
|
1507
1520
|
*
|
|
1508
1521
|
* This type automatically includes all artifacts registered via {@link TestArtifactRegistry}.
|
|
1509
1522
|
*/
|
|
1510
|
-
type TestArtifact = FailureScreenshotArtifact | TestAnnotationArtifact | VisualRegressionArtifact | TestArtifactRegistry[keyof TestArtifactRegistry];
|
|
1523
|
+
type TestArtifact = BrowserTraceArtifact | FailureScreenshotArtifact | TestAnnotationArtifact | VisualRegressionArtifact | TestArtifactRegistry[keyof TestArtifactRegistry];
|
|
1511
1524
|
|
|
1512
|
-
export { afterAll as
|
|
1513
|
-
export type {
|
|
1525
|
+
export { afterAll as ab, afterEach as ac, aroundAll as ad, aroundEach as ae, beforeAll as af, beforeEach as ag, onTestFailed as ah, onTestFinished as ai, createChainable as c };
|
|
1526
|
+
export type { TestArtifactBase as $, AfterAllListener as A, BeforeAllListener as B, ChainableFunction as C, SequenceHooks as D, SequenceSetupFiles as E, File as F, SerializableRetry as G, SuiteFactory as H, ImportDuration as I, SuiteOptions as J, TaskBase as K, TaskCustomOptions as L, TaskEventPack as M, TaskHook as N, OnTestFailedHandler as O, TaskMeta as P, TaskPopulated as Q, Retry as R, Suite as S, Task as T, TaskResult as U, VitestRunnerConfig as V, TaskResultPack as W, TaskState as X, TestAnnotation as Y, TestAnnotationArtifact as Z, TestAnnotationLocation as _, TestTagDefinition as a, TestArtifactLocation as a0, TestArtifactRegistry as a1, TestAttachment as a2, TestContext as a3, TestFunction as a4, TestOptions as a5, TestTags as a6, Use as a7, VisualRegressionArtifact as a8, VitestRunnerConstructor as a9, VitestRunnerImportSource as aa, Test as b, TestArtifact as d, SuiteHooks as e, FileSpecification as f, VitestRunner as g, TaskUpdateEvent as h, TestAPI as i, SuiteAPI as j, SuiteCollector as k, AfterEachListener as l, AroundAllListener as m, AroundEachListener as n, BeforeEachListener as o, BrowserTraceArtifact as p, CancelReason as q, FailureScreenshotArtifact as r, Fixture as s, FixtureFn as t, FixtureOptions as u, Fixtures as v, InferFixturesTypes as w, OnTestFinishedHandler as x, RunMode as y, RuntimeContext as z };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { A as AfterAllListener,
|
|
1
|
+
export { A as AfterAllListener, l as AfterEachListener, m as AroundAllListener, n as AroundEachListener, B as BeforeAllListener, o as BeforeEachListener, p as BrowserTraceArtifact, q as CancelReason, r as FailureScreenshotArtifact, F as File, f as FileSpecification, s as Fixture, t as FixtureFn, u as FixtureOptions, v as Fixtures, I as ImportDuration, w as InferFixturesTypes, O as OnTestFailedHandler, x as OnTestFinishedHandler, R as Retry, y as RunMode, z as RuntimeContext, D as SequenceHooks, E as SequenceSetupFiles, G as SerializableRetry, S as Suite, j as SuiteAPI, k as SuiteCollector, H as SuiteFactory, e as SuiteHooks, J as SuiteOptions, T as Task, K as TaskBase, L as TaskCustomOptions, M as TaskEventPack, N as TaskHook, P as TaskMeta, Q as TaskPopulated, U as TaskResult, W as TaskResultPack, X as TaskState, h as TaskUpdateEvent, b as Test, i as TestAPI, Y as TestAnnotation, Z as TestAnnotationArtifact, _ as TestAnnotationLocation, d as TestArtifact, $ as TestArtifactBase, a0 as TestArtifactLocation, a1 as TestArtifactRegistry, a2 as TestAttachment, a3 as TestContext, a4 as TestFunction, a5 as TestOptions, a as TestTagDefinition, a6 as TestTags, a7 as Use, a8 as VisualRegressionArtifact, g as VitestRunner, V as VitestRunnerConfig, a9 as VitestRunnerConstructor, aa as VitestRunnerImportSource } from './tasks.d-B4a0-8OW.js';
|
|
2
2
|
import '@vitest/utils';
|
|
3
3
|
import '@vitest/utils/diff';
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as Suite,
|
|
2
|
-
export {
|
|
1
|
+
import { S as Suite, F as File, T as Task, a as TestTagDefinition, V as VitestRunnerConfig, b as Test } from './tasks.d-B4a0-8OW.js';
|
|
2
|
+
export { C as ChainableFunction, c as createChainable } from './tasks.d-B4a0-8OW.js';
|
|
3
3
|
import { ParsedStack, Arrayable } from '@vitest/utils';
|
|
4
4
|
import '@vitest/utils/diff';
|
|
5
5
|
|
|
@@ -10,13 +10,17 @@ declare function interpretTaskModes(file: Suite, namePattern?: string | RegExp,
|
|
|
10
10
|
declare function someTasksAreOnly(suite: Suite): boolean;
|
|
11
11
|
declare function generateHash(str: string): string;
|
|
12
12
|
declare function calculateSuiteHash(parent: Suite): void;
|
|
13
|
-
|
|
13
|
+
interface HashMeta {
|
|
14
|
+
typecheck?: boolean;
|
|
15
|
+
__vitest_label__?: string;
|
|
16
|
+
}
|
|
17
|
+
declare function createFileTask(filepath: string, root: string, projectName: string | undefined, pool?: string, viteEnvironment?: string, meta?: HashMeta): File;
|
|
14
18
|
/**
|
|
15
19
|
* Generate a unique ID for a file based on its path and project name
|
|
16
20
|
* @param file File relative to the root of the project to keep ID the same between different machines
|
|
17
21
|
* @param projectName The name of the test project
|
|
18
22
|
*/
|
|
19
|
-
declare function generateFileHash(file: string, projectName: string | undefined): string;
|
|
23
|
+
declare function generateFileHash(file: string, projectName: string | undefined, meta?: HashMeta): string;
|
|
20
24
|
declare function findTestFileStackTrace(testFilePath: string, error: string): ParsedStack | undefined;
|
|
21
25
|
|
|
22
26
|
interface ConcurrencyLimiter extends ConcurrencyLimiterFn {
|
package/dist/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { x as calculateSuiteHash, y as createChainable, z as createFileTask, A as createTagsFilter, B as createTaskName, C as findTestFileStackTrace, D as generateFileHash, E as generateHash, F as getFullName, G as getNames, H as getSuites, I as getTasks, J as getTestName, K as getTests, L as hasFailed, M as hasTests, N as interpretTaskModes, O as isTestCase, P as limitConcurrency, Q as matchesTags, R as partitionSuiteChildren, S as someTasksAreOnly,
|
|
1
|
+
export { x as calculateSuiteHash, y as createChainable, z as createFileTask, A as createTagsFilter, B as createTaskName, C as findTestFileStackTrace, D as generateFileHash, E as generateHash, F as getFullName, G as getNames, H as getSuites, I as getTasks, J as getTestName, K as getTests, L as hasFailed, M as hasTests, N as interpretTaskModes, O as isTestCase, P as limitConcurrency, Q as matchesTags, R as partitionSuiteChildren, S as someTasksAreOnly, U as validateTags } from './chunk-artifact.js';
|
|
2
2
|
import '@vitest/utils/error';
|
|
3
3
|
import '@vitest/utils/helpers';
|
|
4
4
|
import '@vitest/utils/timers';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest/runner",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "5.0.0-beta.2",
|
|
5
5
|
"description": "Vitest test runner",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"pathe": "^2.0.3",
|
|
47
|
-
"@vitest/utils": "
|
|
47
|
+
"@vitest/utils": "5.0.0-beta.2"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "premove dist && rollup -c",
|