I have two services, and one of them is dependent on another:
UserService:
@Injectable()export class UserService {
constructor(private apiService: ApiService){}
...}
ApiService:
@Injectable()export class ApiService {
constructor(){}
...}
So my problem is that I am struggling to inject the dependency, ApiService into
my tests for the UserService. Here's what I have in the user service spec.
(imports omitted):
describe('UserService', () => {
beforeEach(() => {
addProviders([
UserService,
provide(ApiService, {useClass: MockApiService})
]);
});
it('Should ...', inject([UserService], (service: UserService) => {
expect(true).toBe(true);
}));})
The error that this throws is:
Error: Cannot resolve all parameters for 'UserService'(undefined). Make sure
that all the parameters are decorated with Inject or have valid type
annotations and that 'UserService' is decorated with Injectable.
What I also tried was to add the ApiService in the inject inside the it,
but the error stays the same, so: it('Should ..., inject([UserService,
ApiService] ...))
Using Angular 2 RC4 with TypeScript
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.