Closed intellix closed 7 years ago
Reading the docs it seems that the recommended way is:
userService = fixture.debugElement.injector.get(UserService);
I'll do more research.
I'll leave it as it is for now; until someone points out a problem with the current implementation or a benefit of using something different.
I acknowledge that using the recommended way wouldn't hurt, but in general I have a problem with doing/changing things "just because".
It's also how they look if you generate tests using Angular CLI :)
fyi, v0.12.0
now uses injectors. See https://github.com/SimonTestNet/SimonTest/issues/10
Currently, mocks are created and referenced globally within a test.
The recommended approach is to fetch them from the injector: https://angular.io/docs/ts/latest/guide/testing.html#!#service-from-injector
Currently:
Recommended:
When I log out the method being spied upon within my service, it's not a spy. But if I use the injector to fetch it first and then spy, it does work