// Adding the command function foo() { return cy.wrap('foo'); } Cypress.Commands.add('foo', foo); //Using the command cy.foo().then(value => console.log(value)); // foo