I have encountered an issue while testing a Vue component that relies on accessing this.$parent.$props.
For example:
export default class item extends Vue {
private point = this.$parent.$props.point;
}
The error I am experiencing is:
TypeError: Cannot read property 'point' of undefined
I have attempted to use mounting options and parentComponent in my test, but I keep receiving the error message "[vue-test-utils]: options.parentComponent should be a valid Vue component options object".
This is the code snippet I have used for testing purposes:
import Parent from "@/components/Parent.vue";
let wrapper: any;
describe("item.vue", () => {
it("item vue testing", () => {
wrapper = mount(item, {
propsData: {
num: 1,
},
parentComponent: Parent
});
});
});
How can I effectively mock this.$parent.$props in my component? And what could be the mistake in the above test code?