Tutorial by Topics: mocking

@ngrx/Store is becoming more widely used in Angular 2 projects. As such, the Store is required to be injected into the constructor of any Component or Service that wishes to use it. Unit testing Store isn't as easy as testing a simple service though. As with many problems, there are a myriad of ways to implement solutions. However, the basic recipe is to write a mock class for the Observer interface and to write a mock class for Store. Then you can inject Store as a provider in your TestBed.

The Mockito docs have an excellent example of how to provide a sequence of answers for multiple calls to a mock. However, they don't cover how to do that for a method that returns void, other than noting that stubbing void methods require using the do family of methods.

Page 1 of 1