React-native-testing-library: V7 getByText no longer find translation string

Created on 26 Sep 2020  路  5Comments  路  Source: callstack/react-native-testing-library

Describe the bug

In our codebase, we implement translation with jsLingui and have code like this:

// trivial implementation of Trans

const Trans = (message) => message;

const Component = () => (
    <Text>
      <Trans>There was a problem fetching data.</Trans>
    </Text>
)

Trans would render a string.
Previously, getByText("There was a problem fetching data.") would return a match and it no longer does

Expected behavior

getByText("There was a problem fetching data.") should return a match

Steps to Reproduce

See above

Screenshots

debug() would render

        <Text>
          There was a problem fetching data.
        </Text>

Versions

  npmPackages:
    @testing-library/react-native: ^7.0.2 => 7.0.2
    react: 16.11.0 => 16.11.0
    react-native: 0.62.2 => 0.62.2
    react-test-renderer: 16.11.0 => 16.11.0
bug

Most helpful comment

Experiencing this as well with react-intl

All 5 comments

This should definitely pass. cc @AugustinLF working on this field

Yep, there's some changes incoming to the way we find text in the rendered component. This use case _should_ be covered, I also feel that it was already covered. Would you mind having a look at #554 and see if it works for your use case?

Yep, there's some changes incoming to the way we find text in the rendered component. This use case _should_ be covered, I also feel that it was already covered. Would you mind having a look at #554 and see if it works for your use case?

@AugustinLF , thanks for the response. I will try today and report back

Experiencing this as well with react-intl

We are possibly experiencing this as well. We are using i18n-js and expo-localization. We are on react-native v0.63.3.

Was this page helpful?
0 / 5 - 0 ratings