cy.pause() now pauses test while running cypress run --headed --no-exit


Cypress gives us the ability to stop the test at a spot via cy.pause() command. We can use this to stop the test before any action or assertion that is causing our tests to fail. But this command only works when we run Cypress in GUI mode and, it is ignored when we run the tests in headless mode.

Before

Before version 8.6.0 cy.pause() was ignored if we run our tests via cypress run --headed --no-exit command.

describe("example", () => {
  it("should not pause the test", () => {
    cy.visit("www.google.co.in");
    cy.pause();
    cy.contains("India");
    cy.get('input[value="Google Search"');
  });
});

Now, if we run the above test via the cypress run --headed --no-exit command, then we notice from the image below that our test has not paused.

After

From Cypress 8.6.0 cy.pause() works the same with cypress open and cypress run command when --headed and --no-exit flags are passed to cypress run.

describe("example", () => {
  it("should pause the test", () => {
    cy.visit("www.google.co.in");
    cy.pause();
    cy.contains("India");
    cy.get('input[value="Google Search"');
  });
});

Now when we run the above test via cypress run --headed --no-exit command then we notice from the image that our test has paused.

To know more about this, check out the PR.

Join Our Newsletter