From ab02c6ff4736864106b05efa201cf385274219c7 Mon Sep 17 00:00:00 2001 From: Daniel Price Date: Fri, 15 May 2015 11:46:05 -0700 Subject: [PATCH] Issue #442 chai can't cope with AssertionErrors raised from node's assert --- lib/chai/core/assertions.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/chai/core/assertions.js b/lib/chai/core/assertions.js index dd67ba336..f2f0f3034 100644 --- a/lib/chai/core/assertions.js +++ b/lib/chai/core/assertions.js @@ -1227,9 +1227,9 @@ module.exports = function (chai, _) { constructor = null; errMsg = null; } else if (typeof constructor === 'function') { - name = constructor.prototype.name || constructor.name; - if (name === 'Error' && constructor !== Error) { - name = (new constructor()).name; + name = constructor.prototype.name; + if (!name || (name === 'Error' && constructor !== Error)) { + name = constructor.name || (new constructor()).name; } } else { constructor = null;