Skip to content

Instantly share code, notes, and snippets.

@darekrossman
Last active November 18, 2016 21:09
Show Gist options
  • Save darekrossman/ce8132f4e7f5734c97665022cce78a55 to your computer and use it in GitHub Desktop.
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.
'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