dequelabs / axe-core

Accessibility engine for automated Web UI testing
https://www.deque.com/axe/
Mozilla Public License 2.0
5.75k stars 746 forks source link

Not sure to understand how `.exclude()` works... :thinking: #4423

Closed soykje closed 2 months ago

soykje commented 2 months ago

Product

axe-core

Question

Hi there :wave:

I'm currently working on a a11y script based on webdriverjs. But I'm having troubles using the .exclude() method. As I understood, it can take an array of CSS selectors, right? In my actual setup I have something like:

const results = await new AxeBuilder(driver)
        .options({
          resultTypes: ['violations', 'incomplete'],
          rules: {
            // 'meta-viewport': { enabled: false },
            'page-has-heading-one': { enabled: false },
            'landmark-one-main': { enabled: false },
            region: { enabled: false },
            'color-contrast': { enabled: false },
          },
          runOnly: ['best-practice', 'wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa'],
          reporter: 'v2',
        })
        .exclude('*:not(.docs-story)')
        .analyze()

In my current setup (I'm working on a Design System documented with Storybook), I want to only check .docs-story DOM nodes. Afaik the selector should work, but for some reason I end with a page-has-heading-one error, which should not pop as not related to the defined excluding perimeter, right?

I'll be very gratefull to get some more detailed infos about how this works, to be sure I'm building my script correctly! :+1:

Thx in advance! :pray:

soykje commented 2 months ago

I guess I was not writing the issue in the right place... So I moved it there and close this one. Sorry guys :sweat_smile: