I've been struggling with returning a value from my custom function due to the fact that I'm dealing with a promise.
Here's my code:
This is my custom function:
Cypress.Commands.add("myFunction", () => {
cy.get('#someID').then($container) => {
const isHidden = $container().children('div:nth-child(3)').is(':hidden');
console.log(isHidden); // This returns either true or false and that is good
return isHidden; // this returns $chainer but I want to return either true or false
}
});
Here is my test suite:
context('some description', () => {
before(function(){
const result = cy.myFunction();
console.log(result); // This is $chainer, but I want to get the value of true or false from isHidden variable
});
});