Skip to content

Commit

Permalink
fix: add hasOwnProperty to wrapper.vm
Browse files Browse the repository at this point in the history
This allows Jest to spy on the proxied vm
Fixes #309
  • Loading branch information
cexbrayat committed Feb 25, 2021
1 parent 3cd6686 commit d055022
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/mount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,11 @@ export function mount(
// if not, use the return value from app.mount.
const appRef = vm.$refs[MOUNT_COMPONENT_REF] as ComponentPublicInstance
const $vm = Reflect.ownKeys(appRef).length ? appRef : vm
// we add `hasOwnProperty` so jest can spy on the proxied vm without throwing
$vm.hasOwnProperty = (property) => {
return Reflect.has($vm, property)
}
console.warn = warnSave

return createWrapper(app, $vm, setProps)
}

Expand Down

0 comments on commit d055022

Please sign in to comment.