LearnBoost/expect.js — pull request #79 by christianalfoni (2013-11-19 17:15:55+00:00)
Title: not.throwError with regexp matching should only fail if an error is actually thrown

We built our own error constructor for arguments passed to a function, ArgumentsError.

When we test our code we get a problem with expect(fn).to.not.throwError(/ArgumentsError/)

This is what happens:
- If an error is thrown, but is of a different type: OK (as expected)
- If an error is thrown, and is an ArgumentsError: FAILS (as expected)
- If no errors are thrown: FAILS (not expected)

I have added a verification that there actually is an error thrown before verifying the matcher, as the matcher should only be verified on actual throws. No errors, not.to.throwError should pass even with a regexp matcher :-)