Cypress . Commands . add ( 'navigate' , ( url , options = { } ) => { return cy . window ( ) . then ( $win => { if ( options . forceReload || ! $win . location . href . startsWith ( Cypress . config ( 'baseUrl' ) ) ) { cy . log ( 'Visit' ) ; cy . visit ( url , options ) ; return cy . get ( '.page-loader' ) . should ( 'not.exist' , { timeout : 20000 } ) ; } if ( ! url || url === '' ) { cy . log ( 'Reload' ) ; cy . reload ( ) ; return cy . get ( '.page-loader' ) . should ( 'not.exist' , { timeout : 20000 } ) ; } if ( $win . location . href === Cypress . config ( 'baseUrl' ) + url ) { cy . log ( 'Refresh' ) ; return navByLink ( '/' ) . then ( ( ) => { return navByLink ( url ) ; } ) ; } return navByLink ( url ) ; function navByLink ( href ) { cy . log ( 'navByLink' ) ; return cy . document ( ) . then ( $doc => { const a = $doc . createElement ( 'a' ) ; a . href = href ; $doc . body . appendChild ( a ) ; a . click ( ) ; $doc . body . removeChild ( a ) ; } ) ; } } ) ; } ) ; Cypress . Commands . add ( 'dataCy' , value => { return cy . get ( `[data-cy=${ value }]` ) ; } ) ; Cypress . Commands . add ( 'asAllDataCy' , ( ) => cy . get ( '[data-cy]' ) . then ( list => { list . each ( ( i , { dataset : { cy : name } } ) => { cy . dataCy ( name ) . as ( name ) ; } ) ; } ) ) ; Cypress . Commands . add ( 'findPseudoBefore' , { prevSubject : 'element' } , el => { const win = el [ 0 ] . ownerDocument . defaultView ; return win . getComputedStyle ( el [ 0 ] , 'before' ) ; } ) ; Cypress . Commands . add ( 'findPseudoAfter' , { prevSubject : 'element' } , el => { const win = el [ 0 ] . ownerDocument . defaultView ; return win . getComputedStyle ( el [ 0 ] , 'after' ) ; } ) ;