Ignore Rules
You can choose to ignore specified rules while testing for accessibility. We support ignoring a specific rule, ignoring rules by class name, and ignoring rules by accessibility identifier. While we feel that all rules are important, these customizations will enable your team to fit results for their unique needs. Whether a business decision has been made, or bugs are already known and pending fixes, you can focus on what's important to your team.
In the below examples, axe
refers to the AxeDevTools
object initialized when logging in.
APIs Available
To ignore a specific rule or set of rules, update the configuration before testing takes place.
Ignore Rule(s)
The below code shows how to ignore a specific rule, ConflictingTraits
.
Rules ignored with this API will not run and therefore will not be available within the dashboard.
axe?.configuration.ignore(rule: AxeRuleId.ConflictingTraits.toString())
To ignore multiple rules:
axe?.configuration.ignore(rules: [AxeRuleId.ConflictingTraits.toString(), AxeRuleId.InScrollView.toString()])
Ignore Rules by Class Name
Note: Supports class names and accessibility identifiers.
Rules ignored with this API will run and be reported in the dashboard under the IGNORED
status.
axe?.configuration.ignore(rulesFor: ["UILabel": [AxeRuleId.InScrollView.toString()]])
Ignore Rules by Accessibility Identifier
Note: Supports class names and accessibility identifiers.
Rules ignored with this API will run and be reported in the dashboard under the IGNORED
status.
axe?.configuration.ignore(rulesFor: ["LoginScreen.Button": [AxeRuleId.CollidingViews.toString()]])
Ignore Rules with Automated Testing
To ignore rules while running unit or UI tests, update the configuration before your tests run. We recommend utilizing the setUp and tearDown methods.