Context
I created an ApiService class to be able to handle our custom API queries, while using our own serializer + other features.
ApiService's constructor signature is:
constructor(metaManager: MetaManager, connector: ApiConnectorService, eventDispatcher: EventDispatcher);
MetaManageris an injectable service that handles api's metadatas.ApiConnectorServiceis a service which is wrappingHttpto add our custom headers and signature system.EventDispatcheris basically Symfony's event dispatcher system, in typescript.
Problem
When I test the ApiService, I do an initialization in beforeEach:
beforeEach(async(() => {
TestBed.configureTestingModule({
imports : [
HttpModule
],
providers: [
ApiConnectorService,
ApiService,
MetaManager,
EventDispatcher,
OFF_LOGGER_PROVIDERS
]
});
}));
and it works fine.
Then I add my second spec file, which is for ApiConnectorService, with this beforeEach:
beforeEach(async(() => {
TestBed.configureTestingModule({
imports : [HttpModule],
providers: [
ApiConnectorService,
OFF_LOGGER_PROVIDERS,
AuthenticationManager,
EventDispatcher
]
});
}));
And all the tests fail with this error:
Error: Can't resolve all parameters for ApiService: (MetaManager, ?, EventDispatcher).
- If I remove
api-connector-service.spec.ts(ApiConnectorService's spec file) from my loaded tests,ApiService's tests will succeed. - If I remove
api-service.spec.ts(ApiService's spec file) from my loaded tests,ApiConnectorService's tests will succeed.
Why do I have this error? It seems like the context between my two files are in conflict and I don't know why and how to fix this.