Last active
May 14, 2019 09:41
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In case anyone needs it, here's a jest reporter that we used