Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cypress chrome not pausing at debugger statement

I have the following code in the test:

it('shows correct language', () => {
  cy.visit('/product/my product');
  cy.changeLanguage('English');
  cy.get('[data-test=attribute-name]').should(
    (elements) => {
      console.log('this shows in console', elements);
      alert('But it wont break!!!!!!!!!!');//this alert shows
      debugger;//never breaks here
    },
  );
});

Started cypress with ./node_modules/.bin/cypress open then I run the test in the cypress window, that opens chrome and I open the dev tools manually (don't know how tell cypress to open chrome with devtools open).

It shows the message in the console and shows the alert but never actually breaks. In the sources tab the "Deactivate breakpoints" is not set so breakpoints are active.

Manually set the breakpoint and then click the "Run all test" button after the first run will pause on the manually set breakpoint but ignores the debugger statement.

like image 257
HMR Avatar asked Oct 22 '25 05:10

HMR


1 Answers

I think I've managed to solve the issue you're having

Rather than using debugger, you can use cy.debug(). But for it to work, you NEED to have your debugger/console open when running the test.

Check out this page for more info: https://docs.cypress.io/api/commands/debug.html

like image 54
Jordan Kowal Avatar answered Oct 23 '25 17:10

Jordan Kowal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!