how to mock ngrx selector in a component : <p>In a component, we use a ngrx selector to retrieve different parts of the state.</p>

<pre><code>public isListLoading$ = this.store.select(fromStore.getLoading);
public users$ = this.store.select(fromStore.getUsers);
</code></pre>

<p>the <code>fromStore.method</code> is created using ngrx <code>createSelector</code> method. For example:</p>

<pre><code>export const getState = createFeatureSelector&lt;UsersState&gt;('users');
export const getLoading = createSelector(
  getState,
  (state: UsersState) =&gt; state.loading
);
</code></pre>

<p>I use these observables in the template:</p>

<pre><code>&lt;div class="loader" *ngIf="isLoading$ | async"&gt;&lt;/div&gt;
&lt;ul class="userList"&gt;
    &lt;li class="userItem" *ngFor="let user of $users | async"&gt;{{user.name}}&lt;/li&gt;
&lt;/div&gt;
</code></pre>

<p>I would like to write a test where i could do something like:</p>

<pre><code>store.select.and.returnValue(someSubject)
</code></pre>

<p>to be able to change subject value and test the template of the component agains these values.</p>

<p>The fact is we struggle to find a proper way to test that. How to write my "andReturn" method since the <code>select</code> method is called two times in my component, with two different methods (MemoizedSelector) as arguments?</p>

<p>We don't want to use real selector and so mocking a state then using real selector seems not to be a proper unit test way (tests wouldn't be isolated and would use real methods to test a component behavior).</p>
