You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
This is a bit hard to describe but hopefully the reproduction demo will clear things up.
I have a big project with 7000+ thousand tests. Recent ones are good, old ones are bad and rely heavily on .vm.
I'm migrating the code base to a monorepo and the design system is now bundled as separate package by vite and the apps import the components’ bundled version instead of the .vue, tests inherently do too. I noticed that most of the tests that rely on vm stopped working.
wrapper.findComponent(VComp).vm.someMethod// someMethod is always undefined, before bundle it wasn't.
Note
I don't know if this is VTU fault or if it's by design, but having in mind that if I import the raw .vue component instead of the bundled .js version everything works I am assuming it is — Please close this issue if my assumption is wrong.
import{VExampleasVExampleRaw}from'../../packages/ui/src/VExample.vue'import{VExampleasVExampleBundled}from'ui'// swapping VExampleBundled per VExampleRaw in the components option makes it pass.it('finds exposed "vm" properties in *bundled* component wrapper via findComponent',()=>{constwrapped=mount({components: {
VExampleBundled,},template: `<div><v-example /></div>`,});consttest=wrapped.findComponent({name: 'VExample'});console.log(test.vm);// only has "a" propexpect(test.exists()).toBe(true);// failsexpect(test.vm.exposedFn).toBeInstanceOf(Function);});
Related information:
vue: 3.5.13
@vue/test-utils: 2.4.6
Additional context
The same behaviour is not found in mount. When passing the bundled version of a component to mount, exposed properties are exposed correctly to vm, that's why I think it's a bug in findComponent.
Describe the bug
This is a bit hard to describe but hopefully the reproduction demo will clear things up.
I have a big project with 7000+ thousand tests. Recent ones are good, old ones are bad and rely heavily on
.vm.I'm migrating the code base to a monorepo and the design system is now bundled as separate package by
viteand the apps import the components’ bundled version instead of the.vue, tests inherently do too. I noticed that most of the tests that rely onvmstopped working.Note
I don't know if this is
VTUfault or if it's by design, but having in mind that if I import the raw.vuecomponent instead of the bundled.jsversion everything works I am assuming it is — Please close this issue if my assumption is wrong.To Reproduce
https://stackblitz.com/edit/vitest-dev-vitest-h8drorow?file=apps%2Fdemo%2Ftest%2Fbasic.test.ts
Should run automatically, if not
npm run testExpected behavior
exposed properties via
defineExposeare available though offindComponentreturnedVueWrapperAssuming a basic
VExample.vuecomponentBundles to
Faulty test
Related information:
Additional context
The same behaviour is not found in
mount. When passing the bundled version of a component tomount, exposed properties are exposed correctly to vm, that's why I think it's a bug infindComponent.