I have a angularjs component that I am upgrading:
import { Directive, ElementRef, Injector, Output, EventEmitter } from '@angular/core';
import { UpgradeComponent } from '@angular/upgrade/static';
@Directive({
selector: 'up'
})
export class UpDirective extends UpgradeComponent {
constructor(elementRef: ElementRef, injector: Injector) {
super('old', elementRef, injector);
}
}
This component works just fine when I run the application.
However when I try and test the Angular 8 component that uses that directive I get the following error:
NullInjectorError: StaticInjectorError(DynamicTestModule)[$injector]:
StaticInjectorError(Platform: core)[$injector]:
NullInjectorError: No provider for $injector!
I assume that is coming from the injector that is used in the UpgradeComponent. However I am not sure how to provide that to my spec.ts.
Angular does a good job documenting how to make this work in an application, but nothing on how to test: https://angular.io/api/upgrade/static/UpgradeComponent
Also looked here: https://github.com/angular/angular/issues/24369, however still not clear how to test.