Skip to content

Migration guide from @testing-library/react-native is missing some breaking changes #477

Closed as not planned
@TAGraves

Description

@TAGraves

Hey all,

Stoked to see the two react-native testing libraries have finally merged! At Root, we have a fair number of testing library tests in our react native project. I tried upgrading @testing-library/react-native from v6 to v7 and about 20% of our tests are failing after following the upgrade guide.

Another engineer will be taking a closer look at the upgrade (I was just trying to get an idea of the effort involved), but looking through the errors I see at least the following undocumented breaking changes:

getByLabelText(...).getProp is not a function (see https://www.native-testing-library.com/docs/next/api-test-instance#getprop) -- this one is obviously replaced with .props instead

baseElement is undefined (see https://www.native-testing-library.com/docs/next/api-main#baseelement)

parentNode is undefined (see https://www.native-testing-library.com/docs/api-test-instance#parentnode) -- this one is really important for us as we use it a lot for testing styles in cases where we can guarantee what the "native" parent will be. From a quick check I'm not sure if there is a new equivalent (.parent behaves differently since there's no concept of a NativeTestInstance now)

string precision options are missing (see https://www.native-testing-library.com/docs/next/api-queries#precision)

If there are existing ways to migrate from these old patterns to the new ones, we'd love to hear it and see it added to the migration guide. If not -- we'd likely be happy to contribute to add some of this functionality back in!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions