Last active
March 25, 2016 11:00
-
-
Save CurtisHumphrey/641d72bff7eebc5bcc86 to your computer and use it in GitHub Desktop.
React Dump Component Standard Testing Patterns
This file contains 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
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