Last active
November 23, 2019 13:06
-
-
Save Frank1234/ab5eacf58a153b606f9c0ed01257e18a to your computer and use it in GitHub Desktop.
Class that can add testIDs on both Android and iOS debug builds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Platform} from 'react-native'; | |
const getPlatformTestId = (id: string) => | |
Platform.OS === 'ios' ? {testID: id} : {accessible: true, accessibilityLabel: id}; | |
/** | |
* Adds a testID to the views on Android and iOS in their specific ways. On Android, | |
* this will result in a ContentDescription on Debug builds (and no changes on live builds). | |
*/ | |
const setTestID = (id : string) => | |
__DEV__ ? getPlatformTestId(id) : null; | |
export default setTestID; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment