Skip to content

Commit

Permalink
Add ability to exclude messages by regex
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Wendt committed Aug 16, 2017
1 parent 55e213a commit fabd7e4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ module.exports = {
level: 'warning',
});
});

global.PROTRACTOR_CONSOLE_EXCLUDE_REGEX = { };
},

postTest: function() {
postTest: function(passed, testInfo) {
let config = this.config;

if (!this.enabled) {
Expand All @@ -60,7 +62,14 @@ module.exports = {

return browser.manage().logs().get('browser')
.then(result => {
result = result.filter(byLogLevel, config);
result = result
.filter(byLogLevel, config)
.filter(function(log) {
let testExcludeRegex = global.PROTRACTOR_CONSOLE_EXCLUDE_REGEX[testInfo.name];
let excludedByConfig = config.excludeRegex && log.message.match(config.excludeRegex);
let excludedByTest = testExcludeRegex && log.message.match(testExcludeRegex);
return !excludedByConfig && !excludedByTest;
});

if (result.length === 0) {
return;
Expand Down

0 comments on commit fabd7e4

Please sign in to comment.