I'm writing a test script for my module and I need to be able to close my server when my request is done. The following code works but I can see that app.close() was dropped from express 3. What's the best way to do it now?
var testCase = require('nodeunit').testCase;
var request = require('request');
var express = require('express');
var app = express.createServer();
var srv = app.listen();
....
request({
method: 'POST',
json: true,
body: { id: 'second request'},
url: 'http://' + target
}, function(err, res, body) {
console.info("closing server");
app.close();
test.done();
});
});
Thanks, Li
p.s. test.done() must be called after closing the server, otherwise the test will fail.