【问题标题】:How to resolve tooltip warning in testcase vue test utils?如何解决测试用例 vue 测试工具中的工具提示警告?
【发布时间】:2021-09-30 07:45:29
【问题描述】:

在使用 bootstrap-vue 的 vb-tooltip.hover 时,单元测试不断发出警告:
[BootstrapVue warn]: tooltip - 提供的目标不是有效的 HTML 元素。

【问题讨论】:

    标签: vue.js unit-testing jestjs bootstrap-vue vue-test-utils


    【解决方案1】:

    我在定义 componentData 时使用 attachTo: createContainer() 找到了解决方案。每当重新定义包装器时,也必须重新定义。

    const createContainer = (tag = "div") => {
      const container = document.createElement(tag);
      document.body.appendChild(container);
    
      return container;
    };
    
    const componentData = {
      attachTo: createContainer(),
      store,
      localVue
    };
    
    const wrapper = shallowMount(Index, componentData);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-01-24
      • 1970-01-01
      • 1970-01-01
      • 2018-11-04
      • 2020-04-25
      • 1970-01-01
      • 2011-08-12
      相关资源
      最近更新 更多