I was writing end-to-end tests for TripTime’s authorisation function, and as the system will block user from registering a new account if the email is occupied, I used the conditional testing feature offered by Cypress.
1 | .get('body') |
The problem with conditional testing is that it can only be used when the state has stabilized. In modern day applications, knowing when state is stable is oftentimes impossible.
This problem applies to me, as it takes time for the request to validate the email to resolve, and Cypress might have already taken the wrong path by then.
On the other hand, waiting for XHR is not very robust either as I do not have control over when the validating request is to be returned.
I settled on waiting for 1s for now in this specific scenario. On other scenarios I seek to see if I could wait for the XHR to resolve instead of hard coding the waiting time.