Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

no-truthy-falsy.md 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # Disallow using `toBeTruthy()` & `toBeFalsy()` (`no-truthy-falsy`)
  2. ## Deprecated
  3. This rule has been deprecated in favor of
  4. [`no-restricted-matchers`](no-restricted-matchers.md) with the following config:
  5. ```json
  6. {
  7. "rules": {
  8. "jest/no-restricted-matchers": [
  9. "error",
  10. {
  11. "toBeTruthy": "Avoid `toBeTruthy`",
  12. "toBeFalsy": "Avoid `toBeFalsy`"
  13. }
  14. ]
  15. }
  16. }
  17. ```
  18. ---
  19. Tests against boolean values should assert true or false. Asserting `toBeTruthy`
  20. or `toBeFalsy` matches non-boolean values as well and encourages weaker tests.
  21. For example, `expect(someBoolean).toBeFalsy()` passes when
  22. `someBoolean === null`, and when `someBoolean === false`.
  23. Similarly, `expect(someBoolean).toBeTruthy()` passes when `someBoolean === []`,
  24. and when `someBoolean === 'false'` (note that `'false'` is a string).
  25. ## Rule details
  26. This rule triggers a warning if `toBeTruthy()` or `toBeFalsy()` are used.
  27. This rule is disabled by default.
  28. ### Default configuration
  29. The following patterns are considered warnings:
  30. ```js
  31. expect(someValue).toBeTruthy();
  32. expect(someValue).toBeFalsy();
  33. ```
  34. The following patterns are not considered warnings:
  35. ```js
  36. expect(someValue).toBe(true);
  37. expect(someValue).toBe(false);
  38. ```