fkhadra / react-on-screen

Check if a react component in the viewport
https://fkhadra.github.io/react-on-screen/
MIT License
405 stars 50 forks source link

Setting isVisible to true with Jest, or else how to set ref? #43

Open 9bits opened 5 years ago

9bits commented 5 years ago

Is it possible to set isVisible to true using Jest?

I want to be able to test whether my function is being called when the element is visible.

Setting the window.innerWidth and window.innerWidth doesn't work, and isVisible is still false.

If it's not possible to set isVisible to true, how can I achieve my testing objectives?

yemi commented 5 years ago

Having the same issue isVisible gets set to false and my test breaks due to logic being performed when !isVisible