Browse Source

Don't leak internal AssertionErrors to user code

Asynchronous `t.throws()` / `t.notThrows()` was the only case where
internal AssertionErrors were leaked to user code. Return `undefined`
instead.
master
Mark Wubben 8 years ago
parent
commit
d56db75705
  1. 15
      lib/assert.js

15
lib/assert.js

@ -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 {
@ -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 {

Loading…
Cancel
Save