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.

React.addons.TestUtils.Simulate.scroll is not working with JSDOM

See original GitHub issue

Hi, I’m trying to test the scroll event and I could not make the scroll event propagation to happen using TestUtils:

React.addons.TestUtils.Simulate.scroll(contentDiv, { deltaY: 500 });

The above code is never triggering the scroll function callback. Then if I change the implementation to be something like this it works:

contentDiv.scrollTop = 500;

var evt = document.createEvent("HTMLEvents");
evt.initEvent("scroll", false, true);
contentDiv.dispatchEvent(evt);

Am I doing something wrong with the React TestUtils? I’ve created a stackoverflow ticket for this.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:7
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
barsukovcommented, Nov 29, 2016

Guys any activity on that issue? Currently has a trouble to test my own infinite scroll component.

1reaction
gaearoncommented, Nov 29, 2016

If there was any activity you would see it on the issue 😉 . With an issue like this, the best way to fix it is to dive into why it happens and send a PR to the project.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React.addons.TestUtils.Simulate.scroll is not working
Simulate.scroll() only simulates a scroll event dispatched by a specific React component (e.g. when you have overflow: scroll set on that component) and ......
Read more >
React.addons.TestUtils.Simulate.scroll is not working with JSDOM
Hi, I'm trying to test the scroll event and I could not make the scroll event propagation to happen using TestUtils: React.addons.TestUtils.
Read more >
Test Utilities - React
ReactTestUtils makes it easy to test React components in the testing framework of your choice. At Facebook we use Jest for painless JavaScript...
Read more >
React.addons.TestUtils.Simulate.scroll is not working-Reactjs
I realized the crux of my problem was that TestUtils.Simulate.scroll() only simulates a scroll event dispatched by a specific React component (e.g. when...
Read more >
react-addons-test-utils | Yarn - Package Manager
This solves an issue that already exists in React 17 and below, but is even more important in React 18 because React yields...
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