You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: remove invalid service dependency guide section
The current section `Services with dependencies` within the testing services
guide is non-functional and has been removed. The example service is using
`inject` but the test code is using constructor-based injection. The further
sections discuss the use of TestBed to adjust providers which better handles
these cases.
The first test creates a `ValueService` with `new` and passes it to the `MasterService` constructor.
26
-
27
-
However, injecting the real service rarely works well as most dependent services are difficult to create and control.
28
-
29
-
Instead, mock the dependency, use a dummy value, or create a [spy](https://jasmine.github.io/tutorials/your_first_suite#section-Spies) on the pertinent service method.
30
-
31
-
HELPFUL: Prefer spies as they are usually the best way to mock services.
32
-
33
-
These standard testing techniques are great for unit testing services in isolation.
34
-
35
-
However, you almost always inject services into application classes using Angular dependency injection and you should have tests that reflect that usage pattern.
36
-
Angular testing utilities make it straightforward to investigate how injected services behave.
37
-
38
10
## Testing services with the `TestBed`
39
11
40
12
Your application relies on Angular [dependency injection (DI)](guide/di) to create services.
0 commit comments