title: Mock ngrx/store in Angular2 tests
body: <p>Could you probably help me mocking the Store?
  I've seen <a href="https://github.com/ngrx/store/issues/128" rel="nofollow noreferrer">this</a> and <a href="https://stackoverflow.com/questions/40857864/mocking-ngrx-store">this</a> questions by a have a bit different error.
  I'm using store in one of my services, where I use dispatch, select and get store methods.
  I've mocked the Store following @noelmace suggestion and used following dispatcher, reducer and state creating the store:</p>
  
  <pre><code> export class ObservableMock implements Observer&lt;any&gt; {
          closed?: boolean = false; // inherited from Observer
          nextVal: any = ''; // variable I made up
  
          constructor() {
          }
  
          next = (value: any): void =&gt; {
              this.nextVal = value;
          };
          error = (err: any): void =&gt; {
              console.error(err);
          };
          complete = (): void =&gt; {
              this.closed = true;
          }
      }
  
      let _reducer: ObservableMock = new ObservableMock();
      let _dispatcher: ObservableMock = new ObservableMock();
      let state$: Observable&lt;any&gt; = new Observable&lt;any&gt;();
  </code></pre>
  
  <p>So my Mockstore class looks following:</p>
  
  <pre><code>export class MockStore&lt;T&gt; extends Store&lt;T&gt; {
  
      //as given above
      constructor() {
          super(_dispatcher, _reducer, state$);
      }
      //as given above
  }
  </code></pre>
  
  <p>However when I try to define my service in test following way it says</p>
  
  <blockquote>
    <p>TypeError: _store.select is not a function</p>
  </blockquote>
  
  <p>This failure is caused by following line in TestedService constructor:</p>
  
  <pre><code>constructor(private _store: Store&lt;TabStore&gt;) {
     let tabStore: Observable&lt;TabStore&gt; = _store.select&lt;TabStore&gt;('myReducer');|
  }
  </code></pre>
  
  <p>Here is my test:</p>
  
  <pre><code>beforeEach(() =&gt; {
          TestBed.configureTestingModule({
              imports: [
                  // StoreModule.provideStore({myReducer: myReducer}),
              ],
              providers: [
                  {provide: Store, useClass: MockStore},
                  {
                      provide: TestedService,
                      useFactory: (tabStore: Store&lt;TabStore&gt;): TestedService=&gt; {
                          return new TestedService(myStore);
                      },
                      deps: [Store]
                  }
              ]
          });
      });
  </code></pre>
  
  <p>Commenting imports out doesn't help either.  Does anyone has ideas what's wrong with mocking?</p>