My situation may differ from the OP, but I struggled with a similar problem and found my way here after repeated searches. I realized that the main problem is that TestUtils.Simulate.scroll() only mimics the scroll event dispatched by a specific React component (for example, when you have overflow: scroll installed on that component), and not the scroll event dispatched window .
In particular, I tried to check the scroll handler that was configured in the React class as follows:
componentDidMount: function () { window.addEventListener('scroll', this.onScroll); }, componentWillUnmount: function () { window.removeEventListener('scroll', this.onScroll); },
To check onScroll() , I finally realized that I had to simulate sending a scroll event from window , for example:
document.body.scrollTop = 100; window.dispatchEvent(new window.UIEvent('scroll', { detail: 0 }));
This worked great for me.
source share