title: Mocha, Express test error - "after all" hook error - Object function has no method 'close'
body: <p>Im just getting started with Mocha, testing against a very basic Express 4.0 rest API.</p>
  
  <pre><code>describe('API CALL UNIT TESTING', function(){
      var app = require('../../app');
      before(function(){
          app.listen(3000);
      });
  
      describe('GET', function(){
  
          it('respond with json', function(done){
              request(app)
                  .get('/api/compile')
                  .set('Accept', 'application/json')
                  .expect('Content-Type', 'application/json')
                  .expect(200, done)
                  .end(function(e, res){
                      //console.log(res)
                      done();
                  })
          })
      });
  
      after(function() {
          app.close();
      });
  });
  </code></pre>
  
  <p>Im getting the following error when running the test:</p>
  
  <blockquote>
    <p>1 passing (48ms)   1 failing</p>
    
    <p>1) API CALL UNIT TESTING "after all" hook:
         TypeError: Object function (req, res, next) {
        app.handle(req, res, next);   } has no method 'close'</p>
  </blockquote>
  
  <p>Can anyone advise what is causing the "after all" hook error?</p>