Skip to content

Commit d055022

Browse files
committed
fix: add hasOwnProperty to wrapper.vm
This allows Jest to spy on the proxied vm Fixes vuejs#309
1 parent 3cd6686 commit d055022

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/mount.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,11 @@ export function mount(
441441
// if not, use the return value from app.mount.
442442
const appRef = vm.$refs[MOUNT_COMPONENT_REF] as ComponentPublicInstance
443443
const $vm = Reflect.ownKeys(appRef).length ? appRef : vm
444+
// we add `hasOwnProperty` so jest can spy on the proxied vm without throwing
445+
$vm.hasOwnProperty = (property) => {
446+
return Reflect.has($vm, property)
447+
}
444448
console.warn = warnSave
445-
446449
return createWrapper(app, $vm, setProps)
447450
}
448451

0 commit comments

Comments
 (0)