Migrate Enzyme to React Testing Library, snapshots included

Proprietary

Migrates Enzyme wrappers as org.openrewrite.react.migrate.enzyme-to-react-testing-library does, and also converts expect(wrapper).toMatchSnapshot() and expect(toJson(wrapper)).toMatchSnapshot() of those wrappers to expect(wrapper.asFragment()).toMatchSnapshot(), removing the enzyme-to-json import where nothing else uses it. RTL snapshots the rendered DOM where Enzyme's serializer recorded a component tree, so the stored snapshots of converted tests no longer match: run the tests with --updateSnapshot once and review the new snapshots. Inline snapshots and snapshots of shallow renders that are not converted are left for review.

org.openrewrite.react.migrate.enzyme-snapshots-to-react-testing-library

Optional

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-snapshots-to-react-testing-library

Install it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.