Skip to content

Instantly share code, notes, and snippets.

@deadlyicon deadlyicon/
Last active May 17, 2018

What would you like to do?
A subclass of the Spec reporter that prints the details of a test failure as soon as it fails

Customer Mocha Reporter

…that prints the details of the test failure error as soon as a test fails.

Why? I hate having to wait until my long test suite finishes to begin debugging why a test fails.

// ./test/mocha.opts
--reporter test/reporter.js
// ./test/reporter.js
'use strict'
const inherits = require('util').inherits
const { Base, Spec } = require('mocha').reporters
const Reporter = function(runner) {, runner)
runner.on('fail', function (test, error) {
inherits(Reporter, Spec)
exports = module.exports = Reporter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.