diff --git a/src/vue-wrapper.ts b/src/vue-wrapper.ts index e0f28b863..73960d350 100644 --- a/src/vue-wrapper.ts +++ b/src/vue-wrapper.ts @@ -19,7 +19,9 @@ export class VueWrapper implements WrapperAPI { ) { this.__vm = vm this.__setProps = setProps - this.componentVM = this.vm.$refs['VTU_COMPONENT'] as ComponentPublicInstance + this.componentVM = this.__vm.$refs[ + 'VTU_COMPONENT' + ] as ComponentPublicInstance this.__emitted = events } @@ -42,7 +44,7 @@ export class VueWrapper implements WrapperAPI { } get vm(): ComponentPublicInstance { - return this.__vm + return this.componentVM } classes(className?: string) { diff --git a/tests/vm.spec.ts b/tests/vm.spec.ts new file mode 100644 index 000000000..0d909d5c6 --- /dev/null +++ b/tests/vm.spec.ts @@ -0,0 +1,21 @@ +import { defineComponent, ref } from 'vue' + +import { mount } from '../src' + +describe('vm', () => { + it('returns the component vm', () => { + const Component = defineComponent({ + template: '