[React] Review: Unit Test is easy
Unit Test of React Component is a bit different, rather than verifying output of functions, Unit Test in React requires 4 extra testing purpose (Ref Artem):
Testing basic component rendering
Testing event handlers
Two most popular options are Jest and Enzyme. After spending hours in try out those tools, I end up in the great Airbnb open sourced Enzyme.
When using Jest to test a React or React Native application, you can write a snapshot test that will save the output of a rendered component to file and compare the component’s output to the snapshot on subsequent runs. This is useful in knowing when your component changes its behaviour.
jsdom + Mocha
jsdom provides React the required DOM to render to, implementing a suitable subset of browser’s DOM implementations entirely in node/io.js.
is a library that wraps packages like React TestUtils, JSDOM and CheerIO to create a simpler interface for writing unit tests (work with shallow rendering).