From 32e59a833b2268d12f24c16e0ac10899d267fcb9 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Thu, 28 Feb 2019 13:05:18 +0100 Subject: [PATCH] ternary --- packages/jest-circus/src/utils.ts | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/packages/jest-circus/src/utils.ts b/packages/jest-circus/src/utils.ts index b09c21f445e0..45d93fc2286e 100644 --- a/packages/jest-circus/src/utils.ts +++ b/packages/jest-circus/src/utils.ts @@ -175,15 +175,9 @@ export const callAsyncCircusFn = ( // soon as `done` called. if (fn.length) { const done = (reason?: Error | string): void => { - let errorAsErrorObject: Error; - - if (checkIsError(reason)) { - errorAsErrorObject = reason; - } else { - errorAsErrorObject = new Error( - `Failed: ${prettyFormat(reason, {maxDepth: 3})}`, - ); - } + const errorAsErrorObject = checkIsError(reason) + ? reason + : new Error(`Failed: ${prettyFormat(reason, {maxDepth: 3})}`); // Consider always throwing, regardless if `reason` is set or not if (completed && reason) {