Not sure if it is a bug or If I'm doing something wrong.
I try to mount my main App component with shallowMount but it doesn't works. I get the following error message:
Cannot set properties of undefined (setting 'hasOwnProperty')
It happens when vue-test-utils try to mount the App Component:
...
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;
...
Here, MOUNT_COMPONENT_REF equals 'VTU_COMPONENT' and vm.$refs[MOUNT_COMPONENT_REF] isn't defined.
It is available online : https://codesandbox.io/s/prod-glitter-tnoyqt?file=/src/App.spec.js
App.vue
<template>
<div id="a-test">
{{ test }}
</div>
</template>
<script>
export default {
name: "App",
};
</script>
App.spec.js
import { shallowMount } from "@vue/test-utils";
import App from "@/App";
describe("App.vue", () => {
test("Test that fails", async () => {
const wrapper = shallowMount(App);
});
});
fixed if I upgrade to @vue/test-utils 2.0.0-rc.21
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With