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

149
Visualizações
Cypress after() called only after success

I have a cypress test for my web application, being a set of blocks:

describe('Test Page X', function () {
    before(function () {
      cy.navigateTo('page-x', 0)
    })
    it ('should work', function(){
      cy.doSomething()
    })
    after(function(){
      cy.navigateBack()
    })
  })

The problem is, that after() is called only when it() works, if it() failes because of some error on the page X, after() is not called, and as a result, the test got stuck on the page X, and the following tests for pages Y, Z etc. also fails.

Am I doing something wrong here? How to make after() that is always called?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

There might be a technical solution, but there's an architectural solution.

Cypress discourages using after hooks for cleaning states after your tests. That's basically what you do right now.

if it() failes because of some error on the page X, after() is not called, and as a result, the test got stuck on the page X, and the following tests for pages Y, Z etc. also fails.

That has an easy solution in that you can navigate to pages Y, Z from before hooks, or directly from the tests.

You can check Cypress recommendation on this topic here.

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