Skip to content

Commit

Permalink
guard against missing Error.captureStackTrace
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Apr 15, 2018
1 parent 03bba1e commit 0446e1a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/expect/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,18 @@ const _validateResult = result => {

function assertions(expected: number) {
const error = new Error();
Error.captureStackTrace(error, assertions);
if (Error.captureStackTrace) {
Error.captureStackTrace(error, assertions);
}

getState().expectedAssertionsNumber = expected;
getState().expectedAssertionsNumberError = error;
}
function hasAssertions(expected: number) {
const error = new Error();
Error.captureStackTrace(error, hasAssertions);
if (Error.captureStackTrace) {
Error.captureStackTrace(error, hasAssertions);
}

utils.ensureNoExpected(expected, '.hasAssertions');
getState().isExpectingAssertions = true;
Expand Down

0 comments on commit 0446e1a

Please sign in to comment.