spy-react-component-lifecycle
v0.2.0
Published
spy-react-component-lifecycle
Downloads
7
Readme
spy-react-component-lifecycle
A separate module for spy react component lifecycle, code from enzyme which is deprecated at v2.0.0
Install
$ npm install spy-react-component-lifecycle --save-dev
Usage
Go and check test.js
.
var Foo = React.createClass({
componentDidMount: noop,
render: function render () {
return React.createElement('div', null, 'foo')
}
})
test('Componenet life cycle', function (assert) {
withDom()
spyLifeCycle(Foo)
var container = window.document.createElement('div')
ReactDOM.render(React.createElement(Foo), container)
assert.true(Foo.prototype.componentDidMount.calledOnce, 'calls componentDidMount once')
assert.end()
})
Notes: Sincejsdom 7.x onward only works on Node.js 4 or newer, the test may only work for Node.js 4 or newer.
License
MIT