Skip to content

Commit

Permalink
expect: Make change requested in toThrowMatchers (#7718)
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrottimark authored and SimenB committed Jan 29, 2019
1 parent 0633a61 commit 7d54557
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions packages/expect/src/toThrowMatchers.js
Expand Up @@ -38,28 +38,22 @@ type Thrown =
};

const getThrown = (e: any): Thrown => {
if (
e !== null &&
e !== undefined &&
typeof e.message === 'string' &&
typeof e.name === 'string' &&
typeof e.stack === 'string'
) {
const hasMessage =
e !== null && e !== undefined && typeof e.message === 'string';

if (hasMessage && typeof e.name === 'string' && typeof e.stack === 'string') {
return {
hasMessage: true,
hasMessage,
isError: true,
message: e.message,
value: e,
};
}

const hasMessage =
e !== null && e !== undefined && typeof e.message === 'string';

return {
hasMessage,
isError: false,
message: hasMessage ? e.message : typeof e === 'string' ? e : String(e),
message: hasMessage ? e.message : String(e),
value: e,
};
};
Expand Down

0 comments on commit 7d54557

Please sign in to comment.