Search code examples
github-actionspa11y

How do I use the HTML/CSV reporters in pa11y with GitHub Actions?


I'm trying to get pa11y to output HTML and CSV reports.

Here's the errors:

Unable to load reporter "csv"

Unable to load reporter "html"

I have pa11y configured to generate cli, csv, and html reports, but only the cli report is output correctly.

My pa11yconfig.json looks like this:

{
  "standard": "WCAG2AAA",
  "level": "notice",
  "defaults": {
    "chromeLaunchConfig": {
      "args": [
        "--no-sandbox"
      ]
    },
    "reporters": [
      "cli",
      "csv",
      "html"
    ],
    "runners": [
      "axe",
      "htmlcs"
    ],
    "timeout": 1000000,
    "wait": 2000
  }
}

And I'm running pa11y like this:

pa11y-ci --sitemap "$SITEMAP_URL"  > "$OUTPUT_DIR/success-pa11y-report.txt" 2> "$OUTPUT_DIR/failures-pa11y-report.txt"

This command is being executed as part of GitHub Actions, which looks like this:

  - name: Install pa11y.
    run: npm install -g pa11y-ci
  - name: 'TEST: Run pa11y tests.'
    run: my-pa11y-script.sh

My understanding is that the reporters are now bundled with pa11y, so how can I get pa11y to recognize them?


Solution

  • As noted by @José Luis, pa11y and pa11y-ci reporters are different.

    There is no csv reporter for pa11y-ci, but there is a bundled json reporter.

    As for html reporters, there is an html reporter included with pa11y, but for pa11y-ci, you need to download the pa11y-ci-reporter-html npm module.

    Reference:

    The pa11y-ci docs currently refer to the deprecated pa11y-html-reporter module, which will not work; I've opened a PR to update the docs.