I'm about to write some testing code and wanted to inject my PresentationService. But in the PresentationService i need to run code after it got created, so I have to run the code in the constructor.
But if I inject the Service into my testing spec, I don't want it to invoke the constructor, because I'll get an error, because I'm not authorized.
I'm doing it this way providers: [{provide: PresentationService, useClass: FakePresentationService}],
and later on I'm getting the Service this way presentationService = TestBed.get(PresentationService);
What is the alternative or the best way, to avoid this error? Or to not invoke the constructor of the Service?
Aucun commentaire:
Enregistrer un commentaire