Is there a way to retrieve the value of the getLength function without it returning undefined? How can I access the value in this case?
Here is my code snippet:
const verifyValue = () => {
const selector = 'nz-option-container nz-option-item';
const myActualLength = getLength(selector);
console.log('I need to extract this value: ' + myActualLength);
}
const getLength = (selector: string) => {
let length;
cy.get(selector).then((listItem) => {
length = listItem.length;
})
return length;
}