Skip to content

Commit

Permalink
docs(snapshot): specify how to disable prettier
Browse files Browse the repository at this point in the history
jestjs#7792 suggests that Prettier is optional, but I assumed that all I needed to do was remove `prettier` from my dependencies. That still results in Jest trying to require `prettier`, causing Jest to fail. Took awhile to learn I needed to set `prettierPath` to `null` or `''`, so I added this to the docs.
  • Loading branch information
connorjclark committed May 7, 2021
1 parent a2f1700 commit ca3f616
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/SnapshotTesting.md
Expand Up @@ -134,6 +134,8 @@ it('renders correctly', () => {

That's all there is to it! You can even update the snapshots with `--updateSnapshot` or using the `u` key in `--watch` mode.

By default, Jest uses Prettier to format inline snapshots. To disable this, set `prettierPath: null` in the config.

### Property Matchers

Often there are fields in the object you want to snapshot which are generated (like IDs and Dates). If you try to snapshot these objects, they will force the snapshot to fail on every run:
Expand Down

0 comments on commit ca3f616

Please sign in to comment.