Skip to content

Commit

Permalink
feat: deprecate prefer-inline-snapshots rule
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed May 16, 2020
1 parent a67d92d commit 1360e9b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ installations requiring long-term consistency.
| [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()` | | |
| [prefer-hooks-on-top](docs/rules/prefer-hooks-on-top.md) | Suggest to have all hooks at top level | | |
| [prefer-inline-snapshots](docs/rules/prefer-inline-snapshots.md) | Suggest using inline snapshots | | ![fixable][] |
| [prefer-spy-on](docs/rules/prefer-spy-on.md) | Suggest using `jest.spyOn()` | | ![fixable][] |
| [prefer-strict-equal](docs/rules/prefer-strict-equal.md) | Suggest using toStrictEqual() | | ![fixable][] |
| [prefer-to-be-null](docs/rules/prefer-to-be-null.md) | Suggest using `toBeNull()` | ![style][] | ![fixable][] |
Expand Down
21 changes: 21 additions & 0 deletions docs/rules/prefer-inline-snapshots.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Suggest using inline snapshots (`prefer-inline-snapshots`)

## 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",
{
"toThrowErrorMatchingSnapshot": "Use `toThrowErrorMatchingInlineSnapshot()` instead",
"toMatchSnapshot": "Use `toMatchInlineSnapshot()` instead"
}
]
}
}
```

---

In order to make snapshot tests more managable and reviewable
`toMatchInlineSnapshot()` and `toThrowErrorMatchingInlineSnapshot` should be
used to write the snapshots inline in the test file.
Expand Down
2 changes: 2 additions & 0 deletions src/rules/prefer-inline-snapshots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export default createRule({
description: 'Suggest using inline snapshots',
recommended: false,
},
deprecated: true,
replacedBy: ['no-restricted-matchers'],
messages: {
toMatch: 'Use toMatchInlineSnapshot() instead',
toMatchError: 'Use toThrowErrorMatchingInlineSnapshot() instead',
Expand Down

0 comments on commit 1360e9b

Please sign in to comment.