Skip to content

Commit df123dd

Browse files
committed
feat(plugins): add option to treat chrome a11y warnings as passes
See angular#1854
1 parent cdf1b87 commit df123dd

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

plugins/accessibility/index.js

+15-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
* }
@@ -152,7 +154,7 @@ function runTenonIO(config) {
152154
* failed tests
153155
* @private
154156
*/
155-
function runChromeDevTools() {
157+
function runChromeDevTools(config) {
156158

157159
var data = fs.readFileSync(AUDIT_FILE, 'utf-8');
158160
data = data + ' return axs.Audit.run();';
@@ -189,10 +191,18 @@ function runChromeDevTools() {
189191

190192
return audit.forEach(function(result, index) {
191193
if (result.result === 'FAIL') {
192-
result.passed = false;
193-
testOut.failedCount++;
194-
195194
var label = result.elementCount === 1 ? ' element ' : ' elements ';
195+
if (result.rule.severity !== 'Warning'
196+
|| config.chromeA11YDevTools.treatWarningsAsFailures) {
197+
result.passed = false;
198+
testOut.failedCount++;
199+
} else {
200+
result.passed = true;
201+
result.rule.heading = '\x1b[33m(WARNING) '
202+
+ result.rule.heading + ' (' + result.elementCount
203+
+ label + 'failed)';
204+
// TODO - continue to output the element failures.
205+
}
196206
result.output = '\n\t\t' + result.elementCount + label + 'failed:';
197207

198208
// match elements returned via promises

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)