title: Jest test fails for async function that calls another async function
body: <p>I am trying to test an async function that uses data returned by another async function. Here is the code to explain my problem:   </p>
  
  <p><code>StudentInfo.js</code></p>
  
  <pre><code>export async function getData() {
    //studentData imported from another file
    return new Promise(resolve =&gt; {
      setTimeout(() =&gt; {
        resolve(studentData);
      }, 5000);
    });
  }
  
  export async function filterStudents() {
    const studentData = await StudentInfo.getData();
  
    //computations
  
    return filteredData; //object
  }
  </code></pre>
  
  <p><code>StudentInfo.test.js</code>  </p>
  
  <pre><code>import * as studentInfo from "src/StudentInfo.js"
  
  describe("StudentInfo" , () =&gt; {
     test("student data correctly filtered", async () =&gt; {
        const studentData = [
           {
              name: Sarah Marshall,
              id: srhmar451
           },
           {...}
        ];
        expectedData = { [...], [...]};
        const spy = jest.spyOn(studentInfo, "getData");
        spy.mockReturnValue(studentData);
        await expect(studentInfo.filterStudents()).toEqual(expectedData);
     });
  });
  </code></pre>
  
  <p>My test fails because the expected return value is <code>Promise {}</code>. Could someone help me write a test for my <code>filterStudents()</code> function? I have been stuck at this for too long.</p>