Skip to content

Commit

Permalink
fix(reporters): Fix results not being reported
Browse files Browse the repository at this point in the history
Fix problems:
 * Not relying on Reporter.USE_COLORS property
 * Construct factory with right configuration
  • Loading branch information
budde377 committed Feb 22, 2016
1 parent 287d0db commit 6303566
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 6 deletions.
9 changes: 4 additions & 5 deletions lib/reporters/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})
Expand Down Expand Up @@ -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'

Expand All @@ -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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/reporters/dots.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/reporters/dots_color.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions lib/reporters/progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down
1 change: 1 addition & 0 deletions lib/reporters/progress_color.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions test/unit/reporters/base.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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
Expand All @@ -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)

Expand Down

0 comments on commit 6303566

Please sign in to comment.