import * as axe from 'axe-core' ; import { defaultRuleset } from '@sa11y/preset-rules' ; import { A11yError } from '@sa11y/format' ; import { A11yConfig , AxeResults , getViolations } from '@sa11y/common' ; /**
 * Context that can be checked for accessibility: Document, Node or CSS selector.
 * Limiting to subset of options supported by axe for ease of use and maintenance.
 */ export type A11yCheckableContext = Document | Node | string ; param context param rules returns { link export async function getViolationsJSDOM ( context = document , rules = defaultRuleset ) { return await getViolations ( async ( ) => { const results = await axe . run ( context as axe . ElementContext , rules as axe . RunOptions ) ; return results . violations ; } ) ; } param context param rules throws export async function assertAccessible ( context = document , rules = defaultRuleset ) { const violations = await getViolationsJSDOM ( context , rules ) ; A11yError . checkAndThrow ( violations ) ; }