Cypress : How to get returned value from custom commands ? (Cypress-promise)

To do this I’m using wrap() to return a Chainable containing the value I want to return.

Module

function foo() {
  return cy.wrap('foo');
}

Cypress.Commands.add('foo', foo);

Test File

cy.foo().then(value => console.log(value)); // foo

Since wrap() is returning a Cypress.Chainable, we can call .then() on our commands. What ever is passed into wrap() is yielded to the next command.

See also: Cypress wrap() documentation

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)