kaorun343 / vue-property-decorator

Vue.js and Property Decorator
MIT License
5.52k stars 380 forks source link

[Vue warn]: Injection "alertService" not found #391

Open felocru opened 3 years ago

felocru commented 3 years ago

Hello.

I have version 8.4.2.

I am doing my tests with jest and one of my components makes use of InjectReactive and Inject. Whenever I run the test I have the always problem:

console.error
    [Vue warn]: Injection "alertService" not found

    found in

    ---> <ParticipantesComponent>
           <Root>

      at warn (node_modules/vue/dist/vue.runtime.common.dev.js:621:15)
      at resolveInject (node_modules/vue/dist/vue.runtime.common.dev.js:2471:11)
      at initInjections (node_modules/vue/dist/vue.runtime.common.dev.js:2423:16)
      at VueComponent.Vue._init (node_modules/vue/dist/vue.runtime.common.dev.js:4986:5)
      at new VueComponent (node_modules/vue/dist/vue.runtime.common.dev.js:5134:12)
      at createComponentInstanceForVnode (node_modules/vue/dist/vue.runtime.common.dev.js:3277:10)
      at init (node_modules/vue/dist/vue.runtime.common.dev.js:3108:45)

  console.error
    [Vue warn]: Injection "__reactiveInject__" not found

Test:

describe('Componente: Participantes', () => {
  let wrapper: Wrapper<ParticipanteClass>;
  let participante: ParticipanteClass;
  const localVue = createLocalVue();

  const i18n = config.initI18N(localVue);
  const store = config.initVueXStore(localVue);

  bootstrapVueConfig.initBootstrapVue(localVue);

  localVue.use(BootstrapVue);

  beforeEach(() => {
    wrapper = mount<ParticipanteClass>(Participante, {
      store,
      i18n,
      localVue,
      data() {
        return {
          isBusyPp: false,
        };
      },
    });

    participante = wrapper.vm;
  });

  it('Busca persona por CVU', () => {
    // const button = wrapper.find('b-button#agregar-participante-persona');
    const button = wrapper.findComponent(BButton);
    button.trigger('click');
  });
});

Could you help me. Thanks.

ig-onoffice-de commented 3 years ago

Same here.