title: Jest testing with Node - Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout
body: <p>I'm starting to test my code with Jest, and I can't make a seemingly simple test to pass. I am simply trying to check if what I receive from a Maogoose database request is an object.</p>
  
  <p>The function <code>fetchPosts()</code> is working because I hooked it up with a React frontend and it is displaying the data correctly. </p>
  
  <p>This is my function <code>fetchPosts()</code>:</p>
  
  <pre><code>module.exports = {
      fetchPosts() {
          return new Promise((resolve, reject) =&gt; {
              Posts.find({}).then(posts =&gt; {
                  if (posts) {
                      resolve(posts)
                  } else {
                      reject()
                  }
              })
          })
      }
  }
  </code></pre>
  
  <p>And my test:</p>
  
  <pre><code>it('should get a list of posts', function() {
      return posts.fetchPosts().then(result =&gt; {
          expect(typeof result).toBe('object')
      })
  })
  </code></pre>
  
  <p>This makes the test fail, and Jest says   </p>
  
  <p>'<strong>Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.</strong>'</p>
  
  <blockquote>
    <p>QUESTION: How can I make this test pass?</p>
  </blockquote>