I have a simple component with two inputs and one button. I was able to test the code with getAllByRole func for buttons. But when I want to find input elements, I got below error :
Unable to find an element with role: "textbox"
This is my code :
import React from "react";
import { View, TextInput, Button } from "react-native";
const ListComp = () => {
return (
<View>
<TextInput />
<TextInput />
<Button title="Test"/>
</View>
)
}
export default ListComp;
and this is test file :
import React from 'react';
import ListComp from './ListComp';
import {
render,
screen,
} from '@testing-library/react-native';
test('renders correctly', () => {
render(<ListComp />);
expect(screen.getAllByRole('textbox')).toHaveLength(2);
});