I am using animate function to animate height of a div. The code looks like this and happens in useLayoutEffect
:
const animation = ref.current.animate(
{ height: [oldHeight, newHeight] },
{ duration: 100 }
);
And my component JSX looks like :
return (
<div ref={ref}> {children} </div>
)
But during testing with react-testing-library
I get the error ref.current.animate
is not a function. I confirmed that ref.current
is defined. How can we mock this function with Jest
. Went through Jest documentation on mocking functions , window object etc but couldn't find info on how to mock these functions on dom nodes.