Skip to content

Instantly share code, notes, and snippets.

@CurtisHumphrey
Last active March 25, 2016 11:00
Show Gist options
  • Save CurtisHumphrey/641d72bff7eebc5bcc86 to your computer and use it in GitHub Desktop.
Save CurtisHumphrey/641d72bff7eebc5bcc86 to your computer and use it in GitHub Desktop.
React Dump Component Standard Testing Patterns
import React from 'react'
import {
shallow
} from 'enzyme'
describe('<DumbComponent />', () => {
let sandbox
let props
beforeEach(() => {
sandbox = sinon.sandbox.create()
// Makes propTypes mismatches fail tests
sandbox.stub(console, 'error', (message) => {
throw new Error(message)
})
props = {}
})
afterEach(() => {
sandbox.restore()
})
it('with normal props it should render without errors', () => {
const wrapper = shallow(<DumbComponent {...props} />)
expect(wrapper).to.exist
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment