...

/

Testing Streams Using the HTTPClient Module

Testing Streams Using the HTTPClient Module

Learn about testing streams using the HTTPClient module.

The HTTPClient module

Observables that are returned from the HTTP client are frequently used in our Angular code. How can we test those streams? Let’s look at the pattern we can use to test those observables. We’ll consider the following method inside RecipeService:

saveRecipe(formValue: Recipe): Observable<Recipe> {
return this.http.post<Recipe>(`${BASE_PATH}/recipes/save`, formValue);
}
The saveRecipe method

The saveRecipe method issues an HTTP request. There’s a very useful API that can be used in this case: ...