title: How to test Express.js routes with Jasmine 2.3 and SuperTest
body: <p>I'm using <a href="http://jasmine.github.io/" rel="noreferrer">Jasmine</a> <code>2.3</code> installed via NPM and executed with Grunt.</p>
  
  <pre><code>'use strict';
  
  module.exports = function(grunt) {
      grunt.initConfig({
          package: grunt.file.readJSON('package.json'),
          exec: {
              jasmine: 'node_modules/.bin/jasmine'
          }
      });
      require('load-grunt-tasks')(grunt);
      require('time-grunt')(grunt);
      grunt.registerTask('default', 'exec:jasmine');
  };
  </code></pre>
  
  <p>I exported an Express.js application object and using it in my specs along with SuperTest.</p>
  
  <pre><code>'use strict';
  
  var supertest = require('supertest')
  var application = require('../../../../../server');
  
  describe('GET /api/users', function() {
      it('should respond with json', function(done) {
          supertest(application)
              .get('/api/users')
              .set('Accept', 'application/json')
              .expect('Content-Type', /json/)
              .expect(200, done);
      });
  });
  </code></pre>
  
  <p>When I run the spec I get no errors even though a <code>200</code> status code was expected and <code>404</code> was the result. Is the problem in Jasmine or SuperTest, or maybe I should be using <a href="https://github.com/visionmedia/superagent" rel="noreferrer">SuperAgent</a>.</p>
  
  <p>I have no routes setup just a <code>404</code> error handler setup on the Express application object.</p>
  
  <pre><code>application.use(function(request, response, next) {
      response
          .status(404)
          .send({
              message: 'not found'
          });
  });
  </code></pre>