import { WdioAssertFunction , WdioOptions , axeRuntimeExceptionMsgPrefix , errMsgHeader } from '@sa11y/common' ; export async function checkA11yErrorWdio ( assertFunc , expectNumA11yIssues = 0 , options = { } ) { let err = new Error ( ) ; try { await assertFunc ( options ) ; } catch ( e ) { err = e as Error ; } expect ( err ) . toBeTruthy ( ) ; expect ( err . message ) . not . toContain ( axeRuntimeExceptionMsgPrefix ) ; if ( expectNumA11yIssues > 0 ) { expect ( err ) . not . toStrictEqual ( new Error ( ) ) ; expect ( err . toString ( ) ) . toContain ( `${ expectNumA11yIssues } ${ errMsgHeader }` ) ; } else { expect ( err ) . toStrictEqual ( new Error ( ) ) ; expect ( err . toString ( ) ) . not . toContain ( errMsgHeader ) ; } }