Skip to content

Instantly share code, notes, and snippets.

@cucumbur
Last active May 14, 2019 09:41
Show Gist options
  • Save cucumbur/e2fc35792c1677b97f23d35205b98550 to your computer and use it in GitHub Desktop.
Save cucumbur/e2fc35792c1677b97f23d35205b98550 to your computer and use it in GitHub Desktop.
A simple hacky reporter I wrote for mocha & Detox that excludes 'excessive' technical information. Place it in the root directory and add --reporter simple-reporter to mocha.opts
// simple-reporter.js
var mocha = require('mocha')
module.exports = SimpleReporter
const trimregex = /[\s\S]+?(?=Hierarchy)/ // or /[\s\S]+?(?=Error Trace)/ or /[\s\S]+?(?=Exception)/ etc
function SimpleReporter (runner) {
mocha.reporters.Base.call(this, runner)
var passes = 0
var failures = 0
runner.on('pass', function (test) {
passes++
console.log('pass: %s', test.fullTitle())
})
runner.on('fail', function (test, err) {
failures++
let trimmedErr = trimregex.exec(err.message)
console.log('fail: %s -- error: %s', test.fullTitle(), trimmedErr)
})
runner.on('end', function () {
console.log('end: %d/%d', passes, passes + failures)
})
}
// To have this reporter "extend" a built-in reporter uncomment the following line:
// mocha.utils.inherits(SimpleReporter, mocha.reporters.Spec);
@sbycrosz
Copy link

In case anyone needs it, here's a jest reporter that we used

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment