question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cypress visit onBeforeLoad is not updating react redux state

See original GitHub issue

Current behavior

Till cypress 9.7, we are able to update initial redux state, which is not updating from version 10.

Desired behavior

No response

Test code to reproduce

cy.fixture(fixture-path.json)
  .as('initialState')
  .then(initialState) => {
    cy.visit(localhost:8080,{
          onBeforeLoad: (window: any){
            window.initialState = initialState
         },
     })
   })

Cypress Version

10.1

Other

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
hoguancommented, Jun 27, 2022

We are encountering the same issue on Cypress 10.0.3.

Here is a reproducible example if it helps.

it('onload', function() {
  cy.on('window:before:load', (e) => {
    console.log('window:before:load');
  });

  cy.on('window:load', (e) => {
    console.log('window:load');
  });

  cy.visit('/', {
    onBeforeLoad(win) {
      console.log('onBeforeLoad');
    },
    onLoad(win) {
      console.log('onLoad');
    }
  });
});

Current behavior: Produces this logs:

window:load
onLoad

Desired behavior:

window:before:load
onBeforeLoad
window:load
onLoad

Versions Cypress version: 10.0.3 Browser: Chrome 103 OS: macOS Monterey, Version 12.4

0reactions
emilyrohrboughcommented, Jul 11, 2022

Unfortunately we have to close this issue due to inactivity. Right now there doesn’t seem to be enough information to reproduce the problem on our end. We’ll have to close this issue until we can reproduce it. This does not mean that your issue is not happening - it just means that we do not have a path to move forward.

Please open a new issue with a reproducible example and link to this issue. Here are some tips for providing a Short, Self Contained, Correct, Example and our own Troubleshooting Cypress guide.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Testing Redux Store - Cypress
In this blog post I will show you how to run assertions against a React application that uses a Redux store. This blog...
Read more >
React/Redux not updating the state - Stack Overflow
What I want to do is to store my login response for me to use the user details on other page. LandingPage.js import...
Read more >
cypress-io/cypress - Gitter
In redux app, input box change will trigger an action to be dispatched, and be processed by the root reducer to create a...
Read more >
Cypress test events from DOM elements - The Koi
In this guide, you will learn how to listen on DOM events in Cypress. You will not just see how to listen with...
Read more >
How to access Redux state in Cypress - Aditya.
Accessing redux store from our react application and using it in cypress integration testing.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found