Angular · Junior · Question 33 of 75

Why is dependency injection useful for testing?

Explanation

TestBed.configureTestingModule({ providers: [{ provide: ApiService, useValue: fakeApi }] }) swaps the real service for a stub. Components only depend on what they inject.

Further reading

Problem with a question

Angular · Junior · question 33

Test yourself

Take the Angular · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz