To use DOM Testing Library with React, we’ll write a custom render function that utilizes the getQueriesForElement function. Because React binds all event handlers to the body we’ll have to append our container to the body and we’ll add a cleanup method to unmount the component and cleanup the DOM. If you like this, checkout react-testing-library.

If you like this, checkout React Testing Library.