component-driven / cypress-axe

Test accessibility with axe-core in Cypress
MIT License
622 stars 86 forks source link

feature request - allow runOnly tags to fall through or use array values #117

Open rramsey opened 2 years ago

rramsey commented 2 years ago

Hi,

Some background. Let's say I have a div with a color green and a background color of green. Running this test correctly fails the contrast check:

const a11yOptions: RunOptions = {
      runOnly: {
        type: 'tag',
        values: ['wcag2aa']
      }
    };
cy.checkA11y(null, a11yOptions as Options);

But if I set values: ['wcag2aaa] it fails using

"axe-core": "^4.3.5",
"cypress": "^9.2.0",
"cypress-axe": "^0.13.0",

It also fails with wcag21aa, even though 2.1 extends 2.0. I would expect that using the tag 2.1aaa would check everything in 2.1aaa, 2.1aa, 2.1a, 2.1, 2.0aaa, 2.0aa, 2.0a, 2.0, 1aaa, 1aa, 1a, and 1.

The example for getRules shows that rules have multiple tags, so this may be a problem/issue for the axe.run team at Deque instead. If they don't have the rules tagged with all of the appropriate fall through values, then checking for a level won't get all of the lower levels.

thanks!