Skip to content

Instantly share code, notes, and snippets.

@Nfinley
Created March 22, 2018 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nfinley/89bc208cd2db5b745161db4bd7cdbc31 to your computer and use it in GitHub Desktop.
Save Nfinley/89bc208cd2db5b745161db4bd7cdbc31 to your computer and use it in GitHub Desktop.
A jest snippet to test a component
import React from 'react';
import {shallow} from 'enzyme';
import $ComponentName$ from '$filepath$'
describe('$ComponentName$ Test', () => {
const props = {};
const wrapper = shallow(<$ComponentName$ {...props}/>);
describe('$ComponentName$ State Test', () => {
it('Should have the correct state', () => {
// Test state here
});
});
describe('$ComponentName$ Props Test', () => {
it('Should have the correct set of Props', () => {
// Test Props Here
});
});
describe('$ComponentName$ Actions Test', () => {
it('Should have the correct set of actions', () => {
// Test Actions Here
});
});
describe('$ComponentName$ Elements Test', () => {
it('Should contain two elements', () => {
expect(wrapper.find('element').length).toEqual(2);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment