web 3d图形渲染器
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.

45 lines
862 B

  1. # Suggest using `toContain()` (`prefer-to-contain`)
  2. In order to have a better failure message, `toContain()` should be used upon
  3. asserting expectations on an array containing an object.
  4. ## Rule details
  5. This rule triggers a warning if `toBe()`, `toEqual()` or `toStrictEqual()` is
  6. used to assert object inclusion in an array
  7. ```js
  8. expect(a.includes(b)).toBe(true);
  9. ```
  10. ```js
  11. expect(a.includes(b)).not.toBe(true);
  12. ```
  13. ```js
  14. expect(a.includes(b)).toBe(false);
  15. ```
  16. ### Default configuration
  17. The following patterns are considered warnings:
  18. ```js
  19. expect(a.includes(b)).toBe(true);
  20. expect(a.includes(b)).not.toBe(true);
  21. expect(a.includes(b)).toBe(false);
  22. expect(a.includes(b)).toEqual(true);
  23. expect(a.includes(b)).toStrictEqual(true);
  24. ```
  25. The following patterns are not considered warnings:
  26. ```js
  27. expect(a).toContain(b);
  28. expect(a).not.toContain(b);
  29. ```