2

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?

2
  • Where is the code? Commented Jan 14, 2022 at 7:39
  • Did you found a solution ? I have the same issue Commented Sep 6, 2024 at 13:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.