Complete the code to import the render function from React Native Testing Library.
import { [1] } from '@testing-library/react-native';
The render function is the main way to render components for testing in React Native Testing Library.
Complete the code to find a button by its text using React Native Testing Library.
const { getByText } = render(<MyButton />);
const button = [1]('Click me');findByText which is async or queryByText which returns null if not found.getByText returns the element with the matching text or throws an error if not found, perfect for testing presence.
Fix the error in the test by completing the assertion to check if the button is pressed.
fireEvent.press(button);
expect([1]).toHaveBeenCalled();The mock function passed as onPress should be checked if it was called after pressing the button.
Fill both blanks to query an input field by placeholder text and change its value.
const { [1] } = render(<MyInput />);
const input = [2]('Enter name');
fireEvent.changeText(input, 'John');getByPlaceholderText is used to find input fields by their placeholder text.
Fill all three blanks to test if a text element updates after a button press.
const { [1] } = render(<Counter />);
const button = [2]('Increment');
fireEvent.press(button);
expect([3]('Count: 1')).toBeTruthy();getByText for the final check which throws if not found.getByText is used to find the button and render function, while queryByText checks if the updated text exists after pressing.