Open athomann opened 7 years ago
Not really: this library is specifically for checking the DOM event chain in the browser, because not everything on a page is is managed by React, so it's not about "clicking on other components in the same app" but literally "clicking any HTML element in the DOM on this page, regardless of what put that HTML element there, and what -if anything- manages it" =)
This sounds like something to find a solution for in the Jest configuration(s), not something that can be fixed in this library.
We've ended up pulling everything out except this HOC and wrapping it inside the index.jsx
. The component would be combobox/combobox.jsx
or something and that's what we import in Jest unit tests. I've not tried switching it out for integration testing.
import onClickOutside from 'react-onclickoutside';
import Combobox from './combobox';
export default onClickOutside(Combobox);
Also probably you could solve it with similar approach as here - https://github.com/andreypopp/react-textarea-autosize#how-to-test-it-with-jest-and-react-test-renderer
It appears the user of
findDOMNode
prevents the ability to test components using the HOC. Is there a way to create the same functionality withoutfindDOMNode
. Use of refs? I'd be happy to help.