-
-
Notifications
You must be signed in to change notification settings - Fork 702
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
Non-Error Types Not Being Detected Properly by .throw #1079
Comments
@mreinigjr Before I go into long-winded explanations here, let me make sure of one thing: In |
@meeber, yes the code is exporting Also, I am not sure what you mean by |
My statement was only in regard to your original example. In your original example, the imported Now let's forget about the original example and take a look at your updated example, specifically The error message is now: There were changes made to If you're stuck with a legacy codebase and need to write tests to assert that the correct objects are being thrown, even if they aren't actually expect(exampleIssue).to.throw().and.be.an.instanceof(badThingHappend); (As for |
Oh gotcha! That makes a ton of sense now. I should have looked into that deeper. The sentence you referenced is exactly what caused the creation of this issue. Updating the docs with your example on how to assert on non- |
So I am seeing some weirdness with functions that have parameters and throw non- |
Hard to speculate on the I don't know if it's related to the issue you're running into, but it's worth noting that the semi-example you provided above isn't really testing the same thing, since the first argument to
|
Thanks @meeber! |
I am working on some legacy code that throws custom errors. In Chai 3.5.0 the following simple code package will pass with mocha 4.1.2. Run
npm install
first and thennpm test
after downloading and extracting the zip file.chai-issue-1.zip(updated)
However, if you upgrade chai to 4.1.2, the test now fails.
npm install --save-exact chai@4.1.2
npm test
Test fails with
AssertionError: expected [Function: exampleIssue] to throw { Object (badThingHappend) } but 'TypeError: badThingHappend is not a constructor' was thrown
Adding
this
to the parameter provided to.throw
in the test fixes the issue and the test passes. Again, runnpm install
andnpm test
after downloading the package.chai-issue-2.zip(updated)
I have not dug too deep to figure out what the underlying issue is between versions of chai, but a very simple fix would be to update the documentation near the second to last sentence in the
.throw
section. Just incase it is relevant, I am running npm version 5.5.1 and node version 6.11.5. Thanks!The text was updated successfully, but these errors were encountered: