Debugging in software development is necessary to trace errors in your programs or scripts. In Cypress, you can use debug() method to quickly inspect any part of your application during the test.
You can attach debug() to any Cypress command chain, such as:
cy.debug().visit('https://maps.google.com') //Pause to debug at beginning of commandscy.get('.searchbox-hamburger-container').debug().type('Golden Gate Bridge') //Debug the 'get' command's yieldcy.get(‘.searchbox-searchbutton-container’).click().debug() //Debug the 'click' command's yieldcy.url().debug(true).should('eq', 'https://www.google.com/maps/search/Golden+Gate+Bridge/@37.8199286,-122.4804438,17z') //debugging is turned on
You can also pass in an options object to change the default behavior of debug() method with debug(options).
cy.url().debug(false).should('eq', 'https://www.google.com/maps/search/Golden+Gate+Bridge/@37.8199286,-122.4804438,17z') //debugging is turned off
Don’t forget to open Developer Tools in Cypress Dashboard to hit the breakpoint.
Thanks for reading.