Skip to content

Commit

Permalink
Use reportOptions config as the second argument to report init
Browse files Browse the repository at this point in the history
Fix issue bitovi#153
  • Loading branch information
ivospinheiro committed Jan 24, 2019
1 parent 614a3b2 commit 49d0d57
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/reporter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var testProperties = ['async', 'sync', 'timedOut', 'pending', 'file', 'duration'

// The reporter listens to service events and reports it to the command line using
// any of the Mocha reporters.
function Reporter(MochaReporter, coverage, root) {
function Reporter(MochaReporter, coverage, root, reporterOptions) {
if(typeof MochaReporter === 'string') {
if(mocha.reporters[MochaReporter]) {
MochaReporter = mocha.reporters[MochaReporter];
Expand All @@ -35,7 +35,7 @@ function Reporter(MochaReporter, coverage, root) {
// The actual (suite and test) objects we can feed to the Mocha runner
this._mochaObjects = {};
// The instantiated Mocha reporter
this.reporter = new MochaReporter(runner);
this.reporter = new MochaReporter(runner, {reporterOptions: reporterOptions});
// This is where we store errors so that we can report them all
// at once at the end
this.errors = [];
Expand Down
2 changes: 1 addition & 1 deletion lib/testee.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ _.extend(Testee.prototype, {

var self = this;
// We need to initialize the reporter first (in case of errors)
var reporter = new Reporter(this.options.reporter, this.options.coverage, this.options.root);
var reporter = new Reporter(this.options.reporter, this.options.coverage, this.options.root, this.options.reporterOptions);
// A deferred that runs the initialization flow
var flow = this.startServer()
// Sets up the reporter and binds Feathers service events to it
Expand Down
16 changes: 16 additions & 0 deletions test/testee.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@ describe('Testee', function () {
});
});

it('reporterOptions should be passed to reporter init', function (done) {
var reporterOptions = {
"junit_report_name": "Tests"
};

var _reporterOptions;
var _reporter = function(runner, options) {
_reporterOptions = options.reporterOptions;
};

testee.test(['examples/qunit/index.html'], browsers, Object.assign({}, config, {reporter: _reporter, reporterOptions: reporterOptions})).catch(function () {
assert.equal(reporterOptions, _reporterOptions);
done();
});
});

describe('QUnit example', function () {
it('socketio provider', function (done) {
testee.test(['examples/qunit/index.html'], browsers, config).catch(function (error) {
Expand Down

0 comments on commit 49d0d57

Please sign in to comment.