@vitest/runner
Advanced tools
Comparing version 0.29.8 to 0.30.0
import { format, deepClone, stringify, getOwnProperties, getType, toArray } from '@vitest/utils'; | ||
import { unifiedDiff } from '@vitest/utils/diff'; | ||
@@ -21,3 +22,5 @@ function partitionSuiteChildren(suite) { | ||
const IS_COLLECTION_SYMBOL = "@@__IMMUTABLE_ITERABLE__@@"; | ||
const isImmutable = (v) => v && (v[IS_COLLECTION_SYMBOL] || v[IS_RECORD_SYMBOL]); | ||
function isImmutable(v) { | ||
return v && (v[IS_COLLECTION_SYMBOL] || v[IS_RECORD_SYMBOL]); | ||
} | ||
const OBJECT_PROTO = Object.getPrototypeOf({}); | ||
@@ -94,9 +97,8 @@ function getUnserializableMessage(err) { | ||
const { replacedActual, replacedExpected } = replaceAsymmetricMatcher(clonedActual, clonedExpected); | ||
err.actual = replacedActual; | ||
err.expected = replacedExpected; | ||
const maxDiffSize = options.outputDiffMaxSize ?? 1e4; | ||
if (err.showDiff || err.showDiff === void 0 && err.expected !== void 0 && err.actual !== void 0) | ||
err.diff = unifiedDiff(replacedActual, replacedExpected, options); | ||
if (typeof err.expected !== "string") | ||
err.expected = stringify(err.expected, 10, { maxLength: maxDiffSize }); | ||
err.expected = stringify(err.expected, 10); | ||
if (typeof err.actual !== "string") | ||
err.actual = stringify(err.actual, 10, { maxLength: maxDiffSize }); | ||
err.actual = stringify(err.actual, 10); | ||
try { | ||
@@ -103,0 +105,0 @@ if (typeof err.message === "string") |
@@ -1,5 +0,5 @@ | ||
import { V as VitestRunner } from './runner-b9659804.js'; | ||
export { V as VitestRunner, a as VitestRunnerConfig, c as VitestRunnerConstructor, b as VitestRunnerImportSource } from './runner-b9659804.js'; | ||
import { T as Task, F as File, S as SuiteAPI, a as TestAPI, b as SuiteCollector, c as SuiteHooks, H as HookListener, d as TestContext, e as Suite, f as HookCleanupCallback, O as OnTestFailedHandler, g as Test } from './tasks-3fbb29e4.js'; | ||
export { D as DoneCallback, F as File, f as HookCleanupCallback, H as HookListener, O as OnTestFailedHandler, R as RunMode, p as RuntimeContext, q as SequenceHooks, r as SequenceSetupFiles, e as Suite, S as SuiteAPI, b as SuiteCollector, o as SuiteFactory, c as SuiteHooks, T as Task, i as TaskBase, j as TaskCustom, k as TaskResult, l as TaskResultPack, h as TaskState, g as Test, a as TestAPI, d as TestContext, m as TestFunction, n as TestOptions } from './tasks-3fbb29e4.js'; | ||
import { V as VitestRunner } from './runner-751eaed8.js'; | ||
export { a as VitestRunnerConfig, c as VitestRunnerConstructor, b as VitestRunnerImportSource } from './runner-751eaed8.js'; | ||
import { T as Task, F as File, S as SuiteAPI, a as TestAPI, b as SuiteCollector, c as SuiteHooks, O as OnTestFailedHandler, d as Test } from './tasks-c965d7f6.js'; | ||
export { D as DoneCallback, m as HookCleanupCallback, H as HookListener, R as RunMode, o as RuntimeContext, q as SequenceHooks, r as SequenceSetupFiles, j as Suite, n as SuiteFactory, f as TaskBase, g as TaskCustom, h as TaskResult, i as TaskResultPack, e as TaskState, p as TestContext, k as TestFunction, l as TestOptions } from './tasks-c965d7f6.js'; | ||
import { Awaitable } from '@vitest/utils'; | ||
@@ -10,12 +10,12 @@ | ||
declare const suite: SuiteAPI<{}>; | ||
declare const test: TestAPI<{}>; | ||
declare const describe: SuiteAPI<{}>; | ||
declare const it: TestAPI<{}>; | ||
declare const suite: SuiteAPI; | ||
declare const test: TestAPI; | ||
declare const describe: SuiteAPI; | ||
declare const it: TestAPI; | ||
declare function getCurrentSuite<ExtraContext = {}>(): SuiteCollector<ExtraContext>; | ||
declare const beforeAll: (fn: SuiteHooks['beforeAll'][0], timeout?: number) => void; | ||
declare const afterAll: (fn: SuiteHooks['afterAll'][0], timeout?: number) => void; | ||
declare const beforeEach: <ExtraContext = {}>(fn: HookListener<[TestContext & ExtraContext, Suite], HookCleanupCallback>, timeout?: number) => void; | ||
declare const afterEach: <ExtraContext = {}>(fn: HookListener<[TestContext & ExtraContext, Suite], void>, timeout?: number) => void; | ||
declare function beforeAll(fn: SuiteHooks['beforeAll'][0], timeout?: number): void; | ||
declare function afterAll(fn: SuiteHooks['afterAll'][0], timeout?: number): void; | ||
declare function beforeEach<ExtraContext = {}>(fn: SuiteHooks<ExtraContext>['beforeEach'][0], timeout?: number): void; | ||
declare function afterEach<ExtraContext = {}>(fn: SuiteHooks<ExtraContext>['afterEach'][0], timeout?: number): void; | ||
declare const onTestFailed: (fn: OnTestFailedHandler) => void; | ||
@@ -26,2 +26,4 @@ | ||
export { afterAll, afterEach, beforeAll, beforeEach, describe, getCurrentSuite, getFn, it, onTestFailed, setFn, startTests, suite, test, updateTask }; | ||
declare function getCurrentTest(): Test<{}> | undefined; | ||
export { File, OnTestFailedHandler, SuiteAPI, SuiteCollector, SuiteHooks, Task, Test, TestAPI, VitestRunner, afterAll, afterEach, beforeAll, beforeEach, describe, getCurrentSuite, getCurrentTest, getFn, it, onTestFailed, setFn, startTests, suite, test, updateTask }; |
@@ -5,2 +5,3 @@ import limit from 'p-limit'; | ||
import { relative } from 'pathe'; | ||
import '@vitest/utils/diff'; | ||
@@ -252,2 +253,3 @@ const fnMap = /* @__PURE__ */ new WeakMap(); | ||
(_, key) => objDisplay(objectAttr(items[0], key)) | ||
// https://github.com/chaijs/chai/pull/1490 | ||
); | ||
@@ -290,3 +292,3 @@ } | ||
const file = { | ||
id: generateHash(path), | ||
id: generateHash(`${path}${config.name || ""}`), | ||
name: path, | ||
@@ -411,3 +413,3 @@ type: "suite", | ||
} | ||
const callCleanupHooks = async (cleanups) => { | ||
async function callCleanupHooks(cleanups) { | ||
await Promise.all(cleanups.map(async (fn) => { | ||
@@ -418,3 +420,3 @@ if (typeof fn !== "function") | ||
})); | ||
}; | ||
} | ||
async function runTest(test, runner) { | ||
@@ -451,2 +453,8 @@ var _a, _b, _c, _d, _e, _f; | ||
} | ||
if (test.promises) { | ||
const result = await Promise.allSettled(test.promises); | ||
const errors = result.map((r) => r.status === "rejected" ? r.reason : void 0).filter(Boolean); | ||
if (errors.length) | ||
throw errors; | ||
} | ||
await ((_d = runner.onAfterTryTest) == null ? void 0 : _d.call(runner, test, retryCount)); | ||
@@ -488,6 +496,9 @@ test.result.state = "pass"; | ||
result.state = "fail"; | ||
const error = processError(err); | ||
result.error = error; | ||
result.errors ?? (result.errors = []); | ||
result.errors.push(error); | ||
const errors = Array.isArray(err) ? err : [err]; | ||
for (const e of errors) { | ||
const error = processError(e); | ||
result.error ?? (result.error = error); | ||
result.errors ?? (result.errors = []); | ||
result.errors.push(error); | ||
} | ||
} | ||
@@ -607,7 +618,17 @@ function markTasksAsSkipped(suite, runner) { | ||
const getDefaultHookTimeout = () => getRunner().config.hookTimeout; | ||
const beforeAll = (fn, timeout) => getCurrentSuite().on("beforeAll", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true)); | ||
const afterAll = (fn, timeout) => getCurrentSuite().on("afterAll", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true)); | ||
const beforeEach = (fn, timeout) => getCurrentSuite().on("beforeEach", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true)); | ||
const afterEach = (fn, timeout) => getCurrentSuite().on("afterEach", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true)); | ||
function getDefaultHookTimeout() { | ||
return getRunner().config.hookTimeout; | ||
} | ||
function beforeAll(fn, timeout) { | ||
return getCurrentSuite().on("beforeAll", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true)); | ||
} | ||
function afterAll(fn, timeout) { | ||
return getCurrentSuite().on("afterAll", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true)); | ||
} | ||
function beforeEach(fn, timeout) { | ||
return getCurrentSuite().on("beforeEach", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true)); | ||
} | ||
function afterEach(fn, timeout) { | ||
return getCurrentSuite().on("afterEach", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true)); | ||
} | ||
const onTestFailed = createTestHook("onTestFailed", (test, handler) => { | ||
@@ -626,2 +647,2 @@ test.onFailed || (test.onFailed = []); | ||
export { afterAll, afterEach, beforeAll, beforeEach, describe, getCurrentSuite, getFn, it, onTestFailed, setFn, startTests, suite, test, updateTask }; | ||
export { afterAll, afterEach, beforeAll, beforeEach, describe, getCurrentSuite, getCurrentTest, getFn, it, onTestFailed, setFn, startTests, suite, test, updateTask }; |
@@ -1,3 +0,3 @@ | ||
export { D as DoneCallback, F as File, f as HookCleanupCallback, H as HookListener, O as OnTestFailedHandler, R as RunMode, p as RuntimeContext, q as SequenceHooks, r as SequenceSetupFiles, e as Suite, S as SuiteAPI, b as SuiteCollector, o as SuiteFactory, c as SuiteHooks, T as Task, i as TaskBase, j as TaskCustom, k as TaskResult, l as TaskResultPack, h as TaskState, g as Test, a as TestAPI, d as TestContext, m as TestFunction, n as TestOptions } from './tasks-3fbb29e4.js'; | ||
export { V as VitestRunner, a as VitestRunnerConfig, c as VitestRunnerConstructor, b as VitestRunnerImportSource } from './runner-b9659804.js'; | ||
export { D as DoneCallback, F as File, m as HookCleanupCallback, H as HookListener, O as OnTestFailedHandler, R as RunMode, o as RuntimeContext, q as SequenceHooks, r as SequenceSetupFiles, j as Suite, S as SuiteAPI, b as SuiteCollector, n as SuiteFactory, c as SuiteHooks, T as Task, f as TaskBase, g as TaskCustom, h as TaskResult, i as TaskResultPack, e as TaskState, d as Test, a as TestAPI, p as TestContext, k as TestFunction, l as TestOptions } from './tasks-c965d7f6.js'; | ||
export { V as VitestRunner, a as VitestRunnerConfig, c as VitestRunnerConstructor, b as VitestRunnerImportSource } from './runner-751eaed8.js'; | ||
import '@vitest/utils'; |
@@ -1,5 +0,14 @@ | ||
import { e as Suite, T as Task, g as Test, j as TaskCustom } from './tasks-3fbb29e4.js'; | ||
export { C as ChainableFunction, E as ErrorWithDiff, P as ParsedStack, s as createChainable, u as processError, v as replaceAsymmetricMatcher, t as serializeError } from './tasks-3fbb29e4.js'; | ||
import { j as Suite, T as Task, d as Test, g as TaskCustom } from './tasks-c965d7f6.js'; | ||
export { C as ChainableFunction, s as createChainable } from './tasks-c965d7f6.js'; | ||
import { Arrayable } from '@vitest/utils'; | ||
export { ErrorWithDiff, ParsedStack } from '@vitest/utils'; | ||
import { DiffOptions } from '@vitest/utils/diff'; | ||
declare function serializeError(val: any, seen?: WeakMap<object, any>): any; | ||
declare function processError(err: any, options?: DiffOptions): any; | ||
declare function replaceAsymmetricMatcher(actual: any, expected: any, actualReplaced?: WeakSet<object>, expectedReplaced?: WeakSet<object>): { | ||
replacedActual: any; | ||
replacedExpected: any; | ||
}; | ||
/** | ||
@@ -25,2 +34,2 @@ * If any tasks been marked as `only`, mark all other tasks as `skip`. | ||
export { calculateSuiteHash, generateHash, getNames, getSuites, getTasks, getTests, hasFailed, hasTests, interpretTaskModes, partitionSuiteChildren, someTasksAreOnly }; | ||
export { calculateSuiteHash, generateHash, getNames, getSuites, getTasks, getTests, hasFailed, hasTests, interpretTaskModes, partitionSuiteChildren, processError, replaceAsymmetricMatcher, serializeError, someTasksAreOnly }; |
export { a as calculateSuiteHash, c as createChainable, g as generateHash, k as getNames, j as getSuites, f as getTasks, e as getTests, d as hasFailed, h as hasTests, i as interpretTaskModes, b as partitionSuiteChildren, p as processError, r as replaceAsymmetricMatcher, l as serializeError, s as someTasksAreOnly } from './chunk-tasks.js'; | ||
import '@vitest/utils'; | ||
import '@vitest/utils/diff'; |
{ | ||
"name": "@vitest/runner", | ||
"type": "module", | ||
"version": "0.29.8", | ||
"version": "0.30.0", | ||
"description": "Vitest test runner", | ||
@@ -36,5 +36,6 @@ "license": "MIT", | ||
"dependencies": { | ||
"concordance": "^5.0.4", | ||
"p-limit": "^4.0.0", | ||
"pathe": "^1.1.0", | ||
"@vitest/utils": "0.29.8" | ||
"@vitest/utils": "0.30.0" | ||
}, | ||
@@ -41,0 +42,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
68935
15
1865
4
+ Addedconcordance@^5.0.4
+ Added@vitest/utils@0.30.0(transitive)
+ Addedblueimp-md5@2.19.0(transitive)
+ Addedconcordance@5.0.4(transitive)
+ Addeddate-time@3.1.0(transitive)
+ Addedesutils@2.0.3(transitive)
+ Addedfast-diff@1.3.0(transitive)
+ Addedjs-string-escape@1.0.1(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedmd5-hex@3.0.1(transitive)
+ Addedsemver@7.6.3(transitive)
+ Addedtime-zone@1.0.0(transitive)
+ Addedwell-known-symbols@2.0.0(transitive)
- Removed@vitest/utils@0.29.8(transitive)
- Removedansi-regex@6.1.0(transitive)
- Removedansi-styles@6.2.1(transitive)
- Removedcli-truncate@3.1.0(transitive)
- Removeddiff@5.2.0(transitive)
- Removedeastasianwidth@0.2.0(transitive)
- Removedemoji-regex@9.2.2(transitive)
- Removedis-fullwidth-code-point@4.0.0(transitive)
- Removedslice-ansi@5.0.0(transitive)
- Removedstring-width@5.1.2(transitive)
- Removedstrip-ansi@7.1.0(transitive)
Updated@vitest/utils@0.30.0