title: Type of Axios mock using jest typescript
body: <p>I have the following method in a class:</p>
  
  <pre><code>import axios from 'axios'
  
  public async getData() {
     const resp = await axios.get(Endpoints.DATA.URL)
     return resp.data
  }
  </code></pre>
  
  <p>Then I am trying to set up a Jest test that does this:</p>
  
  <pre><code>jest.mock('axios')
  
  it('make api call to get data', () =&gt; {
     component.getData()
     expect(axios.get).toHaveBeenCalledWith(Endpoints.DATA.URL)
  })
  </code></pre>
  
  <p>The problem is that because I am not mocking the return value, then it gives an error for <code>resp.data</code> because I'm calling <code>data</code> on <code>null</code> or <code>undefined</code> object. I spent at least 2 hours trying various ways to get this working but I can't find a way such that I can mock <code>axios.get</code> with some return value.</p>
  
  <p>Jest's documentation uses JavaScript so they give this example <a href="https://jestjs.io/docs/en/mock-functions#mocking-modules" rel="noreferrer"><code>axios.get.mockResolvedValue(resp)</code></a> but I can't call <code>mockResolvedValue</code> because that method does not exist on <code>axios.get</code> in TypeScript.</p>
  
  <p>Also, if you know other good testing library for React other than Jest that does this stuff easily for TypeScript, feel free to share.</p>