Skip to content

Ability to query by text that is not a single node. #275

Closed
@Trancever

Description

@Trancever

Describe the Feature

It is very common to wrap one text into another to apply some additional styles. Unfortunately, this doesn't work well with testing. Currently, there is no way to query the whole text e.g.

<Text>Hello <Text>World</Text></Text>

currently queryByText('Hello World') won't find the text, but it would be really handy if it finds it.

There is also an option to change the structure of rendered components and render them one by one e.g.

<Text>Hello </Text><Text>World</Text>

but even though we do it, we have to query each text separately which doesn't make sense in most cases.

I believe queryByText('Hello World') should also somehow find the text that is divided into two sibling components.

Possible Implementations

I have no idea, but react-testing-library supports it by accepting custom matching function in getByText. Maybe it is possible to implement it in a similar way?

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions