-
-
Notifications
You must be signed in to change notification settings - Fork 696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expect to throw force string equality instead of inclusion #436
Comments
@totty90 you can easily new up an error and achieve your desired result, something like this should work: expect(fn).to.throw(new Error("test")); Having said that - I do think our |
Same bug. |
See #551 |
It seems like this doesn’t work. =/ It looks like the expected and actual errors are compared strictly, and the result is that the assertion fails even if the error constructor and messages correspond. I have prepared a quick jsfiddle demo with chai v.3.4.1: function throwingFunction() {
throw new Error('A specific error message');
}
chai.expect(throwingFunction).to.throw(new Error('A specific error message')); Check the browser console to find the assertion error message:
I’m wondering if there I’m missing something. 8-| |
Hey @gurdiga - yes I was actually wrong above, passing two error instances will check for referential equality. |
Sounds like a plan! Thank you! 8-) |
Since we've got #683 merged, this has been solved. |
will pass even if the error thrown in like this
new Error('test2'
). I would expect to don't pass as "test" is not equal to "test2".In your docs you say:
So it passes if the string is included. Is there any way to change the behaviour of this?
The text was updated successfully, but these errors were encountered: