File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -687,6 +687,27 @@ react components.
687687
688688</details >
689689
690+ <details >
691+
692+ <summary >Why isn ' t snapshot diffing working?</summary>
693+
694+ If you use the
695+ [snapshot -diff ](https : // github.com/jest-community/snapshot-diff)
696+ library to save snapshot diffs , it won ' t work out of the box because
697+ this library uses the DOM which is mutable. Changes don ' t return new
698+ objects so snapshot -diff will think it ' s the same object and avoid diffing it.
699+
700+ Luckily there ' s an easy to way to make it work: clone the DOM when
701+ passing it into snapshot -diff. It looks like this :
702+
703+ ` ` ` js
704+ const firstVersion = container.cloneNode(true);
705+ // Do some changes
706+ snapshotDiff(firstVersion, container.cloneNode(true));
707+ ` ` `
708+
709+ </details >
710+
690711## Other Solutions
691712
692713In preparing this project ,
You can’t perform that action at this time.
0 commit comments