We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
.getComponent fails to get a component when it is lazy loaded
.getComponent
Let A and B be two components
A.vue
<template> <div><B/></div> </template> <script> import B from './B.vue'; export default { components: { B, }, }; </script>
B.vue
<template> <div>Hello from B</div> </template>
This rightfully works
import { shallowMount } from '@vue/test-utils'; import A from './A.vue'; import B from './B.vue'; const wrapper = shallowMount(A); wrapper.getComponent(B);
but when changing A to import B asynchronously, it does not anymore
<template> <div><B/></div> </template> <script> export default { components: { B: () => import('./B.vue'), }, }; </script>
I made a reproducible repo https://github.com/ninofiliu/vue-test-bug
Gets the component
Fails with
Unable to get [object Object] within: <div> <!----> </div>
await wrapper.vm.$nextTick()
const wrapper = shallowMount(A, { stubs: { B }});
The text was updated successfully, but these errors were encountered:
Used the same solution as in #1279 and it works as expected
https://github.com/ninofiliu/vue-test-bug/commit/b852816f575da8734e0c20b24046c656c41d11da
babel.config.json
{ "presets": [ ["@babel/preset-env", { "targets": { "node": "current" } }] ], "plugins": ["dynamic-import-node"] }
Thanks @hachichaud for pointing me in this direction!
I do think this workaround belongs in the documentation, though
Sorry, something went wrong.
@lmiller1990 Should we update the docs with any information?
No branches or pull requests
Subject of the issue
.getComponent
fails to get a component when it is lazy loadedSteps to reproduce
Let A and B be two components
A.vue
B.vue
This rightfully works
but when changing A to import B asynchronously, it does not anymore
A.vue
I made a reproducible repo
https://github.com/ninofiliu/vue-test-bug
Expected behaviour
Gets the component
Actual behaviour
Fails with
Possible Solution
await wrapper.vm.$nextTick()
does not helpThe text was updated successfully, but these errors were encountered: