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
- The framework re-rendered the surrounding component after a state change, unmounting the original element
How to fix it
- 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()`
- Add a stable assertion on post-render state before interacting, so the app has settled first