Waiting for XHRs to finish
Testing user interface (UI) transitions is the essence of E2E testing. While it is important to test the predicted outcome of an action right away, there might be cases where the outcome actually has a dependency. For instance, if a user fills out the Login form, we can't show the success toast until we have a successful response from the backend server, hence we can't test whether the success toast is shown right away. In this recipe, you're going to learn how to wait for a specific XHR call to be completed before performing an assertion.
The project for this recipe resides in
- Open the project in VS Code.
- Open the terminal and run
npm installto install the dependencies of the project.
- Once done, run
npm run cypress:test.
This should open a new Cypress window. Tap the
user.spec.tsfile and you should see the tests, as follows: