How to Unit Test dom whose v-if is false by vue

for example, there is a button:
whose evaluation property in v-if returns false (the evaluation property does not have a setter).
so how to trigger the click event of the button through wrapper in the unit test. (button is not rendered at all, and the calculation property cannot be changed to true without setter.)
the temporary idea is to replace it with v-show

.
Jun.10,2022
Although

has not been practiced, I think the idea should be in the unit test file. First, set the value of the v-if bound data to true, and let him render the tag in the template before testing. My assumption is that since unit tests can be introduced into view components, it should be feasible to modify the values in them.


if you just want to detect the logic of a method, you can call the method directly with vm, not necessarily with dom.

Menu