Test Case:
it("Test Email text by test id" , () => {
const testIDName='email-title';
const {getByTestId} = render(
<Provider store={store}>
<NavigationContainer><Login /></NavigationContainer>
</Provider>);
const foundID=getByTestId(testIDName);
expect(foundID).toBeDefined();
})
Element Structure:
<Text testID= {'email-title'} style={styles.emailText}>Email</Text>
Error Being Thrown:
Unable to find an element with testID: email-title
63 | <NavigationContainer><Login /></NavigationContainer>
64 | </Provider>);
> 65 | const foundID=getByTestId(testIDName);
| ^
66 | expect(foundID).toBeDefined();
67 | })
68 |
Libraries utilised : - testing-library/react-native
I'm new to unit testing react native component, and not sure why element is not recognising the test ID. Any Help would be appreciated at this point