Skip to content

Instantly share code, notes, and snippets.

@patkujawa-wf
Created May 20, 2014 18:48
Show Gist options
  • Save patkujawa-wf/b16350d6d5f3f22a70ce to your computer and use it in GitHub Desktop.
Save patkujawa-wf/b16350d6d5f3f22a70ce to your computer and use it in GitHub Desktop.
Idea for a 'tee' reporter to allow multiple reporters in mocha
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