Hi I am pretty new to NodeJs and I am trying to write my first tests.
I am kind of stuck with the setup, so I was hoping for some help.
I wrote these two functions:
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()
});
I do not export it as module as it is my only file.
I assume it's pretty easy to write the tests for that. I started with something like this:
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 (req, res, body) {
expressApp.get('', function(){
expect(res.status).to.equal(200);
});
})
});
});
app.js as well as app-test.js are currently in the same folder.
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.
Can anyone help me out here?
Aucun commentaire:
Enregistrer un commentaire