I am trying to return a value from a function where the return value is inside the then() block. Cypress throws a bunch of errors that I am mixing async and sync code. I tried returning a Promise and resolving it, but that threw up errors too.
cy.get('.btn.btn-primary')
.each(function ($el, index, $list) {
// Lot of code
if (price < minPrice) minPrice = price
})
.then(() => {
cy.log(minPrice); //This works fine
return minPrice; //This throws ERROR
})