react-native-app-intro-slider
react-native-app-intro-slider copied to clipboard
Allow setting testID attributes
Hi @Jacse , I'm testing my app with detox, and in order to get my tests working I have to select the next, prev, skip and done buttons by text, but it gets a little too much work when working with many languages, or when the designer decides to change the default labels.
I think that it could be possible to add attributes like skipButtonTestID
, doneButtonTestID
, prevButtonTestID
and so on, in order to accomplish this. What do you think? Would you be interested in getting a PR for that?
Do you mean adding those extra props so it's easier to test with Detox? I am not very fond of adding extra props that don't have any functional value.
I think those props would have a functional value, as the docs say, they will be used to locate your component in end-to-end testing.
This isn't just a Detox requirement, any e2e testing tool, even native android and iOS ones, rely on this prop to be set.
The issue here is that the prop has to be propagated to lower View
s, otherwise would have no effect.
Is this issue resolved? I also need to test with detox.
Hi guys,
I've just encountered the same issue and here's what I did to resolve it.
Taking advantage of the slides prop which is an array of objects we can add another obj prop inside of each object called testID
for instance and use it on the renderItem
method available.
{
key: 'somethun',
title: 'Title 1',
text: 'Description.\nSay something cool',
image: require('./assets/1.jpg'),
backgroundColor: '#59b2ab',
testID: 'somethun-1'
},
Then we can read the testID
(make sure testID reach the native element) on the renderItem
method.
renderItem = item => <Text testID='item.testID'></Text>
On the detox test I had some synchronization issues and the way it work for me was manually disable it.
await device.disableSynchronization()
await waitFor(element(by.id('somethun-1')))
.toBeVisible()
.withTimeout(2000)
await element(by.id('somethun-1')).swipe('left')
await device.enableSynchronization();
I hope it helps. :)