title: Jest async function always returns undefined, never resolves
body: <p>I'm using <code>axios</code> to fetch some user data from an API and push them into an array in a vanilla JS file like so:</p>
  <pre class="lang-js prettyprint-override"><code>export async function fetchUsernames() {
    let usernames = [];
    axios.get(&quot;https://jsonplaceholder.typicode.com/users&quot;).then((users) =&gt; {
      for (let user of users.data) {
        usernames.push(user[&quot;username&quot;]);
      }
      return usernames;
    });
  }
  </code></pre>
  <p>The problem is, even though it works correctly on my frontend when I hook it up with react, my <code>jest</code> test block always gets <code>undefined</code> as the return value, even though I use async/await. This is my test block:</p>
  <pre class="lang-js prettyprint-override"><code>test('Usernames get fetched properly', async () =&gt; {
    const usernames = await fetchUsernames();
    expect(usernames).toBe(expect.arrayContaining(['Brett']));
  });
  </code></pre>
  <p>This is the error message that I get:</p>
  <pre><code> × Usernames get fetched properly (17 ms)
  
    ● Usernames get fetched properly
  
      expect(received).toBe(expected) // Object.is equality
  
      Expected: ArrayContaining [&quot;Brett&quot;]
      Received: undefined
  
        12 | test('Usernames get fetched properly', async () =&gt; {
        13 |   const usernames = await fetchUsernames();
      &gt; 14 |   expect(usernames).toBe(expect.arrayContaining(['Brett']));
           |                     ^
        15 | });
  
        at Object.&lt;anonymous&gt; (src/App.test.js:14:21)
  
  Test Suites: 1 failed, 1 total
  Tests:       1 failed, 1 passed, 2 total
  Snapshots:   0 total
  Time:        4.038 s
  Ran all test suites related to changed files.
  </code></pre>
  <p>What could most likely be the cause behind this issue?</p>