I am creating a lazyload image loader component that will load image if it is visible for more than 500ms.
It is working as expected but I am unable to write a test to validate it
I have tried jest.runallTimers, setTimeout but no success. I have googled about how to test code with settimeout in useEffect hook but none have worked for me.
I am sharing a codesandbox link in case anybody interested to help.
https://codesandbox.io/s/optimistic-aryabhata-1dtru?file=/__tests__/index.test.js