I am doing some async testing with nodeunit and I was wondering whether it is possible to tell nodeunit to not terminate test cases until test.done is called.
Basically this is how my test cases looks like right now:
exports.basic = testCase({
setUp: function (callback) {
this.ws = new WrappedServer();
this.ws.run(PORT);
callback();
},
tearDown: function (callback) {
callback();
},
testFoo: function(test) {
var socket = ioClient.connect(URL);
socket.emit('PING', 1, 1);
socket.on('PONG', function() {
// do some assertion of course
test.done();
});
}
});
The problem now is that PONG is not sent back quick enough for the test code to be executed. Any ideas?
I just had a very similar problem, hence I was browsing this question. In my case the server (analogous to your WrappedServer) was throwing an exception, causing the test to exit abruptly without hitting my event handler with test.done(). I think it is rather rude of nodeunit to swallow the exception without a peep.
I had to resort to the debugger to find the problem, which if you haven't done before, I can save you a web search: node --debug-brk node_modules/nodeunit/bin/nodeunit your_nodeunit_test.js