Cypress error

CypressError: cy.click() failed because this element is detached from the DOM

The app re-rendered and replaced the element between when Cypress found it and when it tried to click it.

Why this happens

How to fix it

  1. Re-query right before acting instead of holding a stored reference: keep the find-and-act in one chain, e.g. `cy.get('[data-cy=btn]').click()`
  2. Add a stable assertion on post-render state before interacting, so the app has settled first