title: Can't stop express server in after function
body: <p>I have Node tests with this <code>before</code> function:</p>
  
  <pre><code>before((done) =&gt; {
    app.startServer()
      .catch((err) =&gt; {
        done(err);
    });
  });
  </code></pre>
  
  <p>I'm now trying to write an <code>after</code> function which will stop the server.</p>
  
  <p>I had hoped this could be:</p>
  
  <pre><code>after(() =&gt; {
    app.stopServer(apiAddress)
      .catch((err) =&gt; {
        done(err);
      })
  });
  </code></pre>
  
  <p>but that doesn't work.</p>
  
  <p>These are my <code>express.js</code> functions:</p>
  
  <pre><code>function startServer() {
    return new Promise((resolve, reject) =&gt; {
      app.listen(PORT, (err) =&gt; {
        if (err) reject(err);
        log.info(`Server listening on port ${PORT}`);
        resolve();
      });
    });
  }
  
  function stopServer(url) {
    return new Promise((resolve, reject) =&gt; {
      //const server = app.listen(url);
      app.close(url, (err) =&gt; {
        if (err) reject(err);
        log.info(`Server closed on ${url}`);
        resolve();
      });
    });
  }
  </code></pre>
  
  <p>How do I stop my <code>express</code> server in an after function?</p>