2

I'd like to use the pa11y axe runner and include custom rules.

Deque documents that axe can process custom rules at https://www.deque.com/axe/core-documentation/api-documentation/#synopsis-1.

I can configure axe to use a custom rule with this configuration:

{
  disableOtherRules: true,
  rules: [
    {
      id: 'my-cool-rule',
      enabled: true,
      all: ['auto-fail'],
    },
  ],
  checks: [
    {
      id: 'auto-fail',
      metadata: {
        impact: 'critical',
        messages: {
          pass: 'Surprise! This test passed!',
          fail: 'This test did not pass, sadly.',
        },
      },
      evaluate: function () {
        return false;
      },
    },
  ],
}

I can use this configuration with other axe implementations, such as with Cypress.

Pa11y defines a rules property in its configuration docs also: https://github.com/pa11y/pa11y#configuration, and it looks like the pa11y axe runner picks up on those - but not the corresponding rules definitions in the axe config's checks property.

How can I get pa11y to execute my custom rules?

calebtr
  • 200
  • 7

0 Answers0