Adding accessibility checks to a site that already has violations
The first scan of a site that has been live for a few years is rarely clean, and a check that fails every build gets switched off within the week. The way through is to stop failing on what is already there and start failing on what is new.
Why the first scan goes red
Point any axe-core based scanner at a home page that has been in production for a while and expect a few dozen findings. The WebAIM Million survey puts the average home page at 56 detectable errors. Most of them are not new: low-contrast text from an old brand palette, icon buttons with no accessible name, a form label that went missing three redesigns ago.
None of that is a reason not to check. It is a reason the obvious set-up fails. A CI step that exits non-zero on any violation will fail on the first pull request after you add it, and on every pull request after that, whatever the pull request changed. Within days someone marks it as allowed to fail, and from then on it is a log nobody reads.
The two usual workarounds, and what they cost
A threshold. Allow up to N violations and fail above that. This counts, and counting cannot tell a violation you fixed from one you introduced. Fix one, add one, and the number does not move, so the gate stays green while the site gets a new problem.
Disabling rules. Turn off color-contrast because there are forty of them. That
silences the rule everywhere, including on the page someone writes tomorrow, which is
exactly the page you could still have caught.
Both make the build green. Neither tells you anything useful about the change in front of you.
A baseline: accept what is there, fail on what is new
A baseline is a file, committed to your repository, that lists the violations you have seen and chosen not to block on for now. The check runs as normal, compares what it finds against the file, and fails only on violations that are not in it.
With the Skiplink CLI that is two commands. Once, after you have looked at what the scan finds:
# Record what is already there. Review it before you commit it.
npx @skiplink/cli scan https://staging.example.com \
--baseline .skiplink/baseline.json --update-baseline
git add .skiplink/baseline.json
And in every build after that:
npx @skiplink/cli scan https://staging.example.com --baseline .skiplink/baseline.json
On GitHub the Action does the same and comments on the pull request:
- uses: skiplink/action@v1
with:
urls: https://staging.example.com
baseline: .skiplink/baseline.json
token: ${{ secrets.SKIPLINK_TOKEN }}
The forty-first contrast failure now fails the build on the day it appears. The first forty are still there, still visible, in a file anyone can read in review.
What makes a baseline hold up
A baseline is only as good as its matching. Two details decide whether it survives contact with a real codebase:
- Match on the URL path, not the whole URL. Preview deployments get a new hostname on every pull request. A baseline keyed on the full URL matches nothing on exactly the runs it exists for.
- Survive a restyle. If a violation is identified only by its CSS selector, renaming a class reopens everything under it. Skiplink tries the exact selector first and then the element's text, and reports text-only matches as drifted so you can refresh the file when you choose to. Each text match is used once, so one accepted violation cannot quietly absorb ten new ones that share its text.
How violations are matched in the docs has the full rules.
Paying the debt down
A baseline is a list of known problems, not a permission slip. A few habits keep it shrinking:
- Review the first file properly. Read it the way you would read any other pull request. Anything you would be embarrassed to ship, fix before you commit the baseline.
- Fix by rule, not by page. Most debt clusters: one contrast token used in thirty places is one fix. Sort the baseline by rule and start at the top.
- Regenerate after a fix. Run
--update-baselinein the pull request that fixes something, so the file shrinks in the same review. - Watch the size. The number of entries is the honest measure of progress. If it only ever grows, the gate is working and the fixing is not.
What a scan will not tell you
Automated checks find a share of accessibility problems, not all of them. Whether alt text actually describes the image, whether focus order makes sense, whether an error message is understandable: a person has to look. A clean scan means the detectable problems are gone, not that the site is accessible. Our page on what a scan does not tell you goes through the limits in detail.
Related
- API Reference & CI Gate Documentation
- Alternatives: Pa11y CI, Lighthouse CI and axe CLI
- What automated testing can and cannot detect — WCAG 2.2 reference
Try it on your own site: scan a URL for free, or read the docs to add a baseline to your pipeline.