formik-mui icon indicating copy to clipboard operation
formik-mui copied to clipboard

support for @testing-library/react with Select

Open ian5484 opened this issue 5 years ago • 2 comments

I am having trouble triggering the onChange or setValues when dispatching a change event when using a Select. Would you be able to provide an example for this? I have a suspicion this might be a bug.

Here is what I have been trying:

fireEvent.change(container.querySelector('input[name="phoneNumber"]'), { target: { value: "18005551234" } });

This works for basic fields like TextField but I think some of the onChange shims might be interfering the dispatched change event for Select.

The values prop in the Formik render scope never updates if the input is from the Select, however immediately updates if it's a TextField.

ian5484 avatar Dec 17 '19 00:12 ian5484

@testing-library/react has been integrated into the project but not all the components have the better tests yet.

cliedeman avatar Jan 20 '20 06:01 cliedeman

in tests i typically mock all material ui components. do you have a reason for not doing so here? it is much easier just to replace all material ui inputs with native html tags. i think you can trust material-ui's internal unit tests to verify that a select input works the way it's supposed to.

pskfry avatar Apr 01 '20 01:04 pskfry