Cypress . Commands . add ( "isInViewport" , ( element ) => { cy . get ( element ) . then ( ( $el ) => { cy . window ( ) . then ( ( window ) => { const bottom = Cypress . $ ( window ) . height ( ) ; const rect = $el [ 0 ] . getBoundingClientRect ( ) ; expect ( rect . top ) . not . to . be . greaterThan ( bottom ) ; expect ( rect . bottom ) . not . to . be . greaterThan ( bottom ) ; } ) ; } ) ; } ) ;