Skip to content

Instantly share code, notes, and snippets.

@maretekent
Created February 2, 2018 08:46
Show Gist options
  • Save maretekent/490165757f7f99ef428385c32d078028 to your computer and use it in GitHub Desktop.
Save maretekent/490165757f7f99ef428385c32d078028 to your computer and use it in GitHub Desktop.
node js server testing
var should = require('should');
var request = require('request');
var url = 'http://localhost:8080';
var HttpServer = require('./server').HttpServer;
var server;
describe('HttpServer', function () {
before(function (done) {
server = new HttpServer({port: 8080}).start(done);
});
after(function (done) {
server.stop(done);
});
it('should get root ok', function (done) {
request(url, function (error, response, body) {
response.statusCode.should.eql(200);
body.should.eql({ data: 'Some data'});
done();
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment