-
-
Notifications
You must be signed in to change notification settings - Fork 698
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
Misleading .property assertion behaviour with value #452
Comments
For clarification, this const could be set up by checking the |
The opened PR addresses this issue by checking the length of the arguments array. I attempted to add a few additional tests to cover these previously untested cases where If I could get help sorting that out I can update the PR with these additional tests. Additional tests: onefifth@91f57e9 |
This test passes despite
key
not having a value ofundefined
.I realize that the 'correct' way to test this would be to use the
.undefined
assertion, but there are a couple times where this has caught me off guard.Say you've done something like
.to.have.property('key', setupObject.myProprty)
, but you've misspelt.myProperty
.Now you have a really weird test that's passing without doing the value comparison it looks like it should be doing because you've mistakenly passed
undefined
."Offending" code: https://github.com/chaijs/chai/blob/master/lib/chai/core/assertions.js#L850
It would be nice to potentially use some internal
CHAI_UNDEFINED
const as the default value forval
in these cases to internally differentiate between an unused optional parameter and one explicitly set to undefined. I have only encountered this using this particular assertion, but this behaviour quite possibly exists elsewhere there are optional arguments.The text was updated successfully, but these errors were encountered: