From fabd7e466f9c318ab9365b67c2fd5c5fc1691843 Mon Sep 17 00:00:00 2001 From: Chris Wendt Date: Wed, 16 Aug 2017 11:51:45 -0700 Subject: [PATCH] Add ability to exclude messages by regex --- src/index.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 3432c27..39d74f5 100644 --- a/src/index.js +++ b/src/index.js @@ -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) { @@ -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;