-
-
Notifications
You must be signed in to change notification settings - Fork 697
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
Sanity check for assertion instanceOf #893
Comments
Hello @fgarcia thanks for your issue. IMHO this is a chai problem, I agree with you that this should provide a more meaningful error message. So, IMHO:
It should be very easy to do this, we just need to add a check here Am I missing something here? Do someone disagree? |
Hi @fgarcia, thanks for your issue! 😄 Well, I totally agree with @vieiralucas that we should fix this. However, I think throwing an error is something that should be done within Chai's core. IMO the whole point of having a separate module for I think that it would be more adequate to just add a check to Feel free to share your thoughts :) |
I didnt mean to change get-func-name to throw a chai specific custom error. |
Agreed that we should validate what is getting passed to However, with ES6's |
Fixed via #899 |
The current implementation for the
instanceOf
assert does not check if the given constructor is definedchai/lib/chai/core/assertions.js
Line 989 in 104a6b7
There is a common error I hit several times where an imported variable stops working. I use that variable to assert the instance of an object, like:
When the import fails (silently) with an undefined value, the error thrown by the assertion shows a normal Javascript error
TypeError: Cannot read property 'name' of undefined
It would be great getting something more meaningful like
ChaiError: instanceOf() needs a constructor. undefined value given
NOTE:
I've realized there is no such thing as
ChaiError
error subtype. I am not sure how far the current code base goes to improve bad use casesThe text was updated successfully, but these errors were encountered: