-
Notifications
You must be signed in to change notification settings - Fork 257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: How to test <teleport> #418
Comments
Things that might needs to be mentioned
|
Is anyone interested in making this PR? It would be greatly appreciated. |
I found a case where we may actually want to update VTU. In particular - I have a component which renders:
I would like to test the button by itself, without worrying about the teleport (I intend to test them in a more integrated test setup, whereas in these tests I am only concerned with the button). However, if I try to
Ultimately, the tests fail with the following error:
Stubbing I can achieve this by creating an additional component so that the tree looks like
and then I can write the UTs for |
What happens if stub Can you post the exact component and test you want to write? I think it's probably good to have an solid example so we can prototype solutions. If it can be solved with some simple boilerplate, that's probably ideal, but we should make sure it can solve all situations and is very well documented and understood. If it turns out there are some really difficult/impractical scenarios, we can add something. |
That was with It looks like Teleport doesn't have a name in vue-next - so I imagine this is the same issue as with Suspense and would require an upstream fix, no? I was able to work around my immediate issue (testing non-Teleport logic in the same component) with a |
@snoozbuster Yeah you're probably right about the lack of name in vue-next. This can be an easy PR if you want to make a contribution to Vue 3 😉 |
I'm not actually sure that it will fix it. I noticed these lines in |
Possible... maybe time to do a bit of a deep dive into exactly how Teleport and stubs work to figure this one out. |
Are there any news about it? It would be nice to have a proper way to test components using teleport. |
I will write something this week. Any particular scenarios you'd like to see documented? I see several:
Eg: <template>
<teleport to="#farAway">
<some-component :msg="dynamic" />
</teleport>
</template> Use case: you want to assert the dynamic |
You can follow my experiments and exploration here: #670 I'd like to use apply the VTU wrapper API to the teleported components and elements, too. Currently that isn't working, but I don't think it'll be too difficult to implement. |
Done: https://next.vue-test-utils.vuejs.org/guide/advanced/teleport.html. Pretty neat solution (imo). I think this probably fine for now; we can consider more helpers/utils if this doesn't suffice. |
Lots of good info here: #183
We should doc how to test regarding
<teleport>
.The text was updated successfully, but these errors were encountered: