A
A
Alexey Nikolaev2019-12-10 14:11:44
Unit testing
Alexey Nikolaev, 2019-12-10 14:11:44

Is it possible to check for the occurrence of an element outside the scope?

Good day.
Testing components with vue-test-utils and jest. There is a component in which pressing a button implicitly causes the appearance of a modal window, while nothing changes in the local state (this way one could check the state of some isModalOpen). The only solution here seems to be to check if the element exists in the DOM. But there's a problem.
As we all know, vue-test-utils in the tests suggests creating a wrapper that has a number of methods for accessing the component's DOM. With wrapper, you can test the rendering of a component in its various states. However, wrapper does not allow you to reach the outer scope, document and others like them. You can, of course, give the component a root in the form of App, and then make wrapper.vm.$parent, but again, it is impossible to check the DOM of the component outside the wrapper API - only if with refs, and this approach does not work there.
In general, how to test the opening of a modal window using vue-test-utils? Who faced?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question