title: follow jest docs to mock axios but not working
body: <p>I flow the jest document to mock module 'axios'</p>
  
  <p>like this</p>
  
  <pre><code>// httpCall.js
  import axios from 'axios'
  export default function httpCall () {
    return axios.get('url/to/the/end/point').then(res =&gt; res.data)
  }
  </code></pre>
  
  <p>and my test file</p>
  
  <pre><code>import axios from 'axios'
  import httpCall from './index'
  jest.mock('axios')
  test('mock module axios', () =&gt; {
    const resp = { data: { id: 1, name: 'John Doe' } }
    axios.mockResolvedValue(resp)
    return httpCall().then(res =&gt; expect(res).toEqual(resp.data))
  })
  </code></pre>
  
  <p>and then got this error</p>
  
  <pre><code>TypeError: _axios.default.mockResolvedValue is not a function
  </code></pre>
  
  <p>so I try to google it, then try <a href="https://stackoverflow.com/questions/51393952/mock-inner-axios-create">Mock inner axios.create()</a></p>
  
  <p>create <strong>mocks</strong>/axios-mock.js</p>
  
  <pre><code>const mockAxios = jest.genMockFromModule('axios')
  mockAxios.create = jest.fn(() =&gt; mockAxios)
  export default mockAxios
  </code></pre>
  
  <p>then update my test file to this</p>
  
  <pre><code>import mockAxios from './__mocks__/axios-mock'
  import httpCall from './index'
  test('mock module axios', () =&gt; {
    const resp = { data: { id: 1, name: 'John Doe' } }
    mockAxios.get.mockResolvedValue(resp)
    return httpCall().then(res =&gt; expect(res).toEqual(resp.data))
  })
  </code></pre>
  
  <p>but still got error like below</p>
  
  <pre><code>Request failed with status code 404
  </code></pre>
  
  <p>I have no idea about this... but the end I make it working..</p>
  
  <p>this is my mock file</p>
  
  <pre><code>// __mocks__/axios-mock.js
  import axios from 'axios'
  const mockAxios = jest.genMockFromModule('axios')
  export default axios
  
  // or even like this
  import axios from 'axios'
  jest.mock('axios')
  export default axios
  </code></pre>
  
  <p>this is my test file</p>
  
  <pre><code>import httpCall from './index'
  import mockAxios from './__mocks__/axios-mock'
  
  describe('mock module', () =&gt; {
    it('axios should be mocked', () =&gt; {
      const resp = { data: { id: 1, name: 'John Doe' } }
      mockAxios.get = jest.fn().mockResolvedValue(resp)
      return httpCall().then(res =&gt; expect(res).toEqual(resp.data))
    })
  })
  </code></pre>
  
  <p>after it I try move the axios-mock code to test file like this below</p>
  
  <pre><code>import axios from 'axios'
  import httpCall from './index'
  const mockAxios = jest.genMockFromModule('axios')
  
  describe('mock module', () =&gt; {
    it('axios should be mocked', () =&gt; {
      const resp = { data: { id: 1, name: 'John Doe' } }
      mockAxios.get = jest.fn().mockResolvedValue(resp)
      return httpCall().then(res =&gt; expect(res).toEqual(resp.data))
    })
  })
  </code></pre>
  
  <p>I got this error again</p>
  
  <pre><code>Request failed with status code 404
  </code></pre>
  
  <p>this is my envinfo</p>
  
  <pre><code>System:
      OS: macOS 10.14
      CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
    Binaries:
      Node: 10.13.0 - ~/.nvm/versions/node/v10.13.0/bin/node
      Yarn: 1.7.0 - /usr/local/bin/yarn
      npm: 6.4.1 - ~/.nvm/versions/node/v10.13.0/bin/npm
    npmPackages:
      jest: ^23.6.0 =&gt; 23.6.0
  </code></pre>
  
  <p>my .babelrc</p>
  
  <pre><code>{
    "presets": [
      [
        "@babel/env",
        {
          "modules": "umd"
        }
      ]
    ]
  }
  </code></pre>
  
  <p>my jest.config.js</p>
  
  <pre><code>module.exports = {
  
  }
  </code></pre>
  
  <p>I hope someone can explain why this is the case</p>
  
  <p>and the <a href="https://jestjs.io/docs/en/mock-functions#mocking-modules" rel="nofollow noreferrer">jest mock module document</a> is really working ?</p>