Jest报错:Unknown custom element: <router-link> - did you register the component correctly?

在使用Jest进行Vue单元测试的时候,终端报错
Unknown custom element: - did you register the component correctly?
现象
在我们进行测试的部分出现了<router-link`>标签进行页面跳转,在测试的时候却报错。

解决方案:
在测试代码注入组件名称部分使用以下代码,component是你要测试的组件名称

shallowMount(Component, {
  stubs: ['router-link', 'router-view']
})
上一篇:mysql8.0使用mysqldump报错:Unknown table ‘column_statistics‘ in information_schema (1109)


下一篇:关于INTERNALERROR>pluggy.manager.PluginValidationError: unknown hook ‘pytest_namespace以及pycharm虚拟环境新建