Waiting for an Ajax Request
Let's learn about the Ajax request in testing.
We'll cover the following...
AJAX request
Do you remember the list of problems that would break the signup flow? We fixed the DOM-related ones by retrieving the elements based on the contents instead of the order, but there were a lot of problems related to the AJAX request itself:
-
The AJAX call does not start.
-
The AJAX call has the wrong request payload.
-
The API does not work and it does not respond.
-
The API returns the wrong payload.
-
The user already exists.
The tests we’ve covered so far still do not solve these errors. When they fail, we need to spend some time debugging the web app during testing to discover that the issue is related to the incorrect AJAX request. Don’t worry, Cypress will improve the E2E testing experience!
Server contract
When we test the front-end of our web app, we need to consider it as a closed block (i.e. blackbox testing) and check its interactions with the external world ...