-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
here the link to my github: |
Beta Was this translation helpful? Give feedback.
-
The test breaks because the Next.js router is not available in the jest tests. You need to mock it. Additionally you are nesting a You component should look like this: const router = useRouter();
const changeToFalse = useStore(state => state.changeToFalse);
function onButtonClick() {
changeToFalse();
router.push('/countdown');
}
return (
<StyledButton
data-testid="countdownbutton"
variant="countdownButton"
onClick={onButtonClick}
>
<Icon variant="play" size="80px" color="black" />
</StyledButton>
); Then add the router mock to your test like this: https://github.com/orgs/neuefische/discussions/110 |
Beta Was this translation helpful? Give feedback.
The test breaks because the Next.js router is not available in the jest tests. You need to mock it.
Additionally you are nesting a
button
inside ana
element, which is incorrect. It should either be a simple link (a
element) or abutton
with additional functionality - which is your case. You can useuseRouter
to switch between pages.You component should look like this: