I am new to karma and jasmine, so please forgive me if this sounds silly. I have these following code and what I want to do with it, is finding out what I need to do next. I have CUSTOM_HTTP_CONFIG
injected in the constructor in hello-http.service.ts
, which I cannot find tutorial how I can achieve this, manual inject the dependency and that is what I think the error message is complaining about.
test.spec.ts
beforeEach(async(() => {
TestBed.configureTestingModule({
declaration: [...],
imports[RouterTestingModule, ...],
providers: [HelloHttpService, ...],
});
});
hello-http.service.ts
constructor(
@Inject(CUSTOM_HTTP_CONFIG) protect config: CustomHttpParams,
...
) {
super(config, http);
}
Karma: error
Failed: Uncaught (in promise): Error: StaticInjectorError(DynamicTestModule)[HelloHttpService -> InjectionToken Custom HTTP Config]:
StaticInjectorError(Platform: core)[HelloHttpService -> InjectionToken Custom HTTP Config]:
NullInjectorError: No provider for InjectionToken Custom HTTP Config!
Error: StaticInjectorError(DynamicTestModule)[HelloHttpService -> InjectionToken Custom HTTP Config]:
StaticInjectorError(Platform: core)[HelloHttpService -> InjectionToken Custom HTTP Config]:
NullInjectorError: No provider for InjectionToken Custom HTTP Config!
at _NullInjector.webpackJsonp../node_modules/@angular/core/esm5/core.js._NullInjector.get (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/esm5/core.js:1003:1)
at resolveToken (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/esm5/core.js:1301:1)