I'd like to be able to extend the mocha test results and listen to them from the available mocha object. First, I'm looking at getting the "passes" results.
It looks like they might be subscribed to from suite but I'm not sure how...
I've tried the following which I thought would listen to the end of all of my tests:
var suite = mocha.suite.suites[0];
suite.on("end", function(e){ console.log(e, "mocha - heard the end of my test suite"); } );
My simple hack which works but isn't elegant at all - sad really:
setTimeout(function(){
var passes = $(".passes").find("em").text();
console.log("ui - heard the end of my test suite - passes: " + passes);
}, 500);
I did some more digging in mocha.js and finally discovered that mocha.run() actually returns the runner which emits all the events I was looking.
The original example I was using only had: mocha.run()
So if Mocha.run() returns a runner, then I realized that I could subscribe to it:
much better!
You can also get similar events at