I had a heck of a time getting enzyme to work with functional react components that use hooks this week. I've instead ended up adopting react-testing-library and no longer test for implementation details (you can't really test for implementation details with react-testing-library as its API doesn't allow for it). I also read Kent C Dodds post regarding his thoughts on testing implementation details, and it convinced me to use his library.
Pawan is working as Lead Engineer at JCP, loves to make impact to the customers or masses, comfortable throughout the stack, but presently making difference at front end, node and devops.
If you guys wants to test react hooks having access to your internal states and dispatchers use my library, is super simple: github.com/victor95pc/jest-react-h...
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks for the post 👍🏼
I had a heck of a time getting enzyme to work with functional react components that use hooks this week. I've instead ended up adopting react-testing-library and no longer test for implementation details (you can't really test for implementation details with react-testing-library as its API doesn't allow for it). I also read Kent C Dodds post regarding his thoughts on testing implementation details, and it convinced me to use his library.
Good Work Dinesh !! Really helpful.
I have been working on hooks testing in enzyme and opened a PR some time back here --}github.com/airbnb/enzyme/pull/2041
Would you like to contribute or help?
Thanks Pawan. I'll try to take a look when I find time.
Try github.com/mpeyper/react-hooks-tes.... I think it's little bit easier.
Thank you so much!
Another one is my library github.com/victor95pc/jest-react-h...
Many early birds have already started using this custom hooks library
in their ReactJs/NextJs project.
Have you started using it?
scriptkavi/hooks
PS: Don't be a late bloomer :P
use
useMemo
oruseCallback
foronChange
function inside your hookI understand why we would need to use
useMemo
oruseCallback
but to keep the example simple, it's a good idea to avoid them.Amazing! Thank you <3
what about use effect??
If you guys wants to test react hooks having access to your internal states and dispatchers use my library, is super simple: github.com/victor95pc/jest-react-h...