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

167
Visualizações
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 à 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