For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves : <p>I have this test of nodejs when testing I get a error of done function not declared.</p>

<pre><code>Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
</code></pre>

<p>My test code is, I have the done call back but still getting the error to call the <code>done();</code></p>

<pre><code>    it('remove existing subdocument', (done) =&gt; {
    const Vic = new User({
      name: 'Vic',
      posts: [{ title: 'Leaning Nodejs' }]
    });

    vic.save()
      .then(() =&gt; User.findOne({ name: 'Vic' }))
      .then((user) =&gt; {
        const post = user.posts[0];
        post.remove();
        return user.save();
      })
      .then(() =&gt; User.findOne({ name: 'Vic' }))
      .then((user) =&gt; {
        assert(user.posts.length === 0);
        done();
      });
  });
</code></pre>
