I have a question about return values. I'm fully a...
# best-practices
l
I have a question about return values. I'm fully aware of the fact that cy commands run after the vanilla JavaScript, and I've got plenty of tricks to work within these bounds, with one exception: return values. Does anyone know a good way to incorporate a return value from a simple function within a Cypress test? It sure would be handy. Example:
Copy code
js
it('returns values', () => {
  const message = returnSomething()
  cy.log(message)
})

function returnSomething() {
  cy.log('howdy').then(() => {
    return 'yo'
  })
}
Expected: It should log 'yo' Actual: It logs nothing The reason I have this under 'best-practices' is because I can work around this using aliases like I would global variables, but doing that feels ugly and wrong.