Migrate Enzyme to React Testing Library
ProprietaryMigrates Enzyme mount wrappers whose every use is a supported DOM read or event (find(selector).length, .exists(), .text(), .html(), .hasClass(), positions through .at(n), .first(), .last(), the wrapper's text() and exists(selector), found nodes as a toHaveLength subject, setProps as a rerender of the cloned element, and on React 17 simulate with common mouse, keyboard, focus, form, and touch events, including nativeEvent mocks) and bare mount statements to React Testing Library container queries, rerender, and fireEvent in packages using React 16.9+/17 with RTL 10 to 12, adding RTL 12 where it is missing. Selectors are limited to HTML or SVG tag, class, ID, and pass-through attribute compounds and their descendant combinations. Reports remaining Enzyme usages for manual review. Requires an existing DOM test environment; shared wrappers, props, and snapshots are left for review.
org. openrewrite. react. migrate. enzyme-to-react-testing-libraryOptional
Whether a position into the matches of a selector with a compound that names no tag, such as find('.slice').at(1), is converted. Enzyme also matches a component that receives the class, ID, or attribute as a prop, which shifts the positions of the elements after it; converting assumes that no component in the rendered tree receives it. Defaults to true; set it to false to convert only positions into tag-qualified matches.
mod run . --recipe= org. openrewrite. react. migrate. enzyme-to-react-testing-libraryInstall it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.