Mochawesome Reporter
Overview
Mochawesome is a very popular Mocha reporter and it works out of the box with Nightwatch as well, when Mocha is being used as a test runner.
Usage
1. Use Mocha as test runner in Nightwatch
In order to use Mocha in Nightwatch you need to set the test_runner
config property and set the type to mocha
. Custom options for Mocha can also be specified:
nightwatch.conf.js
{
// other settings...
test_runner: {
type : 'mocha',
options : {
ui : 'bdd',
reporter : 'list'
}
}
}
2. Install mochawesome from NPM
npm i mochawesome --save-dev
3. Pass the --reporter
argument
To use it as a reporter simply pass the --reporter mochawesome
argument as follows:
npx nightwatch examples/tests/ --reporter mochawesome
Configure reporter options
Mochawesome reporter options can be defined in main Nightwatch config under the reporterOptions
dictionary, inside the test_runner
:
nightwatch.conf.js
{
// ...
test_runner: {
type : 'mocha',
options : {
ui : 'bdd',
reporter : 'mochawesome',
reporterOptions: {
reporterDir: './output'
}
}
}
}