Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit 45d6f67

Browse files
committed
feat(plugins): add option to treat chrome a11y warnings as passes
See #1854
1 parent 37d8342 commit 45d6f67

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

Diff for: lib/plugins.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var log_ = function() {
2525
var Plugins = function(config) {
2626
var self = this;
2727

28-
this.pluginConfs = config.plugins;
28+
this.pluginConfs = config.plugins || [];
2929
this.pluginObjs = [];
3030
this.pluginConfs.forEach(function(pluginConf) {
3131
var path;
@@ -72,7 +72,7 @@ Plugins.printPluginResults = function(specResults) {
7272
}
7373
}
7474
}
75-
}
75+
};
7676

7777
function pluginFunFactory(funName) {
7878
return function() {

Diff for: plugins/accessibility/index.js

+14-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ var q = require('q'),
1313
* exports.config = {
1414
* ...
1515
* plugins: [{
16-
* chromeA11YDevTools: true,
16+
* chromeA11YDevTools: {
17+
* treatWarningsAsFailures: true
18+
* },
1719
* path: 'node_modules/protractor.plugins/accessiblity'
1820
* }]
1921
* }
@@ -165,7 +167,7 @@ function runTenonIO(config) {
165167
* failed tests
166168
* @private
167169
*/
168-
function runChromeDevTools() {
170+
function runChromeDevTools(config) {
169171

170172
var data = fs.readFileSync(AUDIT_FILE, 'utf-8');
171173
data = data + ' return axs.Audit.run();';
@@ -202,10 +204,17 @@ function runChromeDevTools() {
202204

203205
return audit.forEach(function(result, index) {
204206
if (result.result === 'FAIL') {
205-
result.passed = false;
206-
testOut.failedCount++;
207-
208207
var label = result.elementCount === 1 ? ' element ' : ' elements ';
208+
if (result.rule.severity !== 'Warning'
209+
|| config.chromeA11YDevTools.treatWarningsAsFailures) {
210+
result.passed = false;
211+
testOut.failedCount++;
212+
} else {
213+
result.passed = true;
214+
result.rule.heading = '\x1b[33m(WARNING) '
215+
+ result.rule.heading + ' (' + result.elementCount
216+
+ label + 'failed)';
217+
}
209218
result.output = '\n\t\t' + result.elementCount + label + 'failed:';
210219

211220
// match elements returned via promises

Diff for: plugins/accessibility/spec/failureConfig.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ exports.config = {
1313
},
1414
printAll: false
1515
},
16-
chromeA11YDevTools: true,
16+
chromeA11YDevTools: {
17+
treatWarningsAsFailures: true
18+
},
1719
path: '../index.js'
1820
}]
1921
};

0 commit comments

Comments
 (0)