A typical test in my node.js mocha suite looks like the following:
it(\"; client should do something\", function(done) {
var doneFn = function(args) {
You should to listen to uncaughtException
events, in addition to someEvent
. This way you'll catch errors happening in client, and those will show up in your test report.
it("; client should do something", function(done) {
var doneFn = function(args) {
// run a bunch of asserts on args
client.events.removeListener(client.events.someEvent, userMuteFn);
done();
}
var failedFn = function(err) {
client.events.removeListener('uncaughtException', failedFn);
// propagate client error
done(err);
}
client.events.on(someEvent, doneFn);
client.events.on('uncaughtException', failedFn);
client.triggerEvent();
});
P.S. In case client
is a child process, you also should listen to exit
event, which will be triggered in case the child process dies.