React & Modern Frontend (445 Qs)•Part 4: React Testing & Jest (95 - 100)
What is the purpose of ReactTestUtils package?
ReactTestUtils are provided in the with-addons package and allow you to perform actions against a simulated DOM for the purpose of unit testing.
Practical Code Example
jsx
// ReactTestUtils: Low-level testing primitives (largely superseded by React Testing Library):
import ReactTestUtils from 'react-dom/test-utils';
import Button from './Button';
const component = ReactTestUtils.renderIntoDocument(<Button label="Submit" />);
const domNode = ReactTestUtils.findRenderedDOMComponentWithTag(component, 'button');