Created
May 20, 2014 18:48
-
-
Save patkujawa-wf/b16350d6d5f3f22a70ce to your computer and use it in GitHub Desktop.
Idea for a 'tee' reporter to allow multiple reporters in mocha
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
define(function() { | |
'use strict'; | |
/** | |
* Create a 'tee' reporter that just pipes to wrapped reporters. | |
* Usage: mocha.setup({ reporter: MochaTeeReporter(Reporter1, Rep2, Rep3, ...) }); | |
* @return {Reporter} Suitable for mocha usage | |
*/ | |
return function(/* reporters */) { | |
var reporterCtors = [].slice.call(arguments); | |
var reporters = []; | |
return function MochaTeeReporter(runner) { | |
reporterCtors.forEach(function (Ctor) { | |
// The problem is that there is only one runner and reporters | |
// are expected to mutate its 'stats' property | |
reporters.push(new Ctor(runner)); | |
}); | |
}; | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment