Closed Codnpix closed 4 years ago
Hi @Codnpix! You should be able to fix this by passing testID
in via the textProps
property. That way testID
will be passed directly to the TextComponent
that gets rendered, and should be visible to detox. Let me know if that works for you :)
Hi @jaydenwindle , I tried to do something like that :
import PhoneInput from "react-native-phone-input";
// ...
<PhoneInput
value={this.state.formatedPhoneNumber}
ref={ref => {
this.phone = ref;
}}
onPressFlag={this.handlePhonePressFlag}
initialCountry={this.state.cca2}
onChangePhoneNumber={this.handlePhoneChange}
textStyle={styles.phoneTextStyle}
style={styles.phoneInput}
textProps={{testID: this.props.testID}}
/>
But my component keeps returning null in the Detox test... Is this the syntax you're telling me about ?
Hi, it worked finally ! I don't know why it didn't the first time ... Some mysteries remains but thanks :).
Unable to detect react-native-phone-input component with Detox
We use PhoneInput from the react-native-phone-input package and it seems like the testID property is not supported. testID is the standard prop for testing native components with Detox and other testing tools, I'm able to use it on most of other native components but unfortunately not this one.
Could you update the package including testID prop support, or tell me if there is an alternative way to make that component and a testing program like Detox working together ?
Some snippets from my code in case you see something wrong in it : the component:
and the test I'm trying to pass looks like this :
Package.json:
Config:
Thank you for your help :).