But when I check the document.body.children.length the value is 0 (no elements). I check the createTestHarness and understood that is not possible to test this way, but I want to confirm this.
I will test with @testing-library/react using a dummy component but is not too good to my case.
What is your question:
I have a custom hook that checks the document using
querySelector
to get some information (like width, height, x, y, etc...) about a component.I would like to test this hook using react-hooks, but this hook needs the DOM to work. So I try a test using a wrapper:
But when I check the
document.body.children.length
the value is 0 (no elements). I check the createTestHarness and understood that is not possible to test this way, but I want to confirm this.I will test with
@testing-library/react
using a dummy component but is not too good to my case.Thanks!