I am trying to test a dropdown component with React Testing Library. I need to set the value of the component, but I cant get the node with the query selectors provided by React Testing Library.
Component Generated Code:
Code: Select all
<Dropdown
id="activity"
name="activity"
options={[
{ label: "Option Label", value: "Option Value" },
]}
optionLabel="label"
value={state?.activity}
onChange={(e) => handleChangeState(e.target.name, e.target.value)}
/>
Code: Select all
fireEvent.input(
screen.getByRole("combobox", { name: /activity/i, hidden: true }),
{
target: { value: "Option Value" },
}
);