2020-05-15 05:33:08 +08:00
|
|
|
# Suggest using inline snapshots (`prefer-inline-snapshots`)
|
2020-03-07 11:45:40 +08:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
## Rule details
|
|
|
|
|
|
|
|
This rule triggers a warning if `toMatchSnapshot()` or
|
|
|
|
`toThrowErrorMatchingSnapshot` is used to capture a snapshot.
|
|
|
|
|
|
|
|
The following pattern is considered warning:
|
|
|
|
|
|
|
|
```js
|
|
|
|
expect(obj).toMatchSnapshot();
|
|
|
|
```
|
|
|
|
|
|
|
|
```js
|
|
|
|
expect(error).toThrowErrorMatchingSnapshot();
|
|
|
|
```
|
|
|
|
|
|
|
|
The following pattern is not warning:
|
|
|
|
|
|
|
|
```js
|
|
|
|
expect(obj).toMatchInlineSnapshot();
|
|
|
|
```
|
|
|
|
|
|
|
|
```js
|
|
|
|
expect(error).toThrowErrorMatchingInlineSnapshot();
|
|
|
|
```
|