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

145
Vistas
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 Respuestas
Responde la pregunta

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 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