Skip to content

Instantly share code, notes, and snippets.

@jvanderen1
Created December 1, 2019 20:39
Show Gist options
  • Save jvanderen1/5e619fc0d415eb30f15c643a888f88ea to your computer and use it in GitHub Desktop.
Save jvanderen1/5e619fc0d415eb30f15c643a888f88ea to your computer and use it in GitHub Desktop.
// Imports
// -------
// Libraries
import React from 'react';
import renderer from 'react-test-renderer';
// Components
import { MyComponent } from '.../My-Component';
// Mocks
// -----
jest.mock('...', () => '...');
// Internal
// --------
const defaultProps = {
...
};
//
const getComponent = (props) => renderer.create(
<MyComponent {...{ ...defaultProps, ...props }} />,
);
// Tests
// -----
describe('.../My-Component', () => {
let component;
describe('Rendering', () => {
it('renders default correctly', () => {
component = getComponent();
expect(component).toMatchSnapshot();
});
...
});
describe('Lifecycle', () => {
...
});
describe('Interaction', () => {
...
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment