3 ms·
Kind of specific, but I find that in the React world, Enzyme is worse than useless for the same reasons as mentioned in this article. The tests you end up writi
by slaymaker1907 8y ago
Kind of specific, but I find that in the React world, Enzyme is worse than useless for the same reasons as mentioned in this article. The tests you end up writing just verify your XML (which generally has little to no value). Even if there is some tricky logic which needs testing, you can pretty much always just refactor your code a little bit and just use standard unit tests.
- onion2k 8y agoEnzyme is for writing integration tests rather than unit tests - a component is a whole bunch of different things interacting with the DOM. You can't really break that down in to individual units of code, so you can't unit test it. If you have complex logic in a component that needs unit tests you should probably pull that code out in to its own class and test that separately.
- Zalastax 8y agoManually writing Enzyme tests looks dumb to me but what about Jest snapshots? Their only purpose is to detect changes to prevent accidental behaviour changes. There's very little work that needs to be done to maintain those tests so I want to think they provide value. An explicit git log of how the rendered view has changed seems useful to me - especially in a pull request.
- gedy 8y agoThat is opposite my experience, we use Enzyme to assert behavior of our components and actively avoid checking the JSX. Jest snapshots sounds closer to what you are describing