import { dirxml , time } from 'console' ; import { addMatchImageSnapshotCommand } from 'cypress-image-snapshot/command' ; addMatchImageSnapshotCommand ( { customSnapshotsDir : Cypress . env ( 'snapshotsDir' ) , } ) ; const { isPlainObject , last } = Cypress . _ ; example example Cypress . Commands . add ( 'waitForResources' , ( ... args ) => { let names ; let options ; if ( isPlainObject ( last ( args ) ) ) { names = args . slice ( 0 , args . length - 1 ) ; options = last ( args ) ; } else { names = args ; options = { } ; } const log = false ; const timeout = options . timeout || Cypress . config ( 'defaultCommandTimeout' ) ; cy . log ( `Waiting for resources ${ names . join ( ', ' ) }` ) ; cy . window ( { log } ) . then ( { log , timeout } , ( win ) => { return new Cypress . Promise ( ( resolve , reject ) => { let foundResources ; const interval = setInterval ( ( ) => { foundResources = names . every ( ( name ) => { return win . performance . getEntriesByType ( 'resource' ) . find ( ( item ) => item . name . endsWith ( name ) ) ; } ) ; if ( ! foundResources ) { return ; } cy . log ( 'Found all resources' ) ; clearInterval ( interval ) ; resolve ( ) ; } , 100 ) ; setTimeout ( ( ) => { if ( foundResources ) { return ; } clearInterval ( interval ) ; reject ( new Error ( `Timed out waiting for resources ${ names . join ( ', ' ) }` ) ) ; } , timeout ) ; } ) ; } ) ; } ) ; export enum navigate { LEFT = '{leftarrow}' , UP = '{uparrow}' , RIGHT = '{rightarrow}' , DOWN = '{downarrow}' , ENTER = '{enter}' } type SendNavigatioActionParams = Partial < Cypress . TypeOptions > & { times ? : number ; } ; Cypress . Commands . add ( 'sendNavigateAction' , ( dir , opts = { } ) => { const times = opts ?. times ?? 1 ; const sequence = Array . isArray ( dir ) ? dir : Array ( times ) . fill ( dir ) ; const options = { delay : 350 , waitForAnimation : true , ... opts , } ; return sequence . reduce < Cypress . Chainable > ( ( acc , key ) => { return acc . type ( key , options ) ; } , cy . get ( 'body' ) ) ; } ) ;