title: Connection not closed after test?
body: <p>I have a simple postgres.js wrapper file.</p>
  
  <pre><code>const pg =  require("pg")
  const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL });
  
  function close() {
    return pool.end()
  }
  
  module.exports = {
      end: pool.end,
      close
  };
  
  </code></pre>
  
  <p>Running a jest testcase that utilizes the postgres library above, like so:</p>
  
  <pre><code>const postgres = require("./path/to/postgres.js");
  
  describe("Foo", () =&gt; {
    afterAll(() =&gt; { 
      return postgres.end();
    })
  
    it(...)
  });
  </code></pre>
  
  <p>Will yield the "This usually means that there are asynchronous operations that weren't stopped in your tests." error message and hangs there.</p>
  
  <p>However, if I change the line <code>postgres.end()</code> to <code>postgres.close()</code>, it correctly closes the DB connection and jest terminates after the test is done.</p>
  
  <p>My question is that doesn't <code>close</code> and <code>end</code> functionally does the same thing? Why does one close the connection but the other doesn't?</p>