title: Jest - A worker process has failed to exit gracefully and has been force exited
body: <p>I have a test file called <code>integration.test.js</code></p>
  <pre><code>import app from &quot;../app&quot;;
  import request from &quot;supertest&quot;;
  
  describe(&quot;testing /users&quot;, () =&gt; {
    const app = request(app);
    // 5 test cases here. Both use app for api testing
  })
  
  describe(&quot;testing /images&quot;, () =&gt; {
    const app = request(app);
    // 6 test cases here. Both use app for api testing
  })
  
  describe(&quot;testing /blogs&quot;, () =&gt; {
    const app = request(app);
    // 7 test cases here. Both use app for api testing
  })
  </code></pre>
  <p>When I run <code>jest</code> to run the test cases, it returns a warning</p>
  <pre><code>A worker process has failed to exit gracefully and has been force exited. This is likely caused by tests leaking due to improper teardown. Try runn
  ing with --detectOpenHandles to find leaks. Active timers can also cause this, ensure that .unref() was called on them.
  </code></pre>
  <p>It also takes around 5 seconds to complete the testing, which seems to be slow<br/></p>
  <p>How can I fix the warning and the time of running the test cases?</p>
  <p>app.js</p>
  <pre><code>import express from &quot;express&quot;;
  
  const app = express();
  const PORT = process.env.PORT || 3000;
  
  app.use(express.json());
  
  app.get(&quot;/&quot;, (req, res) =&gt; {
    res.status(200).send(&quot;Hello&quot;);
  });
  
  app.post(&quot;/users&quot;, (req, res) =&gt; {...});
  app.post(&quot;/images&quot;, (req, res) =&gt; {...});
  app.post(&quot;/blogs&quot;, (req, res) =&gt; {...});
  
  
  app.listen(PORT, () =&gt; {
    console.log(`Server running on ${PORT}`);
  });
  
  export default app;
  </code></pre>