karma-runner

How to mock a injected service in a function with Injector

隐身守侯 提交于 2020-08-26 06:51:33
问题 In Angular 7.x I have a global error handling that injects his services with the Injector. So each function has a reference with the injector, like so: import { ErrorHandler, Injectable, Injector, NgZone } from '@angular/core'; import { Router } from '@angular/router'; import { LoggingService } from '../logging/logging.service'; import { EnvironmentService } from '../services/environment.service'; @Injectable() export class GlobalErrorHandler implements ErrorHandler { constructor(private