From d4b5e4733534ec4648abf94e9b77e29fa6a7a6ae Mon Sep 17 00:00:00 2001 From: Nicolas DUBIEN Date: Tue, 21 Feb 2023 06:53:53 +0000 Subject: [PATCH] fix new case for jasmine --- packages/jest-message-util/src/index.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/jest-message-util/src/index.ts b/packages/jest-message-util/src/index.ts index 673e805d04c8..1f9de62b0a3f 100644 --- a/packages/jest-message-util/src/index.ts +++ b/packages/jest-message-util/src/index.ts @@ -436,11 +436,17 @@ export const formatResultsErrors = ( return failedResults .map(({result, content, failureDetails}) => { - const rootErrorOrStack: Error | string = - failureDetails && - (types.isNativeError(failureDetails) || failureDetails instanceof Error) - ? failureDetails - : content; + const rootErrorOrStack: Error | string = failureDetails + ? types.isNativeError(failureDetails) || failureDetails instanceof Error + ? failureDetails // receiving raw errors for jest-circus + : typeof failureDetails === 'object' && + 'error' in failureDetails && + failureDetails.error && + (types.isNativeError(failureDetails.error) || + failureDetails.error instanceof Error) + ? failureDetails.error // receiving instances of FailedAssertion for jest-jasmine + : content + : content; const title = `${chalk.bold.red( TITLE_INDENT +