Reputation: 107
I know of something called find
in enzyme, but I'd like to know how to select a react-native element by some attribute
Upvotes: 1
Views: 752
Reputation: 107
You can select it by any attribute like id
, e.g,
for selecting the following Text in testing.js
<Text id="myid">hello </Text>
you can do the following
it('selects Text with id attr', () => {
let wrapper = shallow(<Testing />);
let text = wrapper.findWhere(node => node.name() === 'Text' && node.prop('id') === 'myid');
console.log(text.debug());
})
Upvotes: 0