Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

120
Vistas
How to handle cypress erros?

Let's say I have simple test:

/// <reference types="cypress" />

describe('Something important', () => {

  it('First test', () => {
    ...
  })

})

And what I need to do is to handle if something happens in First test, I was trying something like, but it doesn't work this way:


it('First test', () => {
    try {
      ...
    } catch (e) {
      ... // send email, for example
    }  
})

So, in some way I need to handle whatever happens in test. Is it possible? Something like this, but for whole test:

cy.get('button').contains('hello')
  .catch((err) => {
    // oh no the button wasn't found
    // (or something else failed)
    cy.get('somethingElse').click()
  })
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Is this what you need Catching Test Failures?

Cypress.on('fail', (error, runnable) => {
  debugger

  // we now have access to the err instance
  // and the mocha runnable this failed on

  throw error // throw error to have test still fail
})

This will fire when the test fails, so you can perform your email or other action.

But generally Cypress expects you to know that the button will be there. You shouldn't have too many unpredictable things on the page (or not on the page, as the case may be).

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda