File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -12,22 +12,37 @@ yarn add --dev snapshot-diff
12
12
## Usage
13
13
14
14
``` js
15
- const snapshotDiff = require (' snapshot-diff' );
15
+ const { snapshotDiff , toMatchDiffSnapshot } = require (' snapshot-diff' );
16
+
17
+ // register custom matcher (optional)
18
+ expect .extend ({ toMatchDiffSnapshot });
16
19
17
20
test (' snapshot difference between 2 strings' , () => {
21
+ // use default jest snapshot matcher
18
22
expect (snapshotDiff (a, b)).toMatchSnapshot ();
23
+
24
+ // or use custom diff snapshot matcher
25
+ expect (a).toMatchDiffSnapshot (b);
19
26
});
20
27
21
28
const React = require (' react' );
22
29
const Component = require (' ./Component' );
23
30
24
31
test (' snapshot difference between 2 React components state' , () => {
32
+ // use default jest matcher
25
33
expect (
26
34
snapshotDiff (
27
35
< Component test= " say" / > ,
28
36
< Component test= " my name" / >
29
37
)
30
38
).toMatchSnapshot ();
39
+
40
+ // or use custom diff snapshot matcher
41
+ expect (
42
+ < Component test= " say" / >
43
+ ).toMatchDiffSnapshot (
44
+ < Component test= " my name" / >
45
+ );
31
46
});
32
47
```
33
48
You can’t perform that action at this time.
0 commit comments