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

164
Vistas
Cypress, how to preserve redux state between cy.visits

I'm currently testing our web application with cypress, and i'm having a paticular problem with the redux state being cleared between cy.visits. I'm Using cypress 8.6.0. We're using React with react-redux.

Current code in my test:

    const state = { some: thing } // a normal object with key-value pairs

    cy.visit('/B').then(() => {
      cy.window()
        .its('store')
        .then(store => {
          store.dispatch({
            type: 'SET_ORDER',
            payload: state,
         });
       });
    });

The problem with this is sometimes, the route /B loads before the disptach event happens, and the test crashes because /B relies on some state being in my redux store to function.

so i thought something like this might work:

    const state = { some: thing } // a normal object with key-value pairs
    cy.visit('/A').then(() => {
       cy.window()
        .its('store')
        .then(store => {
          store.dispatch({
            type: 'SET_ORDER',
            payload: state,
         });
       });
    })
    cy.visit('/B'); // redux state gets cleared before going to /B

But it doesn't work since Cypress clears all state between tests (but also between cy.visits in the same it() test?).

Is there anyway i can preserve my redux state throughout my test? Or atleast just when going from /A to /B?

about 4 years ago · Juan Pablo Isaza
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