Open mrdulin opened 3 years ago
I don't know why I should call wrapper.update() here.
Enzyme effectively takes a snapshot of your UI after the initial mount
and when you call various Enzyme methods (eg. wrapper.setProps(...)
). If you do something which causes the UI outside of Enzyme, such as the act
block here, you need to tell Enzyme that the output as changed and it should take a new snapshot that you can then query. This is what wrapper.update()
does.
From experience working with developers on my team this aspect of Enzyme can be pretty confusing if you've not developed a good mental model of how it works. It would definitely improve the user experience if the need for this could be eliminated.
@robertknight fwiw v2 did this automatically; unfortunately (as i've come to believe in time) v3 changed this behavior to require an explicit update
.
I have same issue here but in my case, I dont use any setTimeout
magic to make Enzyme snapshot out of date.
https://github.com/enzymejs/enzyme/issues/2542
Seem that Enzyme's .setProps()
does not make Enzyme sync the snapshot as expected. It still requires an additional .update()
to be call.
Current behavior
SomeComponent.tsx
:SomeComponent.test.tsx
:If I don't call
wrapper.update()
method, the changed state will not reflect in the view.test result
Expected behavior
I don't know why I should call
wrapper.update()
here. As you can see, the state is changed, but the value of thevisible
prop is not changed.API
Version
Adapter