Q1.Cypress commands are not promises. What are they, and why does the distinction matter?
This is the root cause of most Cypress mistakes; everything else follows from it.
Calling cy.get('#name') does not perform anything. It enqueues a command. Cypress builds the entire chain synchronously as your test function runs, then executes the queue asynchronously, one command at a time, after the function has returned.
The consequence: you cannot assign a command's result to a variable, and await cy.get(...) is meaningless because a command is not thenable in the way a promise is.
// Wrong — text is a Chainable, not a string
const text = cy.get('h1').text();
// Right — work inside the callback
cy.get('h1').invoke('text').then(text => { expect(text).to.contain('Orders'); });- Mixing async/await with cy commands and expecting values back.
- Writing if/else on a cy result outside a .then() — the condition evaluates before the queue runs.