NativeBase icon indicating copy to clipboard operation
NativeBase copied to clipboard

testID property does not map from NativeBase component to the react-native base component class

Open jrryhrtn opened this issue 8 years ago • 5 comments

Hi! Thanks for trying out NativeBase! Due to the overwhelming requests and issues/questions we ask you to add the following details with your issue.

Please check the existing open/closed issues for a possible duplicate before creating a new issue :)

Also DO fill out the below form to give us a better idea about your environment and help us debug it quicker. Issues without the required details will mostly be unattended to.

There were two issues opened/closed on this but the fix is still not present in the latest release.

#1230 XCUITest is failing because testID cannot be found when using native base components Opened by cutemachine Sep 14, 2017 5 comments

#1352 Not able to automate the app due to missing "accessibilityLabel" or "testID"

Opened by sasasa42 Nov 8, 2017 1 comment

react-native, react and native-base version

"native-base": "^2.3.10", "react-native": "0.54.2", "react": "^16.3.0-alpha.1"

Expected behaviour

When setting testID on NativeBase components the inspector displays the test id

Actual behaviour

testID is not propagated to the base react component is as such is hidden from the inspector and cannot be used when doing automation tests using Detox

Steps to reproduce (code snippet or screenshot)

import { Container, Content, Text, List, ListItem } from "native-base"; import VersionNumber from 'react-native-version-number'; import {logOut} from "../../screens/Login/actions"; import {changeMenuOptions} from "./actions"; import { connect } from "react-redux"; import styles from "./styles";

class MenuDrawer extends React.Component {

componentWillMount() {

}

render() { return ( <ListView testID="menu_list" dataSource={this.props.menuOptions} renderRow={data => { return ( <ListItem testID={"menu_list_" + data}> <TouchableOpacity style={styles.listItemLink} onPress={() => this.invokeMenuOption(data)}> {I18n.t(data)} ); }} enableEmptySections={true} />

    </Content>

  </Container>
);

}

Screenshot of emulator/device

Is the bug present in both ios and android or in any one of them?

Both iOS and Android

Any other additional info which would help us debug the issue quicker.

import React from 'react' import { Text } from 'react-native' //map testID to the base component export const Counter = ({value, testID}) => {value.toString()}

jrryhrtn avatar Apr 12 '18 19:04 jrryhrtn

After using Nuclide inspector, testID's are visible on NativeBase components.

jrryhrtn avatar Apr 13 '18 15:04 jrryhrtn

@jrryhrtn I don't understand your last comment. how do we fix this issue with nuclide?

ktajpuri avatar Feb 07 '19 08:02 ktajpuri

@ktajpuri did you manage to fix it? We're having similar problem with Tabs

EgidioCaprino avatar Feb 11 '19 10:02 EgidioCaprino

I was faced with the same issue and found such workaround:

<Tab
  key={tab.heading}
  heading={
    <TabHeading>
      <Text
        accessibilityLabel="My Tab"
        testID="My Tab"
      >
        {tab.heading}
      </Text>
    </TabHeading>
  }
>
  {tab.content}
</Tab>

dmitryt avatar Jun 24 '19 15:06 dmitryt

I was faced with the same issue and found such workaround:

<Tab
  key={tab.heading}
  heading={
    <TabHeading>
      <Text
        accessibilityLabel="My Tab"
        testID="My Tab"
      >
        {tab.heading}
      </Text>
    </TabHeading>
  }
>
  {tab.content}
</Tab>

This workaround worked for me. Btw, if you want to customize heading text style, you can read this thread. https://stackoverflow.com/questions/43113859/customise-tabs-of-native-base

duongntb94 avatar Apr 23 '20 07:04 duongntb94