From 63035662cf3484b189270d3b4d15762331012577 Mon Sep 17 00:00:00 2001 From: Christian Budde Christensen Date: Sat, 13 Feb 2016 14:34:17 +0100 Subject: [PATCH] fix(reporters): Fix results not being reported Fix problems: * Not relying on Reporter.USE_COLORS property * Construct factory with right configuration --- lib/reporters/base.js | 9 ++++----- lib/reporters/dots.js | 2 +- lib/reporters/dots_color.js | 1 + lib/reporters/progress.js | 2 ++ lib/reporters/progress_color.js | 1 + test/unit/reporters/base.spec.js | 12 ++++++++++++ 6 files changed, 21 insertions(+), 6 deletions(-) diff --git a/lib/reporters/base.js b/lib/reporters/base.js index 9aaefc612..28352c755 100644 --- a/lib/reporters/base.js +++ b/lib/reporters/base.js @@ -51,8 +51,7 @@ var BaseReporter = function (formatError, reportSlow, useColors, adapter) { if (!helper.isDefined(adapter.colors)) { adapter.colors = useColors } - - if (adapter.colors === self.USE_COLORS) { + if (!helper.isDefined(self.EXCLUSIVELY_USE_COLORS) || adapter.colors === self.EXCLUSIVELY_USE_COLORS) { return adapter(msg) } }) @@ -118,7 +117,7 @@ var BaseReporter = function (formatError, reportSlow, useColors, adapter) { } this.USE_COLORS = false - + this.EXCLUSIVELY_USE_COLORS = undefined this.LOG_SINGLE_BROWSER = '%s: %s\n' this.LOG_MULTI_BROWSER = '%s %s: %s\n' @@ -136,9 +135,9 @@ var BaseReporter = function (formatError, reportSlow, useColors, adapter) { this.TOTAL_FAILED = 'TOTAL: %d FAILED, %d SUCCESS\n' } -BaseReporter.decoratorFactory = function (formatError, reportSlow) { +BaseReporter.decoratorFactory = function (formatError, reportSlow, useColors) { return function (self) { - BaseReporter.call(self, formatError, reportSlow) + BaseReporter.call(self, formatError, reportSlow, useColors) } } diff --git a/lib/reporters/dots.js b/lib/reporters/dots.js index f06b094af..e4aac0515 100644 --- a/lib/reporters/dots.js +++ b/lib/reporters/dots.js @@ -4,7 +4,7 @@ var DotsReporter = function (formatError, reportSlow, useColors) { BaseReporter.call(this, formatError, reportSlow, useColors) var DOTS_WRAP = 80 - + this.EXCLUSIVELY_USE_COLORS = false this.onRunStart = function () { this._browsers = [] this._dotsCount = 0 diff --git a/lib/reporters/dots_color.js b/lib/reporters/dots_color.js index a583857ca..3da3ffdb3 100644 --- a/lib/reporters/dots_color.js +++ b/lib/reporters/dots_color.js @@ -4,6 +4,7 @@ var BaseColorReporter = require('./base_color') var DotsColorReporter = function (formatError, reportSlow, useColors) { DotsReporter.call(this, formatError, reportSlow, useColors) BaseColorReporter.call(this) + this.EXCLUSIVELY_USE_COLORS = true } // PUBLISH diff --git a/lib/reporters/progress.js b/lib/reporters/progress.js index 7a39d8053..a20a166b8 100644 --- a/lib/reporters/progress.js +++ b/lib/reporters/progress.js @@ -3,6 +3,8 @@ var BaseReporter = require('./base') var ProgressReporter = function (formatError, reportSlow, useColors) { BaseReporter.call(this, formatError, reportSlow, useColors) + this.EXCLUSIVELY_USE_COLORS = false + this.writeCommonMsg = function (msg) { this.write(this._remove() + msg + this._render()) } diff --git a/lib/reporters/progress_color.js b/lib/reporters/progress_color.js index b27f2e7eb..bd607fa7b 100644 --- a/lib/reporters/progress_color.js +++ b/lib/reporters/progress_color.js @@ -4,6 +4,7 @@ var BaseColorReporter = require('./base_color') var ProgressColorReporter = function (formatError, reportSlow, useColors) { ProgressReporter.call(this, formatError, reportSlow, useColors) BaseColorReporter.call(this) + this.EXCLUSIVELY_USE_COLORS = true } // PUBLISH diff --git a/test/unit/reporters/base.spec.js b/test/unit/reporters/base.spec.js index 367a457ce..e2c5dcd01 100644 --- a/test/unit/reporters/base.spec.js +++ b/test/unit/reporters/base.spec.js @@ -31,6 +31,7 @@ describe('reporter', function () { it('should omit adapters not using the right color', function () { var anotherAdapter = sinon.spy() anotherAdapter.colors = true + reporter.EXCLUSIVELY_USE_COLORS = false reporter.adapters.push(anotherAdapter) reporter.write('some') expect(adapter).to.have.been.calledWith('some') @@ -41,6 +42,7 @@ describe('reporter', function () { var reporter = new m.BaseReporter(null, null, true, adapter) var anotherAdapter = sinon.spy() reporter.adapters.push(anotherAdapter) + reporter.EXCLUSIVELY_USE_COLORS = false reporter.write('some') expect(adapter).to.not.have.been.called return expect(anotherAdapter).to.not.have.been.called @@ -50,12 +52,22 @@ describe('reporter', function () { var reporter = new m.BaseReporter(null, null, true, adapter) var anotherAdapter = sinon.spy() reporter.adapters.push(anotherAdapter) + reporter.EXCLUSIVELY_USE_COLORS = false adapter.colors = false reporter.write('some') expect(adapter).to.have.been.calledWith('some') return expect(anotherAdapter).to.not.have.been.called }) + it('should call all adapters if EXCLUSIVELY_USE_COLORS is undefined', function () { + var anotherAdapter = sinon.spy() + anotherAdapter.colors = true + reporter.adapters.push(anotherAdapter) + reporter.write('some') + expect(adapter).to.have.been.calledWith('some') + expect(anotherAdapter).to.have.been.calledWith('some') + }) + it('should format', function () { reporter.write('Success: %d Failure: %d', 10, 20)