How do I trigger a change event on radio buttons in react-testing-library?

Posted by Prem Tiwari | Updated on

How do I trigger a change event on radio buttons in react-testing-library?

First, you don’t have to call rerender. You use rerender only when you want the component to receive different props. See link.

Whenever you call fireEvent the component will render like it would in your normal app. It’s correct to fire a change event, but you must pass a second parameter with the event data.

This example works:


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers