diff --git a/expect.js b/expect.js index 7d47e95..4c0ed47 100644 --- a/expect.js +++ b/expect.js @@ -161,9 +161,9 @@ thrown = true; } - if (isRegExp(fn) && not) { - // in the presence of a matcher, ensure the `not` only applies to - // the matching. + if (thrown && not && isRegExp(fn)) { + // in the presence of a matcher and an error actually is thrown, + // ensure the `not` only applies to the matching. this.flags.not = false; } diff --git a/test/expect.js b/test/expect.js index 7b24cdf..5d6d508 100644 --- a/test/expect.js +++ b/test/expect.js @@ -143,6 +143,7 @@ describe('expect', function () { expect(itThrowsString).to.throwException(/aaa/); expect(itThrowsString).to.not.throwException(/bbb/); + expect(itWorks).to.not.throwException(/ccc/); err(function () { expect(itThrowsString).to.throwException(/no match/i);