Debugging Flaky Tests
Learn about different ways to debug flakes in Cypress.
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 additional buttons will appear inside of the status bar:
Get hands-on with 1200+ tech skills courses.