I have been working on (ticket) Improving the Search E2E test.
The changes done to the workflow
Creates a new patient with a random name.
Search for the newly created patient.
Deletes the newly created patient at the end of the test.
I faced a blocker while working on this issue. The test cannot find the Search Button most of the time. But sometimes (1/20) it finds the button and the test passes.
Steps taken to solve this issue
Result
Finding the button using a different attribute
Fail
Setup patient-search-app, add an id to the button and test locally
The problem is in the condition syntax. For such conditions, every symbol counts. You either copy-paste the text from the actual element or add a selector to assert the element by selector for future cases.
By default Cypress assumes whenever you cy.get an element - for that element to exist. It will wait around until it does exist or it will time out. If it times, the test fails.
If you want Cypress to wait until the element DOES NOT EXIST, you simply add that as an assertion e.g.