Last active
September 15, 2016 09:21
-
-
Save dmatteo/e082e5866761b737855c to your computer and use it in GitHub Desktop.
Testing a React.js component with `jsdomify` and `mocha`
This file contains hidden or 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 expect from 'unexpected'; | |
import jsdomify from 'jsdomify'; | |
describe('MyComponent', () => { | |
let React, TestUtils, getInstance, MyComponent; | |
before(() => { | |
jsdomify.create(); | |
React = require('react/addons'); | |
TestUtils = React.addons.TestUtils; | |
MyComponent = require('./MyComponent'); | |
getInstance = (props = {}) => { | |
return TestUtils.renderIntoDocument( | |
<MyComponent {...props} /> | |
); | |
}; | |
}); | |
after(() => { | |
jsdomify.destroy(); | |
}); | |
it('should render', () => { | |
const instance = getInstance(); | |
expect(instance, 'to be defined'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment