@vitest/runner 4.1.4 → 5.0.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/chunk-artifact.js +25 -6
- package/dist/index.d.ts +8 -3
- package/dist/index.js +1 -1
- package/dist/{tasks.d-Bh0IjN67.d.ts → tasks.d-Br8qsHTh.d.ts} +11 -3
- package/dist/types.d.ts +1 -1
- package/dist/utils.d.ts +2 -2
- 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();
|
|
@@ -2185,6 +2199,7 @@ function formatTitle(template, items, idx) {
|
|
|
2185
2199
|
}
|
|
2186
2200
|
});
|
|
2187
2201
|
}
|
|
2202
|
+
const inspectOptions = { truncate: runner.config.taskTitleValueFormatTruncate };
|
|
2188
2203
|
const isObjectItem = isObject(items[0]);
|
|
2189
2204
|
function formatAttribute(s) {
|
|
2190
2205
|
return s.replace(/\$([$\w.]+)/g, (_, key) => {
|
|
@@ -2194,7 +2209,11 @@ function formatTitle(template, items, idx) {
|
|
|
2194
2209
|
}
|
|
2195
2210
|
const arrayElement = isArrayKey ? objectAttr(items, key) : undefined;
|
|
2196
2211
|
const value = isObjectItem ? objectAttr(items[0], key, arrayElement) : arrayElement;
|
|
2197
|
-
|
|
2212
|
+
// print string without quotes
|
|
2213
|
+
if (typeof value === "string") {
|
|
2214
|
+
return truncateString(value, inspectOptions.truncate);
|
|
2215
|
+
}
|
|
2216
|
+
return inspect(value, inspectOptions);
|
|
2198
2217
|
});
|
|
2199
2218
|
}
|
|
2200
2219
|
let output = "";
|
|
@@ -2205,7 +2224,7 @@ function formatTitle(template, items, idx) {
|
|
|
2205
2224
|
// format "%"
|
|
2206
2225
|
(match) => {
|
|
2207
2226
|
if (i < count) {
|
|
2208
|
-
output += format(match[0], items[i++]);
|
|
2227
|
+
output += format([match[0], items[i++]], inspectOptions);
|
|
2209
2228
|
} else {
|
|
2210
2229
|
output += match[0];
|
|
2211
2230
|
}
|
|
@@ -3035,13 +3054,13 @@ async function runTest(test, runner) {
|
|
|
3035
3054
|
updateTask("test-retried", test, runner);
|
|
3036
3055
|
}
|
|
3037
3056
|
}
|
|
3038
|
-
// if test is marked to be failed, flip the result
|
|
3057
|
+
// if test is marked to be failed, flip the result unless `TestSyntaxError` is present
|
|
3039
3058
|
if (test.fails) {
|
|
3040
3059
|
if (test.result.state === "pass") {
|
|
3041
3060
|
const error = processError(new Error("Expect test to fail"));
|
|
3042
3061
|
test.result.state = "fail";
|
|
3043
3062
|
test.result.errors = [error];
|
|
3044
|
-
} else {
|
|
3063
|
+
} else if (!test.result.errors?.some((e) => e.__vitest_test_syntax_error__)) {
|
|
3045
3064
|
test.result.state = "pass";
|
|
3046
3065
|
test.result.errors = undefined;
|
|
3047
3066
|
}
|
|
@@ -3454,4 +3473,4 @@ function manageArtifactAttachment(attachment) {
|
|
|
3454
3473
|
}
|
|
3455
3474
|
}
|
|
3456
3475
|
|
|
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,
|
|
3476
|
+
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-Br8qsHTh.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-Br8qsHTh.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;
|
|
@@ -1412,6 +1413,13 @@ interface VisualRegressionArtifact extends TestArtifactBase {
|
|
|
1412
1413
|
message: string;
|
|
1413
1414
|
attachments: VisualRegressionArtifactAttachment[];
|
|
1414
1415
|
}
|
|
1416
|
+
/**
|
|
1417
|
+
* @experimental
|
|
1418
|
+
*/
|
|
1419
|
+
interface BrowserTraceArtifact extends TestArtifactBase {
|
|
1420
|
+
type: "internal:browserTrace";
|
|
1421
|
+
data: unknown;
|
|
1422
|
+
}
|
|
1415
1423
|
interface FailureScreenshotArtifactAttachment extends TestAttachment {
|
|
1416
1424
|
path: string;
|
|
1417
1425
|
/** Original file system path to the screenshot, before attachment resolution */
|
|
@@ -1507,7 +1515,7 @@ interface TestArtifactRegistry {}
|
|
|
1507
1515
|
*
|
|
1508
1516
|
* This type automatically includes all artifacts registered via {@link TestArtifactRegistry}.
|
|
1509
1517
|
*/
|
|
1510
|
-
type TestArtifact = FailureScreenshotArtifact | TestAnnotationArtifact | VisualRegressionArtifact | TestArtifactRegistry[keyof TestArtifactRegistry];
|
|
1518
|
+
type TestArtifact = BrowserTraceArtifact | FailureScreenshotArtifact | TestAnnotationArtifact | VisualRegressionArtifact | TestArtifactRegistry[keyof TestArtifactRegistry];
|
|
1511
1519
|
|
|
1512
|
-
export { afterAll as
|
|
1513
|
-
export type {
|
|
1520
|
+
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 };
|
|
1521
|
+
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-Br8qsHTh.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-Br8qsHTh.js';
|
|
2
|
+
export { C as ChainableFunction, c as createChainable } from './tasks.d-Br8qsHTh.js';
|
|
3
3
|
import { ParsedStack, Arrayable } from '@vitest/utils';
|
|
4
4
|
import '@vitest/utils/diff';
|
|
5
5
|
|
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.1",
|
|
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.1"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "premove dist && rollup -c",
|