Skip to content

Commit

Permalink
feat: deprecate no-expect-resolves rule
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed May 16, 2020
1 parent 538e561 commit b6a22e5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 0 additions & 1 deletion README.md
Expand Up @@ -137,7 +137,6 @@ installations requiring long-term consistency.
| [no-deprecated-functions](docs/rules/no-deprecated-functions.md) | Disallow use of deprecated functions | | ![fixable][] |
| [no-disabled-tests](docs/rules/no-disabled-tests.md) | Disallow disabled tests | ![recommended][] | |
| [no-duplicate-hooks](docs/rules/no-duplicate-hooks.md) | Disallow duplicate setup and teardown hooks | | |
| [no-expect-resolves](docs/rules/no-expect-resolves.md) | Disallow expect.resolves | | |
| [no-export](docs/rules/no-export.md) | Prevent exporting from test files | ![recommended][] | |
| [no-focused-tests](docs/rules/no-focused-tests.md) | Disallow focused tests | ![recommended][] | ![fixable][] |
| [no-hooks](docs/rules/no-hooks.md) | Disallow setup and teardown hooks | | |
Expand Down
18 changes: 18 additions & 0 deletions docs/rules/no-expect-resolves.md
@@ -1,5 +1,23 @@
# Avoid using `expect().resolves` (`no-expect-resolves`)

## Deprecated

This rule has been deprecated in favor of
[`no-restricted-matchers`](no-restricted-matchers.md) with the following config:

```json
{
"rules": {
"jest/no-restricted-matchers": [
"error",
{ "resolves": "Use `expect(await promise)` instead." }
]
}
}
```

---

Jest allows you to test a promise resolve value using `await expect().resolves`.
For consistency and readability this rule bans `expect().resolves` in favor of
`expect(await promise)`.
Expand Down
2 changes: 2 additions & 0 deletions src/rules/no-expect-resolves.ts
Expand Up @@ -13,6 +13,8 @@ export default createRule({
description: 'Disallow expect.resolves',
recommended: false,
},
deprecated: true,
replacedBy: ['no-restricted-matchers'],
messages: {
expectResolves: 'Use `expect(await promise)` instead.',
},
Expand Down

0 comments on commit b6a22e5

Please sign in to comment.