我在运行 npm run 测试时遇到问题。错误是
[Vue warn]: Unknown custom element: <nuxt-link> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
Run Code Online (Sandbox Code Playgroud)
SidebarCMS.spect.js
import { shallowMount } from "@vue/test-utils";
import SidebarCMS from "../layouts/SidebarCMS";
const factory = () => {
return shallowMount(SidebarCMS, {});
};
describe("SidebarCMS", () => {
test("renders properly", () => {
const wrapper = factory();
expect(wrapper.html()).toMatchSnapshot();
});
});
Run Code Online (Sandbox Code Playgroud)
谁能帮我?
您可以stub在创建实例时使用子组件。有关存根组件的更多信息,请查看此链接。
尝试这样,这将解决您的警告!
const factory = () => {
return shallowMount(SidebarCMS, {
stubs: {
'nuxt-link': true,
'any-other-child': true
}
});
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
900 次 |
| 最近记录: |