title: Errors when trying to mock an async fetch function in Jest spec
body: <p>I'm writing tests for my app but running into problems when I try to mock an async fetch function. No matter what I try, I get:</p>
  
  <pre><code>asyncFetch.mockReturnValue is not a function
  </code></pre>
  
  <p>Which leads me to believe the function is not being mocked. However, I do not know where the problem lies.</p>
  
  <p>This is the test:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>import emailSignin from 'api/emailSignin';
  
  jest.mock('api/helpers/asyncFetch');
  
  describe('API Auth', () =&gt; {
    describe('login', () =&gt; {
      it('has a happy path', async () =&gt; {
        const asyncFetch = require('api/helpers/asyncFetch').default;
  
        asyncFetch.mockReturnValue({
          json: () =&gt; 'it worked',
        });
  
        const response = await emailSignin('bob', 'password');
        expect(response).toEqual('it worked');
      });
    });
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p>And this is the module I am trying to mock:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>import {
    ClientError,
    ServerError,
    ValidationError,
  } from 'api/helpers/errors';
  
  async function asyncFetch(url, requestConfig = {}) {
    const response = await fetch(url, requestConfig);
    const responseBody = await response.json();
    const { statusText, status } = response;
  
    switch (status) {
      case 400:
      case 401:
      case 403:
        throw new ClientError(statusText, status);
      case 422:
        throw new ValidationError(statusText, status, responseBody.errors);
      case 500:
      case 501:
      case 502:
      case 503:
      case 504:
      case 505:
        throw new ServerError(statusText, status);
      default:
        return response;
    }
  }
  
  export default asyncFetch;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Any help would be greatly appreciated!</p>