diff --git a/cypress/e2e/test.cy.js b/cypress/e2e/test.cy.js index 685350b..952f443 100644 --- a/cypress/e2e/test.cy.js +++ b/cypress/e2e/test.cy.js @@ -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 }); }); diff --git a/src/index.ts b/src/index.ts index 70654db..9c076ec 100644 --- a/src/index.ts +++ b/src/index.ts @@ -21,6 +21,7 @@ export interface Options extends axe.RunOptions { includedImpacts?: string[]; interval?: number; retries?: number; + reportOnly?: boolean; } export interface InjectOptions { @@ -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 { @@ -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,