No estoy seguro si es un error o si estoy haciendo algo mal.
Intento montar el componente principal de mi aplicación con el shallowMount pero no funciona. Recibo el siguiente mensaje de error:
No se pueden establecer propiedades de indefinido (estableciendo 'hasOwnProperty')
Ocurre cuando vue-test-utils intenta montar el componente de la aplicación:
... var appRef = vm.$refs[MOUNT_COMPONENT_REF]; // we add `hasOwnProperty` so jest can spy on the proxied vm without throwing appRef.hasOwnProperty = function (property) { return Reflect.has(appRef, property); }; console.warn = warnSave; var wrapper = createVueWrapper(app, appRef, setProps); trackInstance(wrapper); return wrapper; ... Aquí, MOUNT_COMPONENT_REF es igual a 'VTU_COMPONENT' y vm.$refs[MOUNT_COMPONENT_REF] no está definido.
Está disponible en línea: https://codesandbox.io/s/prod-glitter-tnoyqt?file=/src/App.spec.js
aplicación.vue
<template> <div id="a-test"> {{ test }} </div> </template> <script> export default { name: "App", }; </script>Aplicación.spec.js
import { shallowMount } from "@vue/test-utils"; import App from "@/App"; describe("App.vue", () => { test("Test that fails", async () => { const wrapper = shallowMount(App); }); });arreglado si actualizo a @vue/test-utils 2.0.0-rc.21