Let me take an example.
before(function (done)
{
...
testUtils.someInitWork(done);
});
testUtils = {
someInitWork: function (done)
{
...
if (e)
// wrap the error into another error object and add contextual information.
e2 = errorManager.getError('myerror', e, { context: "more context for the error });
}
};
when test initialization code fails deep down a util function, it passes required contextual information into the error object. This error object is passed to before's done callback eventually. mocha prints the error message on console (I am using reporter spec). Instead if I can get it to print util.inspect(e)
- that information will be more useful to debug the issue.
Of course, I can modify the test code to print it. but is there a way to modify how mocha reports the error (passed to before callback) on console?