From 62b6f31aad01164fd3112807565447e3ac4e7bab Mon Sep 17 00:00:00 2001 From: IgnusG <6438760+IgnusG@users.noreply.github.com> Date: Sun, 4 Sep 2022 15:04:23 +0200 Subject: [PATCH] fix: show diff for errors that contain actual/expected without showDiff --- packages/vitest/src/node/error.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/vitest/src/node/error.ts b/packages/vitest/src/node/error.ts index d9dbc42de956..d6a60504b2d0 100644 --- a/packages/vitest/src/node/error.ts +++ b/packages/vitest/src/node/error.ts @@ -69,7 +69,8 @@ export async function printError(error: unknown, ctx: Vitest, options: PrintErro handleImportOutsideModuleError(e.stack || e.stackStr || '', ctx) - if (e.showDiff) { + // Eg. AssertionError from assert does not set showDiff but has both actual and expected properties + if (e.showDiff || (e.showDiff === undefined && e.actual && e.expected)) { displayDiff(stringify(e.actual), stringify(e.expected), ctx.logger.console, { outputTruncateLength: ctx.config.outputTruncateLength, outputDiffLines: ctx.config.outputDiffLines,