Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!