DEV Community

Discussion on: Understanding React Testing Library

lukeshiru profile image
LUKESHIRU

That's what I'm saying 😅 ... why would you test if the native img onLoad event works? Or if it changes something? If you do that, it seems like the component has a side effect when the image is done loading (which you'll emulate from RTL with fireEvent.load). Ideally the component shouldn't do that by itself, but actually receive it from the parent (which is easier to test, because you don't need that fireEvent at all).