title: Mocha tests timeout if more than 4 tests are run at once
body: <p>I've got a node.js + express web server that I'm testing with Mocha. I start the web server within the test harness, and also connect to a mongodb to look for output:</p>
  
  <pre><code>describe("Api", function() {        
      before(function(done) {
          // start server using function exported from another js file
          // connect to mongo db
      });
  
      after(function(done) {
          // shut down server
          // close mongo connection
      });
  
      beforeEach(function(done) {
          // empty mongo collection
      });
  
      describe("Events", function() {    
          it("Test1", ...);
          it("Test2", ...);
          it("Test3", ...);
          it("Test4", ...);
          it("Test5", ...);
      });
  });
  </code></pre>
  
  <p>If Mocha runs more than 4 tests at a time, it times out:</p>
  
  <pre><code>4 passing (2s)
  1 failing
  
  1) Api Test5:
     Error: timeout of 2000ms exceeded
      at null.&lt;anonymous&gt; (C:\Users\&lt;username&gt;\AppData\Roaming\npm\node_modules\moch\lib\runnable.js:165:14)
      at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
  </code></pre>
  
  <p>If I skip <em>any</em> one of the 5 tests, it passes successfully. The same problem occurs if I reorder the tests (it's always the last one that times out). Splitting the tests into groups also doesn't change things.</p>
  
  <p>From poking at it, the request for the final test is being sent to the web server (using http module), but it's not being received by express. Some of the tests make one request, some more than one. It doesn't affect the outcome which ones I skip. I haven't been able to replicate this behaviour outside mocha.</p>
  
  <p>What on earth is going on?</p>