I have a component which allows users to navigate back in history using react router v6's useNavigate hook. However, the test seems to fail when I call the function with navigate(-1) but passes if I pass a string url eg. navigate("/home"). Does anyone know the right way to test navigate(-1)? Here's a codesandbox to illustrate the issue
CodePudding user response:
<button onClick={() => navigate(-1)}>go back</button>
