title: Jest testing Axios cancel request Issue with React
body: <p>In my code I am trying to cancel an axios request within my app, following the <a href="https://github.com/axios/axios#cancellation" rel="nofollow noreferrer">docs</a>. So there is no error on compiling the code and no errors in the console.</p>
  <p>However when I am trying to mock Axios in Jest and create a mock function and file with axios.js in the <strong>mock</strong> folder, In my test suite I get:</p>
  <pre><code>TypeError: Cannot read property 'source' of undefined
  </code></pre>
  <p>I have don the following in my app:</p>
  <pre><code> const cancelRequest = axios.CancelToken.source();
  
        search = query =&gt; {
        axios
          .get (`https://www.url.com?s=${query}` , {
          cancelToken: cancelRequest.token
          })
          .then (response =&gt; {
          this.setState ( {array: response.data.data, loading: false});
          })
          .catch (error =&gt; {
          console.log ('Error', error);
          });
        };
  
        componentWillUnmount() {
          cancelRequest.cancel();
        }
  </code></pre>
  <p>Any Idea's</p>