Skip to content

Add note about snapshot diffing #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 13, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,27 @@ react components.

</details>

<details>

<summary>Why isn't snapshot diffing working?</summary>

If you use the
[snapshot-diff](https://github.com/jest-community/snapshot-diff)
library to save snapshot diffs, it won't work out of the box because
this library uses the DOM which is mutable. Changes don't return new
objects so snapshot-diff will think it's the same object and avoid diffing it.

Luckily there's an easy to way to make it work: clone the DOM when
passing it into snapshot-diff. It looks like this:

```js
const firstVersion = container.cloneNode(true);
// Do some changes
snapshotDiff(firstVersion, container.cloneNode(true));
```

</details>

## Other Solutions

In preparing this project,
Expand Down