Last active
November 18, 2016 21:09
-
-
Save darekrossman/ce8132f4e7f5734c97665022cce78a55 to your computer and use it in GitHub Desktop.
A snippet for scaffolding out a basic snapshot test with Jest. It uses a custom HOC to provide our mocked context.
This file contains hidden or 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
'Jest Snapshot Test': | |
'prefix': 'jst', | |
'body': ''' | |
import React from 'react'; | |
import renderer from 'react-test-renderer'; | |
import { withAppContext } from '_util/test-utils'; | |
import { default as Component } from '../$1'; | |
const WrappedComponent = withAppContext(Component); | |
describe('$1', () => { | |
const props = { | |
$2 | |
}; | |
it('matches the snapshot', () => { | |
const component = renderer.create( | |
<WrapedComponent { ...props } /> | |
); | |
let tree = component.toJSON(); | |
expect(tree).toMatchSnapshot(); | |
}); | |
}); | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment