Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ Disables assertions based on violations and only logs violations to the console

Reference : https://github.com/avanslaars/cypress-axe/issues/17

###### failureThreshold (optional, defaults to 0)

Allows you to configure the number of violations that will cause the assertion to fail. This should be used as a temporary measure while you address accessibility violations, but can help validate that you're not regressing as you progress towards 0 violations.

### Examples

#### Basic usage
Expand Down
7 changes: 4 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ const checkA11y = (
context,
options,
violationCallback,
skipFailures = false
skipFailures = false,
failureThreshold = 0
) => {
cy.window({ log: false })
.then(win => {
Expand Down Expand Up @@ -61,9 +62,9 @@ const checkA11y = (
})
.then(violations => {
if (!skipFailures) {
assert.equal(
assert.isAtMost(
violations.length,
0,
failureThreshold,
`${violations.length} accessibility violation${
violations.length === 1 ? '' : 's'
} ${violations.length === 1 ? 'was' : 'were'} detected`
Expand Down