title: How to check the response from global fetch in JEST test case
body: <p>So, i am using jest for testing my node function which is calling  fetch() APi to get the data, now when I am writing the test cases for the same i am getting an error like :   </p>
  
  <pre><code>expect(received).resolves.toEqual()
  
      Matcher error: received value must be a promise
  
      Received has type:  function
      Received has value: [Function mockConstructor]
  </code></pre>
  
  <p>my function : </p>
  
  <pre><code> export function dataHandler (req, res, next) {
      const url= "someURL"
      if (url ) {
          return fetch(url )
              .then((response) =&gt; response.json())
              .then((response) =&gt; {
                  if (response.data) {
                      console.log(response);
                      res.redirect(somewhere`);
                  } else {
                      throw Error(response.statusText);
                  }
              })
              .catch((error) =&gt; {
                  next(error);
              });
      } 
  }
  </code></pre>
  
  <p>testcase : </p>
  
  <pre><code> it('check if fetch returning the response', async () =&gt; {
          // Setup
          const req = jest.fn(),
              res = { redirect: jest.fn() },
              next = jest.fn();
          global.fetch = jest.fn().mockImplementation(() =&gt; {
              return new Promise((resolve) =&gt;
                  resolve({
                      json: () =&gt; {
                          return { data: "hello"};
                      }
                  })
              );
          });
          await middlewares.dataHandler(req, res, next);
          //  Assert      
          expect(global.fetch).resolves.toEqual({ data: "hello" });
      });
  </code></pre>
  
  <p>Please be advised I am not using any mocking API, and would prefer not to. </p>
  
  <p>Can anyone help me with what's going wrong?</p>