1beforeEach(() => {
2 // alias the $btn.text() as 'text'
3 cy.get('button').invoke('text').as('text')
4})
5
6it('has access to text', function () {
7 this.text // is now available
8})
9
1// Adding the command
2function foo() {
3 return cy.wrap('foo');
4}
5Cypress.Commands.add('foo', foo);
6
7//Using the command
8cy.foo().then(value => console.log(value)); // foo