Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/vue-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -42,7 +44,7 @@ export class VueWrapper implements WrapperAPI {
}

get vm(): ComponentPublicInstance {
return this.__vm
return this.componentVM
}

classes(className?: string) {
Expand Down
21 changes: 21 additions & 0 deletions tests/vm.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { defineComponent, ref } from 'vue'

import { mount } from '../src'

describe('vm', () => {
it('returns the component vm', () => {
const Component = defineComponent({
template: '<div>{{ msg }}</div>',
setup() {
const msg = 'hello'
const isEnabled = ref(true)
return { msg, isEnabled }
}
})

const wrapper = mount(Component)

expect((wrapper.vm as any).msg).toBe('hello')
expect((wrapper.vm as any).isEnabled).toBe(true)
})
})