Add eslint rule to restrict usage of toBeTruthy or toBeFalsy
requested to merge ali_o_kan/gitlab:374983-add-rule-to-restrict-usage-of-tobetruthy-or-tobefalsy into master
Context
Avoid using
toBeTruthy
ortoBeFalsy
Jest also provides following matchers:
toBeTruthy
andtoBeFalsy
. We should not use them because they make tests weaker and produce false-positive results.For example,
expect(someBoolean).toBeFalsy()
passes whensomeBoolean === null
, and whensomeBoolean === false
.
What does this MR do and why?
- Update
eslint-plugin-jest
to 23.20.0 - Add rule to restrict usage of
toBeFalsy
andtoBeTruthy
inspec/frontend/.eslintrc.yml
- Avoid usage of
toBeTruthy
/toBeFalsy
inspec/frontend/__helpers__/class_spec_helper.js
#369616 (closed)
Screenshots or screen recordings
How to set up and validate locally
- Checkout branch
ali_o_kan/gitlab:374983-add-rule-to-restrict-usage-of-tobetruthy-or-tobefalsy
- Use
toBeFalsy
ortoBeTruthy
inspec/frontend
test
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to &8422 (closed)
Edited by Laurent Deketelaere