Skip to content

testing-library can't find i18next Trans texts #964

Closed
@ghost

Description

Describe the bug

I'm using a <Trans/> component from react-i18next module to translate complex react elements (without mocking it)

It works well in React Native runtime:
image

  • But when I tried to find elements by text it doesn't work
  • When I used debug() text that I'm trying to find exists

Expected behavior

//...
const screen = render(<Text><Trans t={t}>My test</Trans></Text>)

screen.getByText('My test') // will work

Steps to Reproduce

git clone https://github.com/retyui/testing-library-and-i18next-issue
cd testing-library-and-i18next-issue
yarn
yarn test

Screenshots

Full code you find here https://github.com/retyui/testing-library-and-i18next-issue

      <Text>
        <Trans t={t}>My test</Trans>
      </Text>

      <Text>
        <Trans t={t}>
          Open <Text style={styles.link}>link</Text>
        </Trans>
      </Text>

      <Text>
        <Trans t={t} values={{name: 'callstack'}}>
          Hello <Text style={styles.bold}>{'{{name}}'}</Text>!
        </Trans>
      </Text>

image

Versions

  npmPackages:
    @testing-library/react-native: ^9.1.0 => 9.1.0 
    react: 17.0.2 => 17.0.2 
    react-native: 0.68.0 => 0.68.0 
    react-test-renderer: 17.0.2 => 17.0.2 

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions