hossein-zare / react-native-dropdown-picker

A single / multiple, categorizable, customizable, localizable and searchable item picker (drop-down) component for react native which supports both Android & iOS.
https://hossein-zare.github.io/react-native-dropdown-picker-website/
MIT License
969 stars 294 forks source link

Getting error saying that "Unable to find an element with testID: text" #720

Open prudhvieswar opened 8 months ago

prudhvieswar commented 8 months ago

I have used this component and trying to write test case using testing-library. Am getting the error "Unable to find an element with testID: text". I verified the comments and tried to implement by using the given comment.

I tried different ways. Can anyone help me out of this. Below is my code.

it('should select a different option', async () => { const pickerData = [ { label: 'ORANGE', value: 'ORANGE' }, { label: 'APPLE', value: 'APPLE' }, { label: 'WATERMELON', value: 'WATERMELON' }, { label: 'PINAPLE', value: 'PINAPLE' } // Add more options here if needed ];

const selectedOption = 'PINAPLE';

render( <Select items={pickerData} open={true} setOpen={() => (true)} value={selectedOption} setValue={(val: any) => {}} disabled={false} testID={'PINAPLE'} /> );

const Item = screen.getByTestId(
  'PINAPLE'
);

fireEvent.press(Item);

expect(screen.getByTestId('PINAPLE')).toBeDefined();