I am using the latest react-select (https://react-select.com/home) and react-testing-library (https://testing-library.com/docs/react-testing-library/intro/) with jest-dom (https://github.com/testing-library/jest-dom).
I am able to interact with the react-select component in the tests via react-select-event (https://github.com/romgain/react-select-event) successfully.
The problem is when I try to test the value of the react-select component. Neither of toHaveValue()
, toHaveDisplayValue()
and toHaveTextContent()
are working and I don't want to use toHaveFormValues()
as I think that goes against the guiding principles of react-testing-library.
Migrating to another solution that would provide me with select component is too much work at this point. I realise that I probably could write my own selector to retrieve the value, but I am not quite sure how to go about it.
Does someone has experience with this and could provide me with a working code snippet?