Questions tagged [react-testing-library]

Questions about testing React components with the react-testing-library utility.

react-testing-library

1608 questions
17
votes
1 answer

How to test useEffect with async function and setState inside

I have set up a github project to understand how to better test react (v 16.8.0) useEffect hook. I make an api call to fetch data inside useEffect and I set the received data as state component element. My component receives the query as a prop and…
delca85
  • 876
  • 2
  • 8
  • 15
16
votes
2 answers

How to select an option from a select list with React Testing Library

I have a normal select list. I need to test handleChoice gets called when I choose an option. How can I do this with React Testing Library?