title: How to setup mocha to run unit tests first and then start a server and run integration tests
body: <p>I have unit tests and integration tests that need to be run with one 'npm run mocha' command. The suite before my integration tests was set up and working properly with mocha.opts including the before step like so:</p>
  
  <pre><code>test/beforeTests.js (sets up some important variables)
  test/*.x.js (bulk of the tests, all the files ending in .x.js are run)
  </code></pre>
  
  <p>When including my integrations tests, a unit test fails because the running server clashes with some stubbed functions. Therefore I wanted to run unit tests first, then star the server, run integration tests and close the server. Which I have tried by changing mocha.opts to:</p>
  
  <pre><code>test/beforeTests.js (sets up some important variables)
  test/*.x.js (bulk of the tests, all the files ending in .x.js are run)
  test/startServer.js (start the server)
  test/integration/*.x.js (run integration tests)
  test/afterTests.js (close the server)
  </code></pre>
  
  <p>beforeTests.js:</p>
  
  <pre><code>before(function(done) { 
   // do something 
  });
  </code></pre>
  
  <p>startServer.js:</p>
  
  <pre><code>before(function() {
   return runServer()
  });
  </code></pre>
  
  <p>both beforeTests, and startServer work however they are both executed in the beginning of the test instead of</p>
  
  <p><code>beforeTest &gt; do unit tests &gt; start server &gt; do integration tests &gt; stop server</code></p>
  
  <p>I cannot merge the integration tests in one file, or the unit tests as there are too many. Is there a way to set up mocha.opts to do what I want. I've looked around and nothing really fits what I want to do.</p>