title: How to spy on setState and test toHaveBeenCalled() using jest
body: <p>Using Jest and React, How do I spy one <code>this.setState()</code> and test weather the function <code>hasBeenCalled()</code></p>
  
  <pre><code>it('shall update targets when engine register has been called', () =&gt; 
  {
    const wrapper = shallow(
      &lt;LazyloadProvider&gt;
        &lt;p&gt;Wow&lt;/p&gt;
      &lt;/LazyloadProvider&gt;
    ).instance();
    expect(wrapper.state.targets).toEqual({}); // pass
    wrapper.engine.register(FIXTURE.REACT_REF); // pass
    expect(wrapper.state.targets).not.toEqual({}); //pass
    expect(wrapper.setState).toHaveBeenCalled(); // fail
  });
  </code></pre>
  
  <p><strong>Engine Getter:</strong></p>
  
  <pre><code>  get engine() {
      return {
        state: this.state,
        register: target =&gt; {
          this.setState(LazyloadUtils.registerOneTarget(target));
        },
      };
    }
  </code></pre>