@sa11y/assert
Provides assertAccessible API to check DOM for accessibility issues
Usage
Basic Usage
import { assertAccessible } from '@sa11y/assert';
import { full } from '@sa11y/preset-rules';
await assertAccessible();
const elem = document.getElementById('foo');
await assertAccessible(elem);
await assertAccessible(document, full, null);
Getting Results
For advanced use cases where you want to get the accessibility results without throwing an error:
import { getA11yResultsJSDOM, getViolationsJSDOM, getIncompleteJSDOM } from '@sa11y/assert';
import { extended } from '@sa11y/preset-rules';
const allResults = await getA11yResultsJSDOM(document, extended, true);
const violations = await getViolationsJSDOM(document, extended);
const incomplete = await getIncompleteJSDOM(document, extended);
Environment Variables
SELECTOR_FILTER_KEYWORDS
: Comma-separated list of keywords to filter out violations by CSS selector