How to log an element's text in cypress.io after failure

I have a Cypress.io test using following command to fail the test after [data-cy=error] appears. I want to modify it to throw the text before failing the test. Do you have any solutions that how I can log the text?

cy.get('[data-cy=error]', {timeout: 10000})  
  .should('not.exist')

Upvotes: 2

Views: 897

Answers (1)

bbsimonbb
bbsimonbb

Reputation: 29002

Use cy.log(yourTextHere). That should work.

Upvotes: 1

Related Questions