title: Mocha Tests Are Timing Out
body: <p>I'm running Node.js 4.0 so it supports generators now.</p>
  
  <p>I've tried gulp-mocha-co and also recently removed that as well as upgraded to Node 4.0 since it supports generators now.</p>
  
  <p>Either way, as soon as I started to try to make my mocha tests generator friendly I get timeouts on all those tests after adding the * to make my mocha unit tests generators.  I noticed that it doesn't even run my test implementation code.  It gets to the *function() of my test and that's when it just sits and times out.</p>
  
  <p>I am using <a href="https://www.npmjs.com/package/gulp-mocha" rel="nofollow">gulp-mocha</a> right now.</p>
  
  <p><strong>myTests.js</strong></p>
  
  <pre><code>"use strict";
  
  var chai = require('chai'),
      should = chai.should(),
      testUtil = require('../../../test/testUtilities'),
      carUseCase = require('../../../src/usecases/carGet'),
      gateway= require('../../../test/gateway'),
      carRequestModel = require('../../../src/models/http/request/carRequest');
  
  describe('Get Car by Id', function() {
  
      it('should return no car when no cars exist', function*(done){
          var cars = [];
  
          inMemoryGateway.data(cars);
          carUseCase.gateway(gateway);
  
          var request = testUtil.createCarRequest();
          var responseModel = yield carUseCase.find(request);
          should.not.exist(responseModel.cars);
  
          var request = testUtil.createCarRequest(0, "", "", "");
          var responseModel = yield carUseCase.find(request);
          should.not.exist(responseModel.cars);
  
          done();
      });
  </code></pre>
  
  <p><strong>gulp.js</strong></p>
  
  <pre><code>var gulp = require('gulp'),
      mocha = require('gulp-mocha');
  
  ...
      gulp.task('mocha-unit', function() {
          process.env.PORT = 5001;
          return gulp.src([config.test.src.unit], { read: false })
              .pipe(mocha({
                  reporter: config.test.mocha.reporter,
                  ui: 'bdd'
              }))
      });
  </code></pre>
  
  <p><strong>carGet.js</strong></p>
  
  <pre><code>var car = require('../entities/car'),
      realGateway = require('../../src/gateways/carGateway'),
      carResponse = require('../../src/models/http/response/carResponse'),
      _gateway;
  
  module.exports = {
      find: function *(carRequest){
  
          carResponse.http.statusCode = 200;
  
          var entity = yield _gateway.find(carRequest.id);
  
          if(!entity.cars || entity.cars.length == 0){
              entity.cars = null;
              carResponse.http.statusCode = 204;
          }
  
          carResponse.cars = entity.cars;
  
          return carResponse;
      }
  };
  </code></pre>
  
  <p><strong>gatewayTestDouble.js</strong></p>
  
  <pre><code>'use strict';
  
  var _data;
  
  module.exports = {
      data: function(data){
          _data = data
      },
      find: function *(id) {
          var found = [];
  
          if(id == null &amp;&amp; hasData(_data)){
              yield _data;
              return;
          }
  
          if(!id &amp;&amp; !isPositiveNumber(id)){
              yield found;
              return;
          }
  
          if(isPositiveNumber(id) &amp;&amp; hasData(_data)) {
              for (var i = 0; i &lt; _data.length; i++) {
                  if (_data[i].id === id)
                      found.push(_data[i]);
              }
          }
  
          yield found;
      }
  };
  </code></pre>
  
  <p><strong>Error</strong></p>
  
  <pre><code>Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.
  </code></pre>