From 49d0d57f759067438ae74e4d6800d76d0bd552f0 Mon Sep 17 00:00:00 2001 From: Ivo Pinheiro Date: Thu, 24 Jan 2019 23:30:33 +0000 Subject: [PATCH] Use reportOptions config as the second argument to report init Fix issue #153 --- lib/reporter/index.js | 4 ++-- lib/testee.js | 2 +- test/testee.test.js | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/reporter/index.js b/lib/reporter/index.js index 9267541..db049a4 100644 --- a/lib/reporter/index.js +++ b/lib/reporter/index.js @@ -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]; @@ -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 = []; diff --git a/lib/testee.js b/lib/testee.js index c08c58f..383d3b2 100644 --- a/lib/testee.js +++ b/lib/testee.js @@ -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 diff --git a/test/testee.test.js b/test/testee.test.js index 8680a8e..fc2fbbc 100644 --- a/test/testee.test.js +++ b/test/testee.test.js @@ -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) {