-
-
Notifications
You must be signed in to change notification settings - Fork 693
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
It would be nice if expect(x).to.equal.true would throw an error #455
Comments
Hey @joevennix thanks for the issue. It would be nice to have these kinds of properties raise an error - but I don't want to do it on a case-per-case basis, as that becomes a slippery slope, where we have hundreds of lines of code to protect users from mistakes. Rather than that, we've been discussing the idea of using ES6 Proxies over in #407 which will generically catch on ALL of these kinds of errors. I'm going to close this one, in favour of furthering discussion in #407. |
@keithamu, love the idea of using ES6 proxies! I would have proposed that myself but wasn't sure what it would mean for supported browsers etc. Thanks for the quick response. |
@keithamus, does chai have an idea of a testComplete() hook? If so, you could perhaps implement this without proxies, by raising after the test when a expect() is called but an assertion was never actually performed. |
There is no concept of this at the moment, and I doubt there could be - for starters when would the error throw? We've discussed the idea of counting assertions within chai - sort of like qunits Proxies are a solid option for property access, another option is trying to re-develop a solution for "jshint friendly assertions" (meaning no assertion properties like |
Right now,
expect(x).to.equal.true
silently passes. Correct me if I am wrong, but accessing properties off of.equal
never looks to be useful, so it would be beneficial to (forgetful) developers to have this raise instead of silently pass. This could be done with a fixed set of getters onequal
that raise.If my thinking is correct I will happily implement this feature for you folks.
The text was updated successfully, but these errors were encountered: