3 ms·
Maybe I'm missing something here, but I disagree. >> Since we are exporting a higher order component, it makes testing the component more complicated than it h
by jefflombardjr 8y ago
Maybe I'm missing something here, but I disagree.
>> Since we are exporting a higher order component, it makes testing the component more complicated than it has to be.
What exactly are you testing on the connected container components? I agree with the stack overflow article you linked to, just test the components... not the connected components. [0]
>> While this methods has very less boilerplate code and it allows us to properly test each function, it kind of a hack since we are exporting a function just to make is testable which is a code smell. We should export a part of our code only if it is being used somewhere else, not to test it.
No it's not. Unit tests are good, mocking is the real code smell here.[1] You should in fact have more of these unit tests instead of a bunch of integration tests.[2]
Your container components shouldn't be doing much other than what's listed here.[3]
[0] https://stackoverflow.com/questions/51943248/react-redux-testing-mapstatetoprops-and-mapdispatchtoprops-with-enzyme-jest https://stackoverflow.com/questions/51943248/react-redux-tes...
[1] https://medium.com/javascript-scene/mocking-is-a-code-smell-944a70c90a6a https://medium.com/javascript-scene/mocking-is-a-code-smell-...
[2] https://martinfowler.com/articles/practical-test-pyramid.html https://martinfowler.com/articles/practical-test-pyramid.htm...
[3] https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0 https://medium.com/@dan_abramov/smart-and-dumb-components-7c...