declare namespace Cypress { interface Chainable extends CustomCommands { } } /** Possible values for the view to render */ type ViewName = 'slots' | 'slotsComponents' ; interface CustomCommands { param selector example getByDataTest ( selector ) : Cypress . Chainable < JQuery > ; param viewName example goToView ( viewName ) : Cypress . Chainable < Cypress . AUTWindow > ; } const commands = { getByDataTest ( selector ) { return cy . get ( `[data-test="${ selector }"]` ) ; } , goToView ( viewName ) { return cy . visit ( `/?view=${ viewName }` ) ; } } ; Object . entries ( commands ) . forEach ( ( [ commandName , command ] ) => { Cypress . Commands . add ( commandName , command ) ; } ) ;