The intent to @testing-library/react is test what the user see, the things that are rendered on the DOM. As long I could read, that is the philosophy behind the library, and that just fine!
But I was wondering, how do you people test react containers when using this library?
Imagine the situation bellow:
const onChange = () => console.log('Hey!')
const Container = () => <Component onChange={onChange} />
If it was important to test that Component receives the onChange, how would you do that?
I saw some posts suggesting to mock the Component and add a CSS class (!) based on the fact if it has or has not the prop. But this does not smell very good to me.
Should we just don't test this kind of situation?
Top comments (0)