I am writing test cases for custom ErrorHandler in Angular. In the constructor I added the dependency of Injector as I learnt that the providers get initialized after ErrorHandler. This is indicated below:
export class ApplicationErrorHandler implements ErrorHandler {
constructor(injector: Injector) {
this.injector = injector;
}
}
Now while writing test cases, how should I create my error Handler. Can I add Injector as a provider or can I do it as below:
errorHandler = injector.get(ApplicationErrorHandler);
In any case, I get errorHandler as undefined and the below error:
Error: Unexpected value '[object Object]' imported by the module 'DynamicTestModule'
I appreciate any help on how to write it in a way that I can test it. Thank you!