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 b9f2759
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/jest-jasmine2/src/expectation_result_factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@ function stackFormatter(options, initError, errorMessage) {
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 b9f2759

Please sign in to comment.