Unable to import ServiceA present in repoA inside ServiceB in repoB while writing a test case...

Discussão em 'Angular' iniciado por Sai Krushna Rath, Dezembro 2, 2024.

  1. I have a scenario where I have an angular service ServiceA inside repo RepoA. In the index.ts of RepoA, I have export * as ServiceA from './serviceA'. ServiceA has the annotation @Injectable({ providedIn: 'root', })

    Next, in repoB, I have another angular service ServiceB that depends on ServiceA. ServiceB also has the decorator @Injectable({ providedIn: 'root', }). While trying to run a test using jest and TestBed it fails with the error

    Error: NG0202: This constructor is not compatible with Angular Dependency Injection because its dependency at index 2 of the parameter list is invalid.
    This can happen if the dependency type is a primitive like a string or if an ancestor of this class is missing an Angular decorator.

    Please check that 1) the type for the parameter at index 2 is correct and 2) the correct Angular decorators are defined for this class and its ancestors.


    Any idea what might be a fix to this issue ?

    Continue reading...

Compartilhe esta Página