【发布时间】:2021-03-07 15:46:53
【问题描述】:
我在尝试模拟 vue 中的引用时出错,因为我找到的解决方案使用了存根。但存根只接受字符串。
it("Test component", () => {
const wrapper = mount(NeedConfirmation, {
localVue,
store
});
});
[Vue 警告]:挂载钩子错误:“TypeError: this.$refs.appConfirm.setCellphone 不是函数”
it("Test component", () => {
const appConfirm = {
setCellphone: () => {}
};
const wrapper = mount(NeedConfirmation, {
localVue,
store,
stubs: {
appConfirm
}
});
});
[vue-test-utils]:options.stub 值必须传递一个字符串或组件
【问题讨论】:
标签: vue.js jestjs vue-test-utils