Chapter 3Testing React with Enzyme
JavaScript web development can be divided into two eras: pre-React and post-React. Pre-React, all was chaos. Suppose you wanted to make a button toggle a popup when clicked: you’d add code somewhere—nowhere near the button markup—to add an event listener for the button click. The event listener you’d write would directly alter the DOM to show or hide the popup. Code was scattered without rhyme or reason. Unit tests were almost unheard of.
Thankfully, we live in the age of React. Now individual pieces of the app—the button and the popover, in this example—can be isolated as components. The DOM tree they render is a pure function of their props (React parlance for data provided to the component) and their internal ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access