Skip to content
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

[Feature Request] Support disabling rules for particular tests #107

Open
IanVS opened this issue Jun 13, 2022 · 2 comments
Open

[Feature Request] Support disabling rules for particular tests #107

IanVS opened this issue Jun 13, 2022 · 2 comments
Labels

Comments

@IanVS
Copy link

IanVS commented Jun 13, 2022

I'm using this tool along with storybook, but there are some times when I'd like to disable failures for certain stories. For instance, I have a story of an input element, which is intended to be used together with a label, but my stories show the input by itself. I'd like to silence the error Ensures every form element has a label for these stories. Is there a way I can do this currently, and if not, is it a feature you might consider adding?

@Kosai106
Copy link

Storybook already allows for this, assuming you're using their addon: https://github.com/storybookjs/storybook/tree/next/addons/a11y#story-level-overrides

If you're utilizing the test-runner they wrote a blog post about recently, then I haven't yet found a "clean" solution but it is doable albeit there's some manual work involved:

async postRender(page, context) {
  const disabledRulesForStory = () => {
    switch (context.id) {
      case "fields-input--basic-usage":   // <-- You have to manually keep track of the stories and which rules to ignore for each
        return {
          "label": {
            enabled: false
          }
        }

      default:
        return {}
    }
  }
  const violations = await getViolations(page, "#root", {
    detailedReport: true,
    rules: {
      ...disabledRulesForStory()
    },
  });

  // ...Rest of your code
}

@IanVS
Copy link
Author

IanVS commented Jun 30, 2022

Thanks, I am indeed using the test-runner. @yannbf you might be interested in this ^.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants