title: How can I disable a jest mock for a particular test?
body: <p>I have created a working Mock for Axios:</p>
  <pre class="lang-js prettyprint-override"><code>// __mocks__/axios.js
  // Based on https://jestjs.io/docs/manual-mocks
  
  const axios = jest.createMockFromModule(&quot;axios&quot;);
  const log = console.log.bind(console);
  
  axios.create = () =&gt; {
    log(`Running axios.create`);
    return {
      get: () =&gt; {
        log(`Running get`);
        return {
          status: 500,
          statusText: &quot;Internal Server Error&quot;,
          body: {
            onFire: &quot;Mock API response from mock axios module&quot;,
          },
        };
      },
    };
  };
  
  module.exports = axios;
  </code></pre>
  <p>This works fine in my tests - the mock is loaded automatically and the 'throws an error' test works:</p>
  <pre class="lang-js prettyprint-override"><code>describe(`getLatestPrice`, () =&gt; {
    it(`throws an error when the response is bad`, async () =&gt; {
      expect(() =&gt; {
        log(`Should throw`);
        return getLatestPrice(assetCode);
      }).toThrow();
    });
  
    it(`gets a single price by stream code`, async () =&gt; {
      // Disabling the mock isn't working
      jest.unmock(&quot;axios&quot;);
      const price = await getLatestPrice(assetCode);
      log(`price`, price);
      expect(price).toEqual({
        ...
      });
    });
  })
  </code></pre>
  <p>However the second test - which calls <code>jest.unmock()</code> - still uses the mocked library.</p>
  <p><strong>How can I disable mocking for a single test?</strong></p>
  <p>Update: reading <a href="https://github.com/facebook/jest/issues/2649" rel="nofollow noreferrer">https://github.com/facebook/jest/issues/2649</a> I've also tried using <code>requireActual()</code> to override the mock:</p>
  <pre class="lang-js prettyprint-override"><code>const actualAxios = jest.requireActual(&quot;axios&quot;);
  const mockAxios = require(&quot;axios&quot;);
  mockAxios.create = actualAxios.create;
  </code></pre>
  <p>But calls to <code>axios.create()</code> still invole the mock.</p>