Overview:
- I refactoring script tests before I was used Enzyme to test, but now, I want to use @testing-library/react
Problem:
- I can't find a solution for setState in @testing-library/react
Overview:
Problem:
Using setState
is dangerous approach regardless testing library used.
So what you better do? Provide props, change props, call props(wrapper.find('button').filter(button => button.text() === 'Cancel').props().onClick()
for enzyme, fireEvent.click(getByText(/Cancel/i))
for RTL) and verify against what's rendered.
This way your tests will be shorter, most actual and need less changes after you update component under test.