declare namespace Cypress { interface Chainable { example fill ( value ) : Chainable < Element > ; setCodemirrorContent ( value ) : Chainable < Element > ; } } Cypress . Commands . add ( 'fill' , { prevSubject : 'element' } , ( subject , value ) => { return cy . wrap ( subject ) . invoke ( 'val' , value ) . trigger ( 'change' , { force : true } ) ; } ) ; Cypress . Commands . add ( 'setCodemirrorContent' , ( content ) => { const line = content . split ( '\n' ) . find ( ( value ) => value !== '' ) ; cy . get ( '.CodeMirror' ) . click ( ) . get ( 'textarea' ) . type ( '{ctrl}a' ) . type ( '{backspace}' ) . fill ( content ) ; if ( line ) { cy . get ( '.CodeMirror' ) . find ( '.CodeMirror-line' ) . should ( 'contain.text' , line ) ; } } ) ;