title: Is it possible to stub out or spy on the setState method in React when doing unit tests?
body: <p>I have the following function in my component:</p>
  
  <pre><code>method(args) {
   fetch(args)
    .then((response) =&gt; {
      this.setState({
        element: response
        error: false
      });
    })
    .catch((error) =&gt; {
      this.setState({
        error: true
      });
    });
  }
  </code></pre>
  
  <p>I am trying to write a unit test for it so I have mocked out the fetch call using fetch-mock with a custom response. I want to check if the state was updated when this method is called and it doesn't seem to be working.  I am using enzyme, expect, and sinon and have been unsuccessful in getting the spy to be called when I set component.setState = sinon.spy or stubbing it out. How can I check to see if setState was called with certain elements or is my approach to unit testing this wrong?</p>