-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
@testing-library/react
version: 14.1.2- Testing Framework and version: jest, 29.7.0
- DOM Environment:
"jest-environment-jsdom": "^29.7.0"
Relevant code or config:
custom hook:
https://github.com/kasir-barati/my-nextjs-journey/blob/main/libs/hooks/use-update-effect.hook.ts
Test case:
What you did:
I was just making sure that my hook reset the useRef
on component unmount and not rerender (like when your states changes and react rerenders it), So I wrote the mentioned unit test to check that out.
What happened:
https://github.com/kasir-barati/my-nextjs-journey/blob/main/README.md#bug
Reproduction:
https://github.com/kasir-barati/my-nextjs-journey/
Problem description:
AFAIK rerender should not cause useEffect to call cleanup callback since it should be invoked only when the component is unmounted. But here it is not the case. I thought something is wrong with the testing library. But I am not 100% sure and also not does not have the confident to do that. So please feel free to enlighten me on what IDK. 🙏
Suggested solution:
Do not have any