-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.test.tsx
41 lines (36 loc) · 991 Bytes
/
app.test.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import React from 'react';
import Component from './app';
import renderer from 'react-test-renderer';
import snapshotDiff from 'snapshot-diff';
// Ideal API (doesn't serialize)
test('Ideal', () => {
expect(<Component />).toMatchDiffSnapshot(<Component isError />);
})
/** this works but isn't as useful as desired */
test('vanilla toMatchSnapshot()', () => {
expect(
renderer
.create(<Component />)
.toJSON()
).toMatchSnapshot()
})
// works except for [object Object] for component
test('Using react-rest-render', () => {
expect(
renderer
.create(<Component />)
.toJSON()
).toMatchDiffSnapshot(renderer
.create(<Component isError />)
.toJSON());
})
// works except for [object Object] for component
test('using snapshotDiff() func', () => {
const treeA = renderer
.create(<Component />)
.toJSON()
const treeB = renderer
.create(<Component isError />)
.toJSON()
expect(snapshotDiff(treeA, treeB)).toMatchSnapshot()
})