Im learning Jest with TypeScript and I'm facing the following type error:
Property 'mockImplementation' does not exist on type '() => Element'.
Code:
test("Should Render HomePage on Default Route", () => {
// Arrange
Home.mockImplementation(() => <div>HomePageMock</div>) // type error here
// Act
render(
<MemoryRouter>
<Routes>
<Route path="/" element={<Home />} />
</Routes>
</MemoryRouter>
);
// Assert
const element = screen.getByText("HomePageMock");
expect(element).toBeInTheDocument();
});
I have tried casting any
but that doesn't seem to solve it:
Home.mockImplementation((): any => <div>HomePageMock</div>)
Any ideas?
TIA