mantine
mantine copied to clipboard
Select component compatibility with React testing library data-testid and fireEvent
What package has an issue
@mantine/core
Describe the bug
I'm using the Select mantine/core component and trying to write unit tests for the parent component that uses Select where onTimeZoneChange below is a prop passed to the parent component.
return ( <Select data-testid={testIdTimeZonePickerSelect} className={classes.select} label={tokenStrings.TimeZone.Label} data={dataList} value={timeZone} onChange={onTimeZoneChange} searchable placeholder={tokenStrings.TimeZone.Prompt} withAsterisk ></Select> );
To that end, I tried tagging the Select component with a data-testid and writing a react testing library test to verify the onChange behavior.
fireEvent.change(screen.getByTestId(testIdTimeZonePickerSelect), { target: { value: targetTimeZone }, });
The onChange function does not get called.
What version of @mantine/hooks page do you have in package.json?
5.9.4
If possible, please include a link to a codesandbox with the reproduced problem
No response
Do you know how to fix the issue
No
Are you willing to participate in fixing this issue and create a pull request with the fix
None
Possible fix
No response
Is there a plan to fix this?
Yes, it is in the backlog, but there won't be any guides soon.
A guide for testing Select and other combobox components has been added to the help center – https://help.mantine.dev/q/combobox-testing