Languages

React - onChange event doesn't work for checkbox with fireEvent in @testing-library/react

1 points
Asked by:
Creg
9600

I am writing tests for my React application and I got some problem. My checkbox does not change checked property state when I fire fireEvent.change(input!, {target: {checked: true}}) method. I use rebass library. Below I attach more details.

React component:

Test:

1 answer
4 points
Answered by:
Root-ssh
178180

Try to use fireEvent.click(...) instead of fireEvent.change(...).

Example:

1 comments
Creg
4y
I found dome discussion about the problem: https://github.com/testing-library/react-testing-library/issues/156
Add comment
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join