beforeEach(() => {
// alias the $btn.text() as 'text'
cy.get('button').invoke('text').as('text')
})
it('has access to text', function () {
this.text // is now available
})
// 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