diff --git a/lib/test.js b/lib/test.js index fd651966..bdcfb9f2 100644 --- a/lib/test.js +++ b/lib/test.js @@ -35,6 +35,20 @@ var nextTick = typeof setImmediate !== 'undefined' var safeSetTimeout = setTimeout; var safeClearTimeout = clearTimeout; +var isErrorConstructor = isProto(Error, TypeError) // IE 8 is `false` here + ? function isErrorConstructor(C) { + return isProto(Error, C); + } + : function isErrorConstructor(C) { + return isProto(Error, C) + || isProto(TypeError, C) + || isProto(RangeError, C) + || isProto(SyntaxError, C) + || isProto(ReferenceError, C) + || isProto(EvalError, C) + || isProto(URIError, C); + }; + // eslint-disable-next-line no-unused-vars function getTestArgs(name_, opts_, cb_) { var name = '(anonymous)'; @@ -829,7 +843,7 @@ Test.prototype['throws'] = function (fn, expected, msg, extra) { if (typeof expected === 'function') { if (typeof expected.prototype !== 'undefined' && caught.error instanceof expected) { passed = true; - } else if (isProto(Error, expected)) { + } else if (isErrorConstructor(expected)) { passed = false; } else { passed = expected.call({}, caught.error) === true;