0

I know of something called find in enzyme, but I'd like to know how to select a react-native element by some attribute

Yogendra
  • 57
  • 1
  • 9

1 Answers1

0

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());
})
Yogendra
  • 57
  • 1
  • 9