Skip to content

Commit 6303566

Browse files
committed
fix(reporters): Fix results not being reported
Fix problems: * Not relying on Reporter.USE_COLORS property * Construct factory with right configuration
1 parent 287d0db commit 6303566

6 files changed

Lines changed: 21 additions & 6 deletions

File tree

lib/reporters/base.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ var BaseReporter = function (formatError, reportSlow, useColors, adapter) {
5151
if (!helper.isDefined(adapter.colors)) {
5252
adapter.colors = useColors
5353
}
54-
55-
if (adapter.colors === self.USE_COLORS) {
54+
if (!helper.isDefined(self.EXCLUSIVELY_USE_COLORS) || adapter.colors === self.EXCLUSIVELY_USE_COLORS) {
5655
return adapter(msg)
5756
}
5857
})
@@ -118,7 +117,7 @@ var BaseReporter = function (formatError, reportSlow, useColors, adapter) {
118117
}
119118

120119
this.USE_COLORS = false
121-
120+
this.EXCLUSIVELY_USE_COLORS = undefined
122121
this.LOG_SINGLE_BROWSER = '%s: %s\n'
123122
this.LOG_MULTI_BROWSER = '%s %s: %s\n'
124123

@@ -136,9 +135,9 @@ var BaseReporter = function (formatError, reportSlow, useColors, adapter) {
136135
this.TOTAL_FAILED = 'TOTAL: %d FAILED, %d SUCCESS\n'
137136
}
138137

139-
BaseReporter.decoratorFactory = function (formatError, reportSlow) {
138+
BaseReporter.decoratorFactory = function (formatError, reportSlow, useColors) {
140139
return function (self) {
141-
BaseReporter.call(self, formatError, reportSlow)
140+
BaseReporter.call(self, formatError, reportSlow, useColors)
142141
}
143142
}
144143

lib/reporters/dots.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var DotsReporter = function (formatError, reportSlow, useColors) {
44
BaseReporter.call(this, formatError, reportSlow, useColors)
55

66
var DOTS_WRAP = 80
7-
7+
this.EXCLUSIVELY_USE_COLORS = false
88
this.onRunStart = function () {
99
this._browsers = []
1010
this._dotsCount = 0

lib/reporters/dots_color.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var BaseColorReporter = require('./base_color')
44
var DotsColorReporter = function (formatError, reportSlow, useColors) {
55
DotsReporter.call(this, formatError, reportSlow, useColors)
66
BaseColorReporter.call(this)
7+
this.EXCLUSIVELY_USE_COLORS = true
78
}
89

910
// PUBLISH

lib/reporters/progress.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ var BaseReporter = require('./base')
33
var ProgressReporter = function (formatError, reportSlow, useColors) {
44
BaseReporter.call(this, formatError, reportSlow, useColors)
55

6+
this.EXCLUSIVELY_USE_COLORS = false
7+
68
this.writeCommonMsg = function (msg) {
79
this.write(this._remove() + msg + this._render())
810
}

lib/reporters/progress_color.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var BaseColorReporter = require('./base_color')
44
var ProgressColorReporter = function (formatError, reportSlow, useColors) {
55
ProgressReporter.call(this, formatError, reportSlow, useColors)
66
BaseColorReporter.call(this)
7+
this.EXCLUSIVELY_USE_COLORS = true
78
}
89

910
// PUBLISH

test/unit/reporters/base.spec.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ describe('reporter', function () {
3131
it('should omit adapters not using the right color', function () {
3232
var anotherAdapter = sinon.spy()
3333
anotherAdapter.colors = true
34+
reporter.EXCLUSIVELY_USE_COLORS = false
3435
reporter.adapters.push(anotherAdapter)
3536
reporter.write('some')
3637
expect(adapter).to.have.been.calledWith('some')
@@ -41,6 +42,7 @@ describe('reporter', function () {
4142
var reporter = new m.BaseReporter(null, null, true, adapter)
4243
var anotherAdapter = sinon.spy()
4344
reporter.adapters.push(anotherAdapter)
45+
reporter.EXCLUSIVELY_USE_COLORS = false
4446
reporter.write('some')
4547
expect(adapter).to.not.have.been.called
4648
return expect(anotherAdapter).to.not.have.been.called
@@ -50,12 +52,22 @@ describe('reporter', function () {
5052
var reporter = new m.BaseReporter(null, null, true, adapter)
5153
var anotherAdapter = sinon.spy()
5254
reporter.adapters.push(anotherAdapter)
55+
reporter.EXCLUSIVELY_USE_COLORS = false
5356
adapter.colors = false
5457
reporter.write('some')
5558
expect(adapter).to.have.been.calledWith('some')
5659
return expect(anotherAdapter).to.not.have.been.called
5760
})
5861

62+
it('should call all adapters if EXCLUSIVELY_USE_COLORS is undefined', function () {
63+
var anotherAdapter = sinon.spy()
64+
anotherAdapter.colors = true
65+
reporter.adapters.push(anotherAdapter)
66+
reporter.write('some')
67+
expect(adapter).to.have.been.calledWith('some')
68+
expect(anotherAdapter).to.have.been.calledWith('some')
69+
})
70+
5971
it('should format', function () {
6072
reporter.write('Success: %d Failure: %d', 10, 20)
6173

0 commit comments

Comments
 (0)