Created
April 4, 2017 12:33
-
-
Save 255kb/63c8d218c9c34e39c919fb4cdecce559 to your computer and use it in GitHub Desktop.
Mocha custom reporter
This file contains 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
var mocha = require('mocha'); | |
module.exports = MyReporter; | |
function MyReporter(runner) { | |
mocha.reporters.Base.call(this, runner); | |
var passes = 0; | |
var failures = 0; | |
runner.on('pass', function(test){ | |
passes++; | |
console.log('[pass]%s', test.title); | |
}); | |
runner.on('fail', function(test, err){ | |
failures++; | |
console.log('[fail]%s(%s)', test.title, err.message); | |
}); | |
runner.on('end', function(){ | |
console.log('end: %d/%d', passes, passes + failures); | |
process.exit(failures); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment