Skip to content

Commit

Permalink
Don't leak internal AssertionErrors to user code
Browse files Browse the repository at this point in the history
Asynchronous `t.throws()` / `t.notThrows()` was the only case where
internal AssertionErrors were leaked to user code. Return `undefined`
instead.
  • Loading branch information
novemberborn committed Mar 23, 2017
1 parent df54324 commit d56db75
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,10 @@ function wrapAssertions(callbacks) {
};

if (promise) {
const result = promise.then(makeNoop, makeRethrow).then(test);
pending(this, result);
return result;
const intermediate = promise.then(makeNoop, makeRethrow).then(test);
pending(this, intermediate);
// Don't reject the returned promise, even if the assertion fails.
return intermediate.catch(noop);
}

try {
Expand Down Expand Up @@ -208,10 +209,10 @@ function wrapAssertions(callbacks) {
};

if (promise) {
const result = promise
.then(noop, reason => test(makeRethrow(reason)));
pending(this, result);
return result;
const intermediate = promise.then(noop, reason => test(makeRethrow(reason)));
pending(this, intermediate);
// Don't reject the returned promise, even if the assertion fails.
return intermediate.catch(noop);
}

try {
Expand Down

0 comments on commit d56db75

Please sign in to comment.