Relative Content

Tag Archive for reactjsjestjsreact-testing-library

Testing an element outside of the root div, is it possible?

I’m using yet-another-react-lightbox and need to write a basic test that make sure that the light box opens upon a button click.
Upon click the library adds the element to the DOM, yet outside of the root div and I fail to capture these elements.
Is there a way to access these elements?

Jest and React Testing Library not calling functions inside onChange handler

I am trying to test button enabling and disabling in my React component. The problem is that the button is never enabled and it’s never enabled because of my calls to validateEmail() and validateForm() inside handleInputChange(). I tried removing those calls and just setting isValid to true and it worked.

Jest Expect JSX.Element in function not Matching

Hi we have an internal UI library that has function that renders the JSX.Element provided to it as parameter. Normally I would test this with react-testing-library but that is currently bugged. It works fine in the UI so I am just going to let the team who owns the library fix it. In the mean time as I wait for the fix, I mocked out the function but It’s failing to match my expected jsx element. Any ideas?