Skip to content

Wizcorp/mocha-reporter

Repository files navigation

mocha-reporter

Mocha reporter, enhanced.

Features

Log captures

Log capture screenshot

Capture stdout and stderr, and pretty-prints it only on error or when the DEBUG environment variable is set (like in the example above). This allows you to still leverage logging within your tests, or even add test-specific logs.

Pretty errors

Pretty errors

Thrown or returned errors will look much prettier now.

espower-loader

It looks even better when combined with espower-loader!

Installation

npm install --save mocha-reporter

Optionally, you may also add the following at the entrypoint of your test suite (it needs to be placed before any other Mocha-related calls):

require('mocha-reporter').hook()

This will add an extra line containing the file name and line number of the test upon error:

with file name

Finally, you may also set the DEBUG environment to true to view the log output of all tests, including the ones that passed.

DEBUG=true npm run test

debug

Usage

Under package.json:

{
  "scripts": {
    "test:unit": "mocha --reporter mocha-reporter"
  }
}

License

MIT