Skip to main content
Version: 2x

@qavajs/steps-accessibility

qavajs steps to perform accessibility checks using the axe-core library. Works on top of both Playwright and WebdriverIO drivers.

Installation

npm install @qavajs/steps-accessibility

Configuration

Import the library after the corresponding driver library in your qavajs config:

export default {
require: [
'node_modules/@qavajs/steps-playwright/index.js', // or steps-wdio
'node_modules/@qavajs/steps-accessibility/index.js'
],
format: [
['@qavajs/html-formatter', 'report.html']
],
}

Steps

Basic accessibility check

Runs axe on the full page and fails if any violations are found. Attaches an HTML report to the test output.

When I open 'https://example.com/' url
And I perform accessibility check

Configured accessibility check

Passes a JSON options object to axe.run. Supports all axe-core run options, plus two extra properties:

PropertyTypeDescription
contextstring[]CSS selectors to scope the analysis
saveAsstringFile path to save the raw JSON results
When I open 'https://example.com/' url
And I perform accessibility check:
"""
{
"runOnly": ["wcag2a", "wcag2aa"],
"context": ["main"],
"saveAs": "results/report.json"
}
"""

Save results to memory

Stores the full axe results object in a memory variable for custom assertions. Does not throw on violations.

When I open 'https://example.com/' url
And I perform accessibility check and save results as 'axeReport'
Then I expect '$axeReport.violations.length' to equal '0'

With options:

When I open 'https://example.com/' url
And I perform accessibility check and save results as 'axeReport':
"""
{
"runOnly": ["wcag2a"]
}
"""
Then I expect '$axeReport.violations.length' to equal '0'

Step reference

StepDescription
I perform accessibility checkRun axe on the full page; throw if violations found
I perform accessibility check: + docstringRun axe with options; throw if violations found
I perform accessibility check and save results as {value}Run axe; store results in memory variable
I perform accessibility check and save results as {value}: + docstringRun axe with options; store results in memory variable