I suspect you're not actually calling test.done()
in that second test. Put a console.log()
call in there to verify you're actually making that call.
FWIW, I repro'd the described problem using a simplified version of your test, below. If you omit the on('error', function() {...})
handler, then the 2nd test fails to complete. Thus, my theory is that your /push
endpoint is triggering a different behavior in the restify module. I.e. are you sure restify is invoking your callback with an err
property there, or is it doing something different? ... like, for example, emitting an event like http.get
does, below.
var http = require('http');
exports.test1 = function (test) {
test.expect(1);
http.get({hostname: "www.broofa.com", path: "/"}, function (res) {
test.equal(res.statusCode, 200, 'got 200');
test.done();
});
};
exports.test2 = function (test) {
test.expect(1);
http.get({hostname: "www.no-such-domain.com", path: "/"}, function (res) {
test.equal(res.statusCode, 200, 'got 200');
test.done();
}).on('error', function() {
// Comment line below out to repro the "Undone tests" error
test.done();
});
};