From 316b944d2ee7b1c9d011472dc41f149f92e88f26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Go=C5=82e=CC=A8biowski?= Date: Wed, 26 Apr 2017 12:34:16 +0200 Subject: [PATCH] fix(reporters): Revert the backwards-incompatible log priority order changes Commit 35965d9 changed the order of log priorities, making lots of configurations no longer print console.log messages. This was a backwards-incompatible change which this commit reverts. Tests were added to ensure the proper order is respected. Fixes #2582 --- lib/constants.js | 4 +-- test/e2e/browser_console.feature | 5 +-- test/unit/reporters/base.spec.js | 58 ++++++++++++++++++++++++++++++-- 3 files changed, 58 insertions(+), 9 deletions(-) diff --git a/lib/constants.js b/lib/constants.js index 15da4dc0d..d815ac379 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -20,9 +20,9 @@ exports.LOG_PRIORITIES = [ exports.LOG_DISABLE, exports.LOG_ERROR, exports.LOG_WARN, + exports.LOG_LOG, exports.LOG_INFO, - exports.LOG_DEBUG, - exports.LOG_LOG + exports.LOG_DEBUG ] // Default patterns for the pattern layout. diff --git a/test/e2e/browser_console.feature b/test/e2e/browser_console.feature index 53a83ac8e..36578b4e2 100644 --- a/test/e2e/browser_console.feature +++ b/test/e2e/browser_console.feature @@ -11,10 +11,7 @@ Feature: Browser Console Configuration plugins = [ 'karma-jasmine', 'karma-phantomjs-launcher' - ], - browserConsoleLogOptions = { - level: 'log' - }; + ]; """ When I start Karma Then it passes with like: diff --git a/test/unit/reporters/base.spec.js b/test/unit/reporters/base.spec.js index 291e5f4f0..ed75037ad 100644 --- a/test/unit/reporters/base.spec.js +++ b/test/unit/reporters/base.spec.js @@ -103,6 +103,19 @@ describe('reporter', function () { }, adapter) var writeSpy = sinon.spy(reporter, 'writeCommonMsg') + reporter._browsers = ['Chrome'] + reporter.onBrowserLog('Chrome', 'Message', 'LOG') + + return writeSpy.should.have.not.been.called + }) + + it('should not log if lower priority than browserConsoleLogOptions "log"', function () { + var reporter = new m.BaseReporter(null, null, true, { + level: 'log', + terminal: true + }, adapter) + var writeSpy = sinon.spy(reporter, 'writeCommonMsg') + reporter._browsers = ['Chrome'] reporter.onBrowserLog('Chrome', 'Message', 'INFO') @@ -122,9 +135,35 @@ describe('reporter', function () { return writeSpy.should.have.not.been.called }) - it('should not log if lower priority than browserConsoleLogOptions "debug"', function () { + it('should log if higher priority than browserConsoleLogOptions "warn"', function () { var reporter = new m.BaseReporter(null, null, true, { - level: 'debug', + level: 'warn', + terminal: true + }, adapter) + var writeSpy = sinon.spy(reporter, 'writeCommonMsg') + + reporter._browsers = ['Chrome'] + reporter.onBrowserLog('Chrome', 'Message', 'ERROR') + + return writeSpy.should.have.been.called + }) + + it('should log if higher priority than browserConsoleLogOptions "log"', function () { + var reporter = new m.BaseReporter(null, null, true, { + level: 'log', + terminal: true + }, adapter) + var writeSpy = sinon.spy(reporter, 'writeCommonMsg') + + reporter._browsers = ['Chrome'] + reporter.onBrowserLog('Chrome', 'Message', 'WARN') + + return writeSpy.should.have.been.called + }) + + it('should log if higher priority than browserConsoleLogOptions "info"', function () { + var reporter = new m.BaseReporter(null, null, true, { + level: 'info', terminal: true }, adapter) var writeSpy = sinon.spy(reporter, 'writeCommonMsg') @@ -132,7 +171,20 @@ describe('reporter', function () { reporter._browsers = ['Chrome'] reporter.onBrowserLog('Chrome', 'Message', 'LOG') - return writeSpy.should.have.not.been.called + return writeSpy.should.have.been.called + }) + + it('should log if higher priority than browserConsoleLogOptions "debug"', function () { + var reporter = new m.BaseReporter(null, null, true, { + level: 'debug', + terminal: true + }, adapter) + var writeSpy = sinon.spy(reporter, 'writeCommonMsg') + + reporter._browsers = ['Chrome'] + reporter.onBrowserLog('Chrome', 'Message', 'INFO') + + return writeSpy.should.have.been.called }) return it('should format log messages correctly for multi browsers', function () {