title: Angular unit tests TypeError: this.http.get(...).pipe is not a function
body: <p>I'm following this example to make a unit test for service (get request coming from spring app backend) <a href="https://angular.io/guide/testing#testing-http-services" rel="noreferrer">https://angular.io/guide/testing#testing-http-services</a></p>
  
  <p>Service class :</p>
  
  <pre><code>@Injectable()
  export class TarifService {
  
    constructor(private messageService: MessageService, private http: HttpClient) { }
  
    public getTarifs(): Observable&lt;Tarif[]&gt; {
      return this.http.get&lt;Tarif[]&gt;(tarifffsURL).pipe(
        tap(() =&gt; {}),
        catchError(this.handleError('getTarifs', []))
      );
    }
  }
  </code></pre>
  
  <p>Unit Test</p>
  
  <pre><code>describe('TarifService', () =&gt; {
  
    let tarifService: TarifService;
    let httpClientSpy: { get: jasmine.Spy };
    let expectedTarifs;
  
    beforeEach(() =&gt; {
      TestBed.configureTestingModule({
        imports: [ToastrModule.forRoot(), HttpClientModule, HttpClientTestingModule],
        providers: [TarifService, HttpClient, MessageService]
      });
  
      httpClientSpy = jasmine.createSpyObj('HttpClient', ['get']);
      tarifService = new TarifService(&lt;any&gt; MessageService,&lt;any&gt; httpClientSpy);
  
    });
  
  
    it('should be created', inject([TarifService], (service: TarifService) =&gt; {
      expect(service).toBeTruthy();
    }));
  
  
    it('should return expected tarif (HttpClient called once)', () =&gt; {
      const expectedTarifs: Tarif[] =
        [{ id: 1, name: 'Tarif1', value: '20' }, { id: 2, name: 'Tarif2', value:'30' }];
  
      httpClientSpy.get.and.returnValue(expectedTarifs);
  
      tarifService.getTarifs().subscribe(
        tarifs =&gt; expect(tarifs).toEqual(expectedTarifs, 'expected tarifs'),
        fail
      );
      expect(httpClientSpy.get.calls.count()).toBe(1, 'one call');
    });
  });
  </code></pre>
  
  <p>When running the tests, I keep having this error</p>
  
  <pre><code>TarifService should return expected tarif (HttpClient called once)
  TypeError: this.http.get(...).pipe is not a function
  </code></pre>
  
  <p>what could be the cause of this?</p>