Skip to content

Commit

Permalink
fix(reporters): Revert the backwards-incompatible log priority order …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
mgol committed Apr 26, 2017
1 parent ef62da9 commit 316b944
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 1 addition & 4 deletions test/e2e/browser_console.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
58 changes: 55 additions & 3 deletions test/unit/reporters/base.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand All @@ -122,17 +135,56 @@ 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')

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 () {
Expand Down

0 comments on commit 316b944

Please sign in to comment.