-
-
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
breaking change in 2.0 (null, undefined, arguments, ok, true, false, empty, exist) #371
Comments
I see the same. Our test suite was updated to use function call syntax and under 2.0.0 they all fail. Include |
Look at the bottom of the 2.0.0 change log.
Was this intentional? |
Thanks for the issue @BigstickCarpet. This was fully intentional. The new method assertion style ( Because developers have been using the new style, and dropping the new style would break their code, we pushed the change as a Version 2.0.0. According to SemVer (which I'd like us to start following for future releases), major versions mean breaking changes - which is to say that the contract of "you wont have to refactor your test code" is invalidated. If you'd like to keep the method assertion syntax (
Ultimately, if we made the wrong decision in settling on one style, and the majority of the Chai community wants to solely use the method assertions ( |
For more context on all of this:
|
Hi, thank you for this explanation. But as we are not english natives, it turns out that we mispelled some expectation (especially exist()): expect(err).not.to.exists; In the old style, Use the new style Is it possible with [email protected] that this edge case does not happen anymore ? |
Thanks @feugy for your use case, this is definitely one advantage of using method assertions. @feugy I suggest for now you use dirty-chai |
May I suggest placing some sort of notice or link at the top of the documentation saying "Upgrading to 2.0? Look here to see the breaking changes" or something similar. I was confused why things were not working until I found this thread and then the changelog. For what it's worth, at least in my projects, this was an easy global find and place so it wasn't so bad. |
@keithamus Couldn't a lib like funstance make those properties callable in a backwards compatible way? |
@lo1tuma thanks for the suggestion, but we already went down this road with the initial PRs. I'd be incredibly weary of trying to support both styles as it was pretty effectively proven to be buggy. The only real solution is to go all in with one style, which we've done. @KrisSiegel sounds like a great idea 😄. Love to see a PR for better documentation across the project! |
I think the dust has settled on this now. I'm going to close this one, as I'm pretty sure we're sticking with the property style of assertions. dirty-chai exists and is a perfectly suitable plugin for this - and is compatible with all other plugins. |
…otentially harmful in particular when troubleshooting through tests and adding .to.be.defined because you see a .to.be.undefined somehwere. There is .to.exist but after 2.0.0 chaijs#371 assertions are more prone to false positives.
And fix some test for breaking changes of chai. [ chaijs/chai#371 ]
And fix some test for breaking changes of chai. [ chaijs/chai#371 ]
And fix some test for breaking changes of chai. [ chaijs/chai#371 ]
Before the 2.0 release of Chai, these assertions could be written as properties or as functions. For example:
The documentation on chaijs.com even explained that this dual-syntax was there to play nice with some IDEs and linting tools that flag the non-function syntax as an error. But in 2.0, the function syntax no longer exists. Was it removed by accident, or was there a reason for it?
The text was updated successfully, but these errors were encountered: