I am trying to write a test and mock out a component. However, whenever I run my test I get an error:
TypeError: getDistance is not a function
I assume that mocking a component would also remove its function calls.
Test File for TopLevel for what I have now:
jest.doMock("./NestedComponent", () => () => {
const MockName = () => {
return <div />
};
return <MockName />;
});
Component File:
const TopLevel = () => {
return (
<>
<div>
<NestedComponent />
</div>
</>
)
}
NestedComponent file
const NestedComponent = () => {
const distance = getDistance();
return (
<div>
{distance}
</div>
)
}
export default NestedComponent