解决vitest +Vue Test Utils 组件中包含第三方组件时报 Failed to resolve component
[Vue warn]: Failed to resolve component: a-descripttions
If this is a native custom element, make sure to exclude it from component resolution via compilerOptionns.isCustomElement
at <Index schemas= [

当我们测试组件中按需引入了第三方组件(ant-design-vue)时,单元测试会报Failed to resolve component

这里我们只需要在global中加入plugins: [antdv],相关代码如下:

import antdv from 'ant-design-vue';
describe('Descriptions', () => {
  test('renders properly', () => {
    const wrapper = mount(Descriptions, {
      props: {
        schemas: schemasList,
      },
      global: {
        plugins: [antdv], // 修改这里
      },
    });
    expect(wrapper.classes('cpn-basic-descriptions')).toBe(true);
  });
});
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇