Is it possible to use multiple reporters in the browser version of Mocha? I'm creating a reporter that sends test results to my server but I still want to use the default HTML reporter Mocha defaults to. Right now I'm modifying the source code to get this to work. I know Mocha uses commonJS for it's reporters too.
Generate multiple mocha reports in a single mocha execution. This is functionally the same as cypress-multi-reporters ; this is the ongoing fork.
mocha.run
returns a runner object which emits useful events such as 'test end'
and 'suite end'
. Therefore, we can do something like this:
mocha.run()
.on('test end', function(test) {
if ('passed' === test.state) {
console.log('passed!', test.title)
} else if (test.pending) {
console.log('pending!', test.title)
} else {
console.log('fail!', test.title)
let err = test.err
console.log(err)
}
// logic to collect results
})
.on('suite end', function(suite) {
if (suite.root) {
// logic to send collected results to server
}
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With