declare namespace Cypress { interface Chainable { example checkExternalLink ( url ) : Chainable < Element > ; } } Cypress . Commands . add ( 'checkExternalLink' , { prevSubject : 'element' } , ( $element , url ) => { cy . wrap ( $element ) . should ( 'have.attr' , 'href' , url ) . should ( 'have.attr' , 'target' , '_blank' ) ; } ) ;