Home  >  Q&A  >  body text

Ways to resolve tooltip warnings in test cases in Vue Test Utils

<p>When using bootstrap-vue's v-b-tooltip.hover, a warning always appears in the unit test: </p><p><strong>[BootstrapVue warn]: tooltip - the provided target is not valid HTML element. </strong></p>
P粉293341969P粉293341969420 days ago445

reply all(1)I'll reply

  • P粉163465905

    P粉1634659052023-08-27 11:13:36

    I found that using attachTo: createContainer() when defining componentData can solve the problem. At the same time, whenever the wrapper is redefined, it must also be redefined.

    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);

    reply
    0
  • Cancelreply