Considering the React component

Generally, we want to avoid unit-testing third-party libraries. So, let's separate the third-party aspects of a React component from the parts that we would potentially unit-test.

The third-party aspects include any inherited features and functionality; this includes to some degree any life cycle methods and the JSX. So, what's left? The answer to this question depends on whether the component in question is a presentational component or a container component.

Presentational components are almost pure HTML and view mechanisms. There is almost no traditionally unit-testable behavior. Certainly, there is no real business logic.

Container components are where the real action happens in a React application. These components can manipulate data and make business decisions that can control the flow of the application. So, let's keep container components in the list of possible places to start our unit-testing efforts.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.10.182