I have a Cypress test script using the cypress-axe library to run an accessibility test on any given web page to check it for WCAG 2.2 AAA rule violations. It is fairly straightforward. And it worked perfectly good only 4 days ago. Today however, it is passing my tests even though it should not.
describe("Test accessibility for different WCAG levels", () => {
const page = "whateverurlyouwant";
it("should run accessibility audits for WCAG 2.2 AAA", () => {
cy.visit(page);
cy.injectAxe();
cy.checkA11y(
null,
{
runOnly: {
type: "tag",
values: ["wcag22aaa"],
},
},
(violations) => {
cy.writeFile(
"./cypress/a11y-reports/a11y-AAA.json",
violations,
"utf8"
);
}
);
});
});
Test case: I run this test against a webpage that has a known issue and fails WCAG 1.4.6 which is a AAA rule.
Expected result: the issue is reported in my test results file. This is what i experienced last Thursday.
Actual result today: the test passes successfully, no a11y problems found.
Things I have tried to remedy the situation:
- put in a wait statement. just in case it was due to the page not being loaded completely. but no luck.
- told cypress to click a button further down the page which reveals more text. this was to make sure that the page was scrolled down enough to reveal the text block that is causing the contrast fail. also did not help.
My question is: Is there anything wrong with my test that I could improve to make the results more reliable? And actually, I also wonder if this even is a case of flaky test results or something else. I have in fact contacted Deque to check if they have changed anything their end. But since between my successful test and today lies mostly a weekend, I think that’s unlikely.