Skip to content

getAllByTestId is missing #161

@ccfz

Description

@ccfz

Versions

"react": "16.8.3",
"react-native": "0.59.0",
"react-native-testing-library": "^1.6.0",
"react-test-renderer": "^16.8.4"

Description

getAllByTestId appears to be missing, it is listed as a query in the docs.

Screenshot 2019-04-24 at 13 28 58

Reproducible Demo

src:

import React from 'react';
import { Text, View } from 'react-native';

const OptionList = ({ options }) => {
  const renderOptions = (optionList) => {
    return optionList.map(visibleOption => (
      <Text
        key={option.id}
        testID="optionContainer"
      >
        {option.text}
      </Text>
    ));
  };

  return (
    <View>
      {renderOptions(options)}
    </View>
  );
};

export default OptionList;

spec:

import React from 'react';
import { Text } from 'react-native';
import { render } from 'react-native-testing-library';

import OptionList from 'src/components/OptionList';

const buildTestProps = props => ({
  options: [
    { id: 1, text: 'Frodo Card' },
    { id: 2, text: 'Gandalf Card' },
    { id: 3, text: 'Sauron Card' },
    { id: 4, text: 'Elrond Card' },
    { id: 5, text: 'Pippin Card' }
  ],
  ...props
});

let props;
let wrapper;

beforeAll(() => {
  props = buildTestProps();
  wrapper = render(<SwipeSelect {...props} />);
});

describe('SwipeSelect', () => {
  it('renders the options', () => {
    expect(wrapper.getAllByTestId(Text).length).toEqual(5);
  });
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions