diff --git a/README.md b/README.md index ed32c0834..ed5c4f158 100644 --- a/README.md +++ b/README.md @@ -152,7 +152,6 @@ installations requiring long-term consistency. | [no-test-callback](docs/rules/no-test-callback.md) | Avoid using a callback in asynchronous tests | ![recommended][] | ![suggest][] | | [no-test-prefixes](docs/rules/no-test-prefixes.md) | Use `.only` and `.skip` over `f` and `x` | ![recommended][] | ![fixable][] | | [no-test-return-statement](docs/rules/no-test-return-statement.md) | Disallow explicitly returning from tests | | | -| [no-try-expect](docs/rules/no-try-expect.md) | Prefer using toThrow for exception tests | ![recommended][] | | | [prefer-called-with](docs/rules/prefer-called-with.md) | Suggest using `toBeCalledWith()` OR `toHaveBeenCalledWith()` | | | | [prefer-expect-assertions](docs/rules/prefer-expect-assertions.md) | Suggest using `expect.assertions()` OR `expect.hasAssertions()` | | ![suggest][] | | [prefer-hooks-on-top](docs/rules/prefer-hooks-on-top.md) | Suggest to have all hooks at top level | | | diff --git a/docs/rules/no-try-expect.md b/docs/rules/no-try-expect.md index bbe980db8..cba9a937a 100644 --- a/docs/rules/no-try-expect.md +++ b/docs/rules/no-try-expect.md @@ -1,5 +1,12 @@ # Prevent catch assertions in tests (`no-try-expect`) +## Deprecated + +This rule has been deprecated in favor of +[`no-conditional-expect`](no-conditional-expect.md). + +--- + This rule prevents the use of `expect` inside `catch` blocks. ## Rule Details diff --git a/src/rules/no-try-expect.ts b/src/rules/no-try-expect.ts index b95c7f4e8..5cb528aa0 100644 --- a/src/rules/no-try-expect.ts +++ b/src/rules/no-try-expect.ts @@ -14,6 +14,8 @@ export default createRule({ category: 'Best Practices', recommended: false, }, + deprecated: true, + replacedBy: ['no-conditional-expect'], messages: { noTryExpect: [ 'Tests should use Jest‘s exception helpers.',