jest: add react-test-renderer
This commit is contained in:
parent
7fe5d5ccbd
commit
61a5fed1bb
|
@ -40,8 +40,8 @@
|
||||||
transform: translate3d(0, 1px, 0);
|
transform: translate3d(0, 1px, 0);
|
||||||
background: linear-gradient(
|
background: linear-gradient(
|
||||||
to right,
|
to right,
|
||||||
rgba($base-c, 0.05) 25%,
|
mix($base-c, white, 5%) 25%,
|
||||||
rgba($base-c, 0));
|
white);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Line highlight ranges
|
// Line highlight ranges
|
||||||
|
|
32
jest.md
32
jest.md
|
@ -202,20 +202,36 @@ See: [Async tutorial](http://facebook.github.io/jest/docs/en/tutorial-async.html
|
||||||
### Snapshots
|
### Snapshots
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
const tree = renderer.create(
|
it('works', () => {
|
||||||
<Link page="http://www.facebook.com">Facebook</Link>
|
const output = something()
|
||||||
).toJSON()
|
expect(output).toMatchSnapshot()
|
||||||
|
})
|
||||||
```
|
```
|
||||||
|
{: data-line="3"}
|
||||||
|
|
||||||
|
First run creates a snapshot. Subsequent runs match the saved snapshot.
|
||||||
|
See: [Snapshot testing](http://facebook.github.io/jest/docs/en/snapshot-testing.html)
|
||||||
|
|
||||||
|
### React test renderer
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
// First run creates a snapshot; subsequent runs match it
|
import renderer from 'react-test-renderer'
|
||||||
expect(tree).toMatchSnapshot()
|
|
||||||
```
|
```
|
||||||
|
{: .-setup}
|
||||||
|
|
||||||
```bash
|
```jsx
|
||||||
# To update snapshots
|
it('works', () => {
|
||||||
jest --updateSnapshot
|
const tree = renderer.create(
|
||||||
|
<Link page="http://www.facebook.com">Facebook</Link>
|
||||||
|
).toJSON()
|
||||||
|
|
||||||
|
expect(tree).toMatchSnapshot()
|
||||||
|
})
|
||||||
```
|
```
|
||||||
|
{: data-line="2,3,4"}
|
||||||
|
|
||||||
|
React's test renderer can be used for Jest snapshots.
|
||||||
|
See: [Snapshot test](http://facebook.github.io/jest/docs/en/tutorial-react-native.html#snapshot-test)
|
||||||
|
|
||||||
### Mocks
|
### Mocks
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue