Takes axe-core results and creates an html report.
npm install a11y-htmlTakes axe-core results and creates an html report.
```
npm i -D a11y-html
`
import AxeBuilder from '@axe-core/playwright'
import test from '@playwright/test'
import { createReport } from 'a11y-html'
test('analyze accessibility', async ({ page }, testInfo) => {
const axeBuilder = new AxeBuilder({ page })
await page.goto('[SOME URL]')
const results = await axeBuilder.analyze()
const report = createReport(results)
await testInfo.attach('a11y-html.html', {
body: report,
contentType: 'application/octet-stream'
})
})
`
You can pass additional options to customize the html report:
| Option | Usage |
| ---------------- | -------------------------------------------------------- |
| title | Sets the html title. |
| heading | Sets the heading of the report. |
| info | Sets an additional info under the url. |
| switchInfo | Swaps the position of info and url, if info is provided. |
| screenshot | Displays an image in the report. |
| hideInapplicable | Hides all results of type "inapplicable". |
Multiple results can be merged into a single report using createMergedReport. Each result can optionally include an info string and a screenshot. The info string is displayed on the overview page and within the result details:
```
createMergedReport([
{ results: results1, info: 'Info 1' },
{ results: results2, info: 'Info 2' },
results3
])
This package is licensed under the MIT License.
It also includes third-party dependencies that are either used for type imports or bundled into the generated html report. These dependencies are subject to their own licenses.
For a full list of third-party licenses, see LICENSES-THIRD-PARTY.txt.