I have the following React Native code in a component called MyComponent:
<Text> {Constants.MY_TEXT} </Text>
I am trying to test it like this with enzyme:
const wrapper = shallow(
<MyComponent/>
);
expect(wrapper.find(<Text> {Constants.MY_TEXT} </Text>)).toHaveLength(1);
However, the test fails because 0 occurrences of <Text> {Constants.MY_TEXT} </Text> are found.
I think this is because wrapper.find does not understand the argument I am passing to it.
I also tried searching just for the text, without the tag:
expect(wrapper.find({Constants.MY_TEXT})).toHaveLength(1);
However, this fails with:
Unexpected token, expected ,
Any idea how to make the test see the Text tag?