Debugging Flaky Tests
Explore how to debug flaky tests in Cypress using the cy.pause command and other best practices. Understand techniques to isolate test failures, ensure consistent test environments, and avoid false negatives. This lesson helps you stabilize your end-to-end testing and improve test reliability.
Another powerful built-in command for debugging test cases is the cy.pause command. Unlike cy.debug, this does not set a debugger in the code. Rather, it stops the Cypress command from running whatever it is attached to. Why is it useful? It allows us to interact with the application and step through each command one-by-one, followed by the pause command.
Pausing commands
To use cy.pause, we can chain it off from other Cypress commands or call it on its own. We can also chain other commands from it:
cy.get('@cookiePolicyBanner').pause(); // Pause after the `get` command is executed
cy.pause().get('@cookiePolicyBanner'); // Pause before the `get` command is executed
If we run the above commands, we can see that ...