Is there a way to test for a DOM element that shows up in a custom hook?February 11, 2020 at 6:24pm
I am using the react-hooks part of the library. I am using the renderHook function. Is it possible to get DOM elements from that to see if they have been rendered by the custom hook?
February 11, 2020 at 6:44pm
I'm not sure if I understand correctly what you mean, but:
- when using
/react-hooksyou'll get the exact result that your hook returns. If your hook is returning some elements, then you can check them directly from result returned
- you can also test hooks with just
/reactby generating a dumb component in your test that uses the hook. Then, as usual, you are able to look for whatever DOM element you need
that makes sense
I have a dialog that pops up for a confirmation if a condition is true. I will test for the dom element in a component that uses the custom hook. Thank you for your help.