Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filter browser logging by level of LOG #2540

Merged
merged 7 commits into from
Feb 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ exports.LOG_ERROR = 'ERROR'
exports.LOG_WARN = 'WARN'
exports.LOG_INFO = 'INFO'
exports.LOG_DEBUG = 'DEBUG'
exports.LOG_LOG = 'LOG'
exports.LOG_PRIORITIES = [
exports.LOG_DISABLE,
exports.LOG_ERROR,
exports.LOG_WARN,
exports.LOG_INFO,
exports.LOG_DEBUG,
exports.LOG_DISABLE
exports.LOG_LOG
]

// Default patterns for the pattern layout.
Expand Down
5 changes: 4 additions & 1 deletion test/e2e/browser_console.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ Feature: Browser Console Configuration
plugins = [
'karma-jasmine',
'karma-phantomjs-launcher'
];
],
browserConsoleLogOptions = {
level: 'log'
};
"""
When I start Karma
Then it passes with like:
Expand Down
40 changes: 38 additions & 2 deletions test/unit/reporters/base.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,45 @@ describe('reporter', function () {
return expect(writeSpy).to.have.been.calledWith('LOG: Message\n')
})

it('should not log if lower priority than browserConsoleLogOptions.level', function () {
it('should not log if lower priority than browserConsoleLogOptions "error"', function () {
var reporter = new m.BaseReporter(null, null, true, {
browserConsoleLogOptions: {level: 'ERROR'}
browserConsoleLogOptions: {level: 'error'}
}, adapter)
var writeSpy = sinon.spy(reporter, 'writeCommonMsg')

reporter._browsers = ['Chrome']
reporter.onBrowserLog('Chrome', 'Message', 'WARN')

return writeSpy.should.have.not.been.called
})

it('should not log if lower priority than browserConsoleLogOptions "warn"', function () {
var reporter = new m.BaseReporter(null, null, true, {
browserConsoleLogOptions: {level: 'warn'}
}, adapter)
var writeSpy = sinon.spy(reporter, 'writeCommonMsg')

reporter._browsers = ['Chrome']
reporter.onBrowserLog('Chrome', 'Message', 'INFO')

return writeSpy.should.have.not.been.called
})

it('should not log if lower priority than browserConsoleLogOptions "info"', function () {
var reporter = new m.BaseReporter(null, null, true, {
browserConsoleLogOptions: {level: 'info'}
}, adapter)
var writeSpy = sinon.spy(reporter, 'writeCommonMsg')

reporter._browsers = ['Chrome']
reporter.onBrowserLog('Chrome', 'Message', 'DEBUG')

return writeSpy.should.have.not.been.called
})

it('should not log if lower priority than browserConsoleLogOptions "debug"', function () {
var reporter = new m.BaseReporter(null, null, true, {
browserConsoleLogOptions: {level: 'debug'}
}, adapter)
var writeSpy = sinon.spy(reporter, 'writeCommonMsg')

Expand Down