---
title: "Use axe-core for accessibility tests · Agent Wranglers"
url: https://agentwranglers.se/playbook/stack/testing-and-code-quality/axe-core
updated: 2026-10-21
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Use axe-core for accessibility tests

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers). Updated 2026-10-21.

For AI agents: [llms.txt](https://agentwranglers.se/llms.txt) is a short guide that sends you to the rules your problem needs, and [rules.json](https://agentwranglers.se/playbook/stack/rules.json) holds every rule of this playbook as JSON.

- Level: Recommended
- Chapter: [Testing and code quality](https://agentwranglers.se/playbook/stack/testing-and-code-quality)
- Rule: Run axe-core on every page your browser tests open, and fail the test on any violation.
- Cost: Open source. MPL-2.0 licence, free to use in any project. Deque sells paid tools built on it.
- How: axe-core 1.0 shipped in June 2015, and 4.14.0 came out on 5 October 2026. npm counted over 49 million downloads in the week to 18 October 2026. It is MPL-2.0 licensed, an OSI-approved licence. It runs inside any browser driver. Wire it in as [Check accessibility in every build](https://agentwranglers.se/playbook/testing/non-functional-tests/accessibility-in-ci) describes. Choose something else when you need a full manual audit, because automated rules find only part of the problems a screen reader user meets.
- Check: Every page the browser tests open runs axe-core with the `wcag2a`, `wcag2aa` and `wcag21aa` tags, and the build fails on one violation.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### TypeScript example

```ts
import { test, expect } from '@playwright/test';
import AxeBuilder from '@axe-core/playwright';

test('the shop page has no accessibility violations', async ({ page }) => {
  await page.goto('https://example.com/shop');
  const results = await new AxeBuilder({ page }).withTags(['wcag2a', 'wcag2aa', 'wcag21aa']).analyze();
  expect(results.violations).toEqual([]);
});
```

### Python example

```python
from pathlib import Path
from playwright.sync_api import Page

AXE_SCRIPT = Path("node_modules/axe-core/axe.min.js").read_text()
WCAG_TAGS = ["wcag2a", "wcag2aa", "wcag21aa"]

def test_shop_page_has_no_violations(page: Page):
    page.goto("https://example.com/shop")
    page.add_script_tag(content=AXE_SCRIPT)
    results = page.evaluate("tags => axe.run({ runOnly: tags })", WCAG_TAGS)
    assert results["violations"] == []
```

## Sources

- [axe-core](https://github.com/dequelabs/axe-core)

## Related rules

- [Check accessibility in every build](https://agentwranglers.se/playbook/testing/non-functional-tests/accessibility-in-ci) in Testing

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/stack/testing-and-code-quality/axe-core">Agent Wranglers software choices playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Use Playwright for browser tests](https://agentwranglers.se/playbook/stack/testing-and-code-quality/playwright)
- Next: [Use ESLint and Prettier for JavaScript code](https://agentwranglers.se/playbook/stack/testing-and-code-quality/eslint-and-prettier)
- [Testing and code quality](https://agentwranglers.se/playbook/stack/testing-and-code-quality)
