Skip to content

Commit

Permalink
Added documentation related to issue #1820
Browse files Browse the repository at this point in the history
  • Loading branch information
javidjamae committed Jan 29, 2018
1 parent 4ea7273 commit 3be77c2
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions addons/storyshots/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,30 @@ Now run your Jest test command. (Usually, `npm test`.) Then you can see all of y
![Screenshot](docs/storyshots.png)


### Using `createNodeMock` to mock refs

`react-test-renderer` doesn't provide refs for rendered components. By
default, it returns null when the refs are referenced. In order to mock
out elements that rely on refs, you will have to use the
`createNodeMock` option [added to React](https://reactjs.org/blog/2016/11/16/react-v15.4.0.html#mocking-refs-for-snapshot-testing) starting with version 15.4.0.

Here is an example of how to specify the `createNodeMock` option in Storyshots:

```js
import initStoryshots, { snapshotWithOptions } from '@storybook/addon-storyshots'
import TextareaThatUsesRefs from '../component/TextareaThatUsesRefs'

initStoryshots({
test: snapshotWithOptions({
createNodeMock: (element) => {
if (element.type === TextareaThatUsesRefs) {
return document.createElement('textarea')
}
},
}),
})
```

## Configure Storyshots for image snapshots ( alpha )

/*\ **React-native** is **not supported** by this test function.
Expand Down

0 comments on commit 3be77c2

Please sign in to comment.