I have an endpoint that runs mocha tests and I want to get the output of those tests and send it back to the client. Right now, I have:
exports.testApi = function (req, res) {
var mocha = new Mocha();
mocha.addFile('server/api/user/user.spec');
// I want to get the output of mocha.run
mocha.run(function (failures) {
console.log('failures: ' + failures);
return res.status(200).json({}});
})
};
I've looked around and I can't seem to grasp how to use stdout to get the results on the console...