Lupa API Reference / assert/accessibility / assertIsAccessible
Function: assertIsAccessible()
assertIsAccessible(
assertInstance,element,options?):Promise<void>
Defined in: src/assert/accessibility.ts:25
Asserts that a given DOM element or NodeList has no accessibility violations according to axe-core.
Parameters
assertInstance
The main Assert instance to track assertions and evaluate
element
string | Element | NodeList
The DOM element(s) to test
options?
RunOptions
axe-core run options
Returns
Promise<void>
A Promise that resolves when the assertion has been evaluated.
Remarks
This function integrates axe-core to run accessibility checks on a specified context. The element parameter can be a CSS selector string, a single DOM element, or a NodeList. When a string is provided, axe-core will query the document for matching elements. Any violations found will be formatted into a readable error message and trigger an assertion failure.
Example
import { assert } from '@pawel-up/lupa/assert'
await assert.isAccessible('#my-element')
await assert.isAccessible(document.querySelector('main'))