Skip to content

feat: add reportOnly flag to checkA11y #186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 7 additions & 1 deletion cypress/e2e/test.cy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
it('works!', () => {
cy.visit('/');
cy.injectAxe();
cy.checkA11y(undefined, { retries: 20, interval: 10 });
cy.checkA11y(undefined, { retries: 0, interval: 10 });
});

it('Check reportOnly flag passes tests', () => {
cy.visit('https://www.ibm.com/in-en/careers/search');
cy.injectAxe();
cy.checkA11y({ reportOnly: true }, { retries: 0, interval: 10 });
});
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface Options extends axe.RunOptions {
includedImpacts?: string[];
interval?: number;
retries?: number;
reportOnly?: boolean;
}

export interface InjectOptions {
Expand Down Expand Up @@ -81,7 +82,7 @@ const checkA11y = (
if (isEmptyObjectorNull(violationCallback)) {
violationCallback = undefined;
}
const { includedImpacts, interval, retries, ...axeOptions } =
const { includedImpacts, interval, retries,reportOnly, ...axeOptions } =
options || {};
let remainingRetries = retries || 0;
function runAxeCheck(): Promise<axe.Result[]> {
Expand Down Expand Up @@ -125,7 +126,7 @@ const checkA11y = (
return cy.wrap(violations, { log: false });
})
.then((violations) => {
if (!skipFailures) {
if (!skipFailures && !(options && options.reportOnly)) {
assert.equal(
violations.length,
0,
Expand Down