Closed ankiii16 closed 3 years ago
I haven't added testing support in this yet
@ankiii16 if you add inputProps={{ testID: "id" }} to the dropdown component you can access the input with jest
if any one else is searching for a solution here is an example of how I managed it:
in the component
<DropDown
inputProps={{ testID: "theID" }}
... />
and in the test:
const DropDownInput = component.getByTestId('theID');
await act(async () => {
fireEvent.press(DropDownInput);
});
await act(async () => {
// list items do not have a useful identifier and byText wasn't working
// ( probably because the text is in a child element and the menuitem holds the
// function call )
const options = component.getAllByRole("menuitem");
fireEvent.press(options[1]);
});
I cannot event find element with testid or label or anything. Please help me out here.