https://cypress.io logo
Be sure to investigate whether your test is going ...
# e2e-testing
l
Be sure to investigate whether your test is going too fast in some cases. Pages that execute JavaScript often misbehave if the test user operates at superhuman speeds. There are a number of ways to mitigate this: - For each click or page load that triggers JavaScript, assert the state of a portion of the UI that you expect to change. This way the clicks will not continue until the UI is ready. - If your page has a trustworthy loading animation you can add an assertion for the disappearance of the loading animation. - If the page executes XHR, you can alternatively introduce a
cy.intercept()
before the click, then wait for the request after the click. This is a less preferable approach, since a) it's a bit messy in the code, and b) an XHR response is not always sufficient evidence that the UI is ready for more clicks. Also be sure to look at the steps before the issue occurs. Sometimes the variance happens before you notice it, when the page is accumulating state. > It also seems like Cypress is telling us the request is never being made. However, we can see the request being made and not being stubbed even with a cy.intercept(). This tells me you did not get the pattern correct for the
cy.intercept()
. Make sure your intercept results in an alias, then look for the alias to appear in the Test Runner log. This way you can tweak the pattern until you see the alias bubble show up.