Is it possible to mock function in Jest / React / React testing library to get code coverage.
A simple example:
import React from 'react';
interface NewProps {
children: React.ReactNode;
}
const handleClick = () => alert('hello');
const New: React.FunctionComponent<NewProps> = (props: NewProps) => {
return (
<h1 className="heading">{props.children}</h1>
<button onClick={handleClick()}>Click</button>
)
}
export default New;
So for example say I wanted to get coverage for the handleClick function, would I need to mock it?, I say this because some methods I have, are not as simple as this and to test them I was thinking of mocking the function, would that get the coverage?