cypress-io / cypress-example-todomvc

The official TodoMVC tests written in Cypress.
MIT License
258 stars 505 forks source link

fix: Fixes to examples in preparation for Cy 12 #244

Closed BlueWinds closed 1 year ago

BlueWinds commented 1 year ago

Cypress 12 contains breaking changes around how aliases retry commands, leading to new recommended patterns. While unfortunate, this repo demonstrates the sorts of problems users will run into, and why we recommend the new pattern.

The two custom commands in here return the results of cy.get().then() - and when React updates the page, Cy 12 knows it's unsafe to rerun .then(), leading to detached DOM errors.

This PR updates the example repo to match our recommendations, which is that when interacting with the DOM, you alias chains of queries, and not the results of commands, so that Cy knows how to retry them properly when the DOM updates. This update will work in all versions of cypress, so is safe to merge immediately, and does not need to wait for Cypress 12 to go out.