Newts Prefer MS-DOS

    spy-react-component-lifecycle

    0.2.0 • Public • Published

    spy-react-component-lifecycle

    Build Status

    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

    Install

    npm i spy-react-component-lifecycle

    DownloadsWeekly Downloads

    2

    Version

    0.2.0

    License

    MIT

    Last publish

    Collaborators

    • fraserxu