Created
July 3, 2017 13:41
-
-
Save aofleejay/631a67e2d0db163b2dce40810887eb5f to your computer and use it in GitHub Desktop.
React Snapshot Testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import renderer from 'react-test-renderer' | |
import shallowRenderer from 'react-test-renderer/shallow' | |
import App from './App' | |
describe('Test app component', () => { | |
it('shallow snapshot', () => { | |
const renderer = new shallowRenderer | |
const snapshot = renderer.render(<App />) | |
expect(snapshot).toMatchSnapshot() | |
}) | |
it('full snapshot', () => { | |
const html = renderer.create(<App />).toJSON() | |
expect(html).toMatchSnapshot() | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment