I'm new to react testing library so this may be easy, but I currently have a dropdown that I'm importing from fluent UI, and currently getting a "The element does not have a value setter" error when I try to test it using React Testing library. Here's my render function.
import { Dropdown, IDropdownStyles, IDropdownOption } from 'office-ui-fabric-react/lib/Dropdown';
import { Stack } from 'office-ui-fabric-react/lib/Stack';
render()
{
return (
<div className="LandingPage">
<h3>Here are some options</h3>
<form onSubmit={this.handleSubmit}>
<Stack>
<Stack.Item align="center">
<Dropdown
placeholder="Select an option"
label="Select an option"
options={this.options}
styles={this.dropdownStyles}
onChange={this.handleChange}
data-testid="myId"
/>
</Stack.Item>
</Stack>
</form>
</div>
);
}
}
Here is the line that is failing:
const dropdownOption: IDropdownOption = {
key: "0",
text: "dropdownOption"
}
fireEvent.click(queryByTestId("myId"), { target: { value: 'B' }, option: dropdownOption })
The given element does not have a value setter
> 44 | fireEvent.click(queryByTestId("myId"), { target: { value: 'B' }, option: dropdownOption })
| ^