#980·mocha

Bug: Exception in a reporter silently crashes Mocha

Author: rassieCreated Sep 20, 2013Updated Sep 19, 2026
Labelstype: bugstatus: accepting prs

If a reporter raises an exception, Mocha just stops without any error message. An example reporter demonstrating the problem (needs a failing test in the suite):

module.exports = Crash;

var Spec = require('mocha/lib/reporters/spec');

function Crash(runner) {
    Spec.call(this, runner);

    runner.on('fail', function(test, err){
        throw new Error();
    });
}

Crash.prototype.__proto__ = Spec.prototype;