Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

126
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda