From 5fdd6b33fa79189c124c122381bdbc35a855ae33 Mon Sep 17 00:00:00 2001 From: Gabriel Reis Date: Mon, 9 Jan 2017 02:37:56 -0800 Subject: [PATCH] Add testID prop to Button component Summary: This PR adds the `testID` prop to the `Button` component in order to allow end-to-end tests. Closes https://github.com/facebook/react-native/pull/11526 Differential Revision: D4392137 Pulled By: ericvicenti fbshipit-source-id: d3f864aacee319e520af226cd063edef452f6fc8 --- Libraries/Components/Button.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Libraries/Components/Button.js b/Libraries/Components/Button.js index 6b19c88a0af..84982a409cd 100644 --- a/Libraries/Components/Button.js +++ b/Libraries/Components/Button.js @@ -55,6 +55,7 @@ class Button extends React.Component { color?: ?string, accessibilityLabel?: ?string, disabled?: ?boolean, + testID?: ?string, }; static propTypes = { @@ -78,6 +79,10 @@ class Button extends React.Component { * Handler to be called when the user taps the button */ onPress: React.PropTypes.func.isRequired, + /** + * Used to locate this view in end-to-end tests. + */ + testID: React.PropTypes.string, }; render() { @@ -87,6 +92,7 @@ class Button extends React.Component { onPress, title, disabled, + testID, } = this.props; const buttonStyles = [styles.button]; const textStyles = [styles.text]; @@ -110,6 +116,7 @@ class Button extends React.Component { accessibilityComponentType="button" accessibilityLabel={accessibilityLabel} accessibilityTraits={['button']} + testID={testID} disabled={disabled} onPress={onPress}>