DEV Community

Discussion on: React Jest Testing Help

Collapse
 
dorshinar profile image
Dor Shinar

First of all, there doesn't seem to be a reason for the addToList function to return a promise. Second, I've found that relying on internal implementation of a component in tests makes them fragile (for example if later on you'll want to turn your component to a fictional component). In your case that would be where you add a spy on the function.
I'd suggest that you split the tests in two - one for the Provider and one for Home, and user mocks where applicable.

Collapse
 
wolverineks profile image
Kevin Sullivan

Agreed. React Testing Library is a pretty good way to test that abode testing implementation details. testing-library.com/