How to mock and test Selections

Hi. Im having a hard time on jest testing the Select. Is there a sample reference online? Thank you
6 Replies
refine-support-bot
Hi, I am refine support bot :wave:. I am here to help you with your question. I searched for the answer to your question in the refine documentation and found an answer! 🏆
Answer: Refer to the refine useSelect hook documentation for more information on how to mock and test Selections. SOURCES: ./docs/api-reference/core/hooks/useSelect/index.md

Note: If this is the answer you need, then we are very lucky. If not, please wait for someone from the refine core team or the community to try to help you.
genetic-orange
genetic-orange2y ago
Hi @thedevkim, can you give me more detail ? do you wanna test <Select> component from @pankod/refine-antd ?
afraid-scarlet
afraid-scarlet2y ago
Yes i want to test the <Select> component from @pankod/refine-antd Like, the selecting of options etc. @alicanerdurmaz
genetic-orange
genetic-orange2y ago
Unfortunately, I don't have a resource in mind that I can recommend for this. maybe other people in community can recommend. but i wanna clearify something. The select component is exported from antd without any changes. So every solution you apply for antd components is also valid for refine-antd
afraid-scarlet
afraid-scarlet2y ago
The issue im getting is that, testing the events for <Select> with fireEvent. Like selecting options etc. I want to fireEvent onChange of the <Select> component in jest. Do you have any ideas?
genetic-orange
genetic-orange2y ago
Unfortunately i have not 😕 if you ask on antd forums, probably you will get faster answer