Closed zeke closed 1 year ago
@ljharb How actual this issue is? Do you think we need to add something like:
Do not use
to.be.true
, etc. in your tests, but use.to.equal(true)
Shall we put it within Testing section?
Yes, but specifically, a section on never using "noop" matchers - ie, anything that doesn't end in a function call - because the cost of a typo is a silent passing test. In other words, expect(x).to.be.yogurt;
will merrily pass, whereas expect(x).to.be.yogurt()
will correctly throw, failing your test.
Thanks for following up on this, @ljharb 👍
Since opening this issue (over three years ago!), the standard
linter has been updated to no longer allow expressions like to.be.true
, which has protected me from accidentally using that assertion style in projects.
This issue can also be closed.
There's an issue on enzyme https://github.com/airbnb/enzyme/issues/97 about strengthening the assertion styles to avoid false positives:
The issue mentions that the
to.be.true
style violates this styleguide, but I wasn't able to find any content here that alludes to this.