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.

47 lines
969 B

  1. # Avoid using `expect().resolves` (`no-expect-resolves`)
  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. { "resolves": "Use `expect(await promise)` instead." }
  11. ]
  12. }
  13. }
  14. ```
  15. ---
  16. Jest allows you to test a promise resolve value using `await expect().resolves`.
  17. For consistency and readability this rule bans `expect().resolves` in favor of
  18. `expect(await promise)`.
  19. ## Rule details
  20. This rule triggers a warning if `expect().resolves` is used.
  21. This rule is disabled by default.
  22. ### Default configuration
  23. The following patterns is considered warning:
  24. ```js
  25. test('some test', async () => {
  26. await expect(Promise.resolve(1)).resolves.toBe(1);
  27. });
  28. ```
  29. The following pattern is not considered warning:
  30. ```js
  31. test('some test', async () => {
  32. expect(await Promise.resolve(1)).toBe(1);
  33. });
  34. ```