Skip to content
This repository was archived by the owner on Jul 30, 2020. It is now read-only.
This repository was archived by the owner on Jul 30, 2020. It is now read-only.

How do I use getByText without it getting hung up on a <Image> inside the <Text>? #121

Closed
@Vannevelj

Description

@Vannevelj

I've got the following test:

import { Image, Text } from 'react-native';
import React from 'react';
import { render } from 'react-native-testing-library';

it('works', () => {
  render(<Text>Hello</Text>).getByText('Hello');
});

it('does not work', () => {
  render(
    <Text>
      <Image source={{}} />
      Hello
    </Text>
  ).getByText('Hello');
});

If I take out the <Image>, then it does find the text and the test passes. I've seen this issue which seems very much related but it sounds like this should have been fixed: callstack/react-native-testing-library#142

Am I using the API incorrectly?

  • "react-native-testing-library": "^1.13.2",
  • "react-test-renderer": "^16.13.1",
  • "react": "16.9.0",
  • "react-native": "0.61.5",
  • "preset": "react-native",

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