Closed
Description
Describe the bug
getByText
can find element if text render component with text as not children (See "Steps to Reproduce" below)
-const Trans = p => p.i18nKey; // can find (error)
+const Trans = p => p.children; // everything ok
Expected behavior
I see in debug output (see screenshot below) that text exists! But API can find it(
It should work properly!
Steps to Reproduce
test('test', () => {
const { Text } = require('react-native');
const { render } = require('@testing-library/react-native');
const Trans = p => p.i18nKey;
const screen = render(
<Text>
<Trans i18nKey="My text" />
</Text>,
);
screen.debug();
expect(screen.getByText('My text')); // Error: Unable to find an element with text: My text
});
Screenshots
Output:
Versions
npmPackages:
@testing-library/react-native: ^7.2.0 => 7.2.0
react: 17.0.2 => 16.13.1
react-native: 0.66.4 => 0.66.4
react-test-renderer: 17.0.2 => 17.0.2