Is this a bug in "@vue/test-utils" ? Or is it a bug in "Vitest" ? #2980
jason-chang
started this conversation in
General
Replies: 1 comment
-
The problem has been solved. The reason is that the event loop is not activated until the element is inserted into the DOM tree. So when we are unit testing, if we build and want the event loop to work properly, please insert the element into the DOM tree before running the test code. mount(
<SomeComponent>,
{ attachTo: 'body' } // important
) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all, I'm trying to test a Vue component with a DOM structure like this , and I'm trying to trigger a click event on the label element, but the input doesn't trigger a change event.
Demo is Here.
https://stackblitz.com/edit/vitest-dev-vitest-xyzzwj
All tests should have passed, but an error occurred.
Is this a bug in "@vue/test-utils" ? Or is it a bug in "Vitest" ?
Beta Was this translation helpful? Give feedback.
All reactions