From c1eb236523f8dab7e5f7dc70f4ee016b8061f0ba Mon Sep 17 00:00:00 2001 From: Terry Date: Sat, 16 Jun 2018 00:00:39 +0800 Subject: [PATCH] fix(BaseReporter): log message correctly with just one browser (#3045) --- lib/reporters/base.js | 2 +- test/unit/reporters/base.spec.js | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/reporters/base.js b/lib/reporters/base.js index 40822cfef..d5227ef4a 100644 --- a/lib/reporters/base.js +++ b/lib/reporters/base.js @@ -136,7 +136,7 @@ const BaseReporter = function (formatError, reportSlow, useColors, browserConsol } this.onRunComplete = (browsers, results) => { - if (browsers.length > 1 && !results.error && !results.disconnected) { + if (browsers.length >= 1 && !results.error && !results.disconnected) { if (!results.failed) { this.write(this.TOTAL_SUCCESS, results.success) } else { diff --git a/test/unit/reporters/base.spec.js b/test/unit/reporters/base.spec.js index d1d6dbe3e..586cc913d 100644 --- a/test/unit/reporters/base.spec.js +++ b/test/unit/reporters/base.spec.js @@ -3,7 +3,7 @@ describe('reporter', () => { const BaseReporter = require('../../../lib/reporters/base') - describe('Progress', () => { + describe('Base', () => { let reporter let adapter = reporter = null @@ -181,7 +181,7 @@ describe('reporter', () => { return writeSpy.should.have.been.called }) - return it('should format log messages correctly for multi browsers', () => { + it('should format log messages correctly for multi browsers', () => { const writeSpy = sinon.spy(reporter, 'writeCommonMsg') reporter._browsers = ['Chrome', 'Firefox'] @@ -189,5 +189,13 @@ describe('reporter', () => { return expect(writeSpy).to.have.been.calledWith('Chrome LOG: Message\n') }) + + it('should log messages correctly when complete with just one browser', () => { + const writeSpy = sinon.spy(reporter, 'write') + const mockResults = {error: false, disconnected: false} + + reporter.onRunComplete(['Chrome'], mockResults) + return writeSpy.should.have.been.called + }) }) })