Skip to content

Commit

Permalink
please flow gods
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Apr 16, 2018
1 parent d01429f commit 7e87a84
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/jest-jasmine2/src/expectation_result_factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,20 @@ function messageFormatter({error, message, passed}) {
return `thrown: ${prettyFormat(error, {maxDepth: 3})}`;
}

function stackFormatter(options, initError, errorMessage) {
function stackFormatter(options, initError?, errorMessage) {
if (options.passed) {
return '';
}

if ((options.error && options.error.stack)) {
if (options.error && options.error.stack) {
return options.error.stack;
}

return errorMessage + '\n' + initError.stack;
if (initError) {
return errorMessage + '\n' + initError.stack;
}

return new Error(errorMessage).stack;
}

type Options = {
Expand All @@ -52,7 +56,10 @@ type Options = {
message?: string,
};

export default function expectationResultFactory(options: Options, initError) {
export default function expectationResultFactory(
options: Options,
initError?: Error,
) {
const message = messageFormatter(options);
const stack = stackFormatter(options, initError, message);

Expand Down

0 comments on commit 7e87a84

Please sign in to comment.