I want to test if useNavigate has been called after clicking on a button and also if it has been called with correct path in my unit test. I try to spy on it, but I keep getting the following error:
ā Test suite failed to run
TypeError: Cannot redefine property: useNavigate
at Function.defineProperty (<anonymous>)
Here is the spy in my test that triggers an error:
import * as router from "react-router-dom";
jest.spyOn(router, 'useNavigate');
What could be the problem?