title: NgRx Effect: Unit test - seems that actions$ never produce effect
body: <p>When running my unit test I noticed that Jasmine log a message saying that my unit test has no expectations. Because of that I noticed that the unit test wasn't working well. It seems that the action is not triggering the effect. I should mention that the UI get the countries with no problem</p>
  
  <p>I am writting my code based on <a href="https://next.ngrx.io/guide/effects" rel="nofollow noreferrer">https://next.ngrx.io/guide/effects</a> and <a href="https://next.ngrx.io/guide/effects/testing" rel="nofollow noreferrer">https://next.ngrx.io/guide/effects/testing</a>.</p>
  
  <p>Effect</p>
  
  <pre class="lang-js prettyprint-override"><code>@Injectable()
  export class CountryEffects {
      constructor(private actions$: Actions,
          private countryService: CountryService,
          private store: Store&lt;CountryState&gt;) { }
  
      loadCountries$ = createEffect(() =&gt;
          this.actions$.pipe(
              ofType(CountryActions.ActionTypes.LOAD_COUNTRIES),
              withLatestFrom(this.store.select(selectCountries)),
              mergeMap(([action, storeCountries]) =&gt; {
  
                  if (storeCountries &amp;&amp; storeCountries.length &gt; 0) {
                      return of(CountryActions.loadCountriesSuccess({ countries: storeCountries }))
                  }
  
                  return this.countryService.getAll().pipe(
                      map((apiCountries: Country[]) =&gt; CountryActions.loadCountriesSuccess({ countries: apiCountries })),
                      catchError(err =&gt;
                          of(CountryActions.loadCountriesFailure({ error: 'Fail to load countries', countries: null }))
                      )
                  )
              })
          )
      );
  }
  </code></pre>
  
  <p>Effect Spec:</p>
  
  <pre class="lang-js prettyprint-override"><code>import { of, Observable } from "rxjs";
  import { TestBed } from '@angular/core/testing';
  import { provideMockActions } from '@ngrx/effects/testing';
  import { provideMockStore } from '@ngrx/store/testing';
  
  import { CountryService } from 'src/app/vendors/shared/services/country.service';
  import { CountryEffects } from './country.effects';
  
  
  import { COUNTRIES } from 'src/test/mocks/country.mock';
  import { Action } from '@ngrx/store';
  import { CountryActions } from '.';
  
  describe('CountryEffects', () =&gt; {
      let actions$: Observable&lt;Action&gt;;
      let effects: CountryEffects;
      let service: jasmine.SpyObj&lt;CountryService&gt;;
  
      beforeEach(() =&gt; {
          TestBed.configureTestingModule({
              providers: [
                  CountryEffects,
                  provideMockActions(() =&gt; actions$),
                  provideMockStore({
                      selectors: [
                          {
                              selector: CountryActions.ActionTypes.LOAD_COUNTRIES,
                              value: {
                                  countries: []
                              }
                          }
                      ]
                  }),
                  { 
                      provide: CountryService,
                      useValue: jasmine.createSpyObj('countryService', ['getAll'])
                  },
              ]
          });
  
          effects = TestBed.get&lt;CountryEffects&gt;(CountryEffects);
          service = TestBed.get(CountryService);
      });
  
      it('loadCountries$ should return CountryAction.loadCountriesSuccess', () =&gt; {
  
          actions$ = of({ type: CountryActions.ActionTypes.LOAD_COUNTRIES });
          service.getAll.and.returnValue(of(COUNTRIES));
  
          effects.loadCountries$.subscribe(action =&gt; {
              // Here is where I expect it to fail since the effect should return
              // type ActionTypes.LOAD_COUNTRIES_SUCCESS
              expect(action.type).toEqual('Please fail');
              expect(action.countries).toEqual(COUNTRIES);
          });
      });
  });
  
  </code></pre>