title: TypeError: moduleName.startsWith is not a function when mocking "axios"
body: <p>I'm trying to mock an axios get function but I'm getting <code>TypeError: moduleName.startsWith is not a function</code> when mocking &quot;axios&quot; What would be the right way to mock it?</p>
  <p>Error:</p>
  <pre class="lang-sh prettyprint-override"><code> FAIL  src/tests/Sample.test.jsx
    ● Test suite failed to run
  
      TypeError: moduleName.startsWith is not a function
  
         5 | import { backendUrl } from &quot;../helper/constants&quot;
         6 | describe(&quot;test useEffect and axios&quot;, () =&gt; {
      &gt;  7 |     const mockGet = jest.mock(axios.get)
  </code></pre>
  <p>Sample.test.jsx</p>
  <pre class="lang-js prettyprint-override"><code>import { mount } from &quot;enzyme&quot;
  import { screen, render, act } from &quot;@testing-library/react&quot;
  import Sample from &quot;../pages/Sample&quot;
  import axios from &quot;axios&quot;
  import { backendUrl } from &quot;../helper/constants&quot;
  describe(&quot;test useEffect and axios&quot;, () =&gt; {
      const mockGet = jest.mock(axios.get) // THROWS ERROR HERE
  
      let wrapper
      it(&quot;should call axios&quot;, async () =&gt; {
          await act(async () =&gt; {
              mockGet.mockImplementationOnce(() =&gt; Promise.resolve({}))
              wrapper = mount(&lt;Sample /&gt;)
          })
          wrapper.update()
          await expect(mockGet).toHaveBeenCalledWith(backendUrl)
      })
  })
  </code></pre>
  <p>Sample.jsx</p>
  <pre><code>import axios from &quot;axios&quot;
  import { useState, useEffect } from &quot;react&quot;
  import { backendUrl } from &quot;../helper/constants&quot;
  
  const Sample = () =&gt;{
      const [pets, setPets] = useState([])
      useEffect(() =&gt; axios.get(backendUrl)
      .then(({data}) =&gt;setPets(data.entries))
      .catch((err)=&gt;console.log(err)), [])
      return (
          &lt;&gt;
          &lt;p&gt;I h8 all of you&lt;/p&gt;
              {pets.map((e, i) =&gt;&lt;h2 key={i}&gt;{e.Link}&lt;/h2&gt;)}
          &lt;/&gt;
      )
  }
  
  export default Sample
  </code></pre>