Why does Cypress fail to resolve async calls using await in headless mode, even though Cypress promises work in open mode?

I’ve been there too! So, here’s the thing, Cypress commands (like cy.request) aren’t true async/await promises; they’re actually queued commands. It can be a bit confusing because it looks like you’re waiting for something, but internally, Cypress is managing its own command queue.

Now, in headless mode, Cypress is a little more rigid and doesn’t allow test flow to step outside of its command queue, which is why it can cause issues with async calls.

What worked for me was ditching await altogether and chaining commands with .then(). It might seem like a bit of a step back in terms of readability, but I found that if I wrapped my logic in functions and chained them, it kept everything Cypress-friendly while ensuring things ran smoothly.