title: Simple Unit Testing NodeJS/Express
body: <p>Hi I am pretty new to NodeJs and I am trying to write my first tests.</p>
  
  <p>I am kind of stuck with the setup, so I was hoping for some help.</p>
  
  <p>I wrote these two functions:</p>
  
  <pre><code>app.js:
  
  var express = require('express')
    , cors = require('cors')
    , app = express();
  
  app.get('/a_nice_jsonp',cors(corsOptions), function(req, res, next){
    var result = parseCookies(req);
    res.jsonp(result);
  });
  
  app.get('',function(req,res,next){
    res.statusCode = 200;
    res.end()
  });
  </code></pre>
  
  <p>I do not export it as module as it is my only file.</p>
  
  <p>I assume it's pretty easy to write the tests for that. I started with something like this:</p>
  
  <pre><code>app-test.js:
  
  var expect = require('expect.js');
  var express = require('express');
  var expressApp = express();
  
  describe('app js test', function() {
    describe('GET /', function() {
      it('should respond to GET with empty path', function () {
        expressApp.get('', function(req, res, body){
          expect(res.status).to.equal(200);
        });
      })
    });
  });
  </code></pre>
  
  <p>I suppose it really reads like a simple task, but I seem to fail over the setup of the test and how to do it. </p>
  
  <p>Can anyone help me out here?</p>
  
  <p>EDIT: The above test runs fine. However, I have difficulties to test e.g. <code>.end()</code> as well as the <code>result</code> in the <code>jsonp request</code>. I simple do not know how to do it?!</p>