testing - Is supertest compatible with express.js 2.5.8? -
i using express.js version 2.5.8 (from legacy code) , looking test route loading using supertest. having issue server running, not stopping. run tests using jasmine-node
, indicates assertion succeeds. however, console shows process still running.
var request = require('supertest') , express = require('express'); describe('example test', function() { var app; beforeeach(function() { app = express.createserver(); app.configure(function() { app.set('port', process.env.port || 3000); app.use(express.logger('dev')); app.use(express.bodyparser()); app.use(express.methodoverride()); }); app.get('/', function(req, res){ res.send(200); }); }); it('index should homecoming 200', function(done) { request(app) .get('/') .expect(200) .end(function(err, res) { expect(err).tobe(null); done(); }); }); });
this illustration adapted 1 using express.js 3.x.x. assumption express server behaves differently, leading not closing when request terminates within test. uncertain how right issue.
the server still running because aren't closing anywhere. add together app.close()
end(function(){})
stop express server. if want exit node utilize process.exit()
.
testing express jasmine jasmine-node supertest
No comments:
Post a Comment