Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何模拟和测试此项。使用vue测试utils在vue中使用$parents_Javascript_Unit Testing_Vue.js_Vuejs2 - Fatal编程技术网

Javascript 如何模拟和测试此项。使用vue测试utils在vue中使用$parents

Javascript 如何模拟和测试此项。使用vue测试utils在vue中使用$parents,javascript,unit-testing,vue.js,vuejs2,Javascript,Unit Testing,Vue.js,Vuejs2,我正在尝试测试一个vue组件,该组件中使用了$parents.props e、 g 我认为我需要嘲笑它的原因。$家长。$道具是因为我犯了这样的错误 TypeError: Cannot read property 'point' of undefined 我已尝试装载选项parentComponent,但它抛出一个错误,提示“[vue test utils]:options.parentComponent应该是有效的vue component选项对象” 这是我用于测试的代码 import Par

我正在尝试测试一个vue组件,该组件中使用了$parents.props

e、 g

我认为我需要嘲笑它的原因。$家长。$道具是因为我犯了这样的错误

TypeError: Cannot read property 'point' of undefined
我已尝试装载选项parentComponent,但它抛出一个错误,提示“[vue test utils]:options.parentComponent应该是有效的vue component选项对象”

这是我用于测试的代码

import Parent from "@/components/Parent.vue";

let wrapper: any;
describe("item.vue", () => {
  it("item vue testing", () => {
    wrapper = mount(item, {
        propsData: {
            num: 1,
        },
        parentComponent: Parent
      });

  });
});
我该怎么做来嘲弄这件事。$家长。$道具?上面的测试代码有什么错误?

您试过了吗?另见。
import Parent from "@/components/Parent.vue";

let wrapper: any;
describe("item.vue", () => {
  it("item vue testing", () => {
    wrapper = mount(item, {
        propsData: {
            num: 1,
        },
        parentComponent: Parent
      });

  });
});