title: TypeError: Is not a function error in Unit testing with Jasmine
body: <p>I am getting 2 Errors everytime I run my test :</p>
  <p>Error 1... &gt;&gt;&gt;TypeError: this.part.list().subscribe is not a function</p>
  <p>Error 2... &gt;&gt;&gt;Error:  : could not find an object to spy upon for list()
  &gt;&gt;&gt;Usage: spyOn(,)</p>
  <p>The part.service.ts contains the following code :</p>
  <pre><code>*export class PartService {
      constructor(private http: HttpClient, private configuration: Configuration) {
      }
      list(): Observable&lt;Part[]&gt; {
          console.log(this.configuration);
          const link = this.configuration.partApi + '/list';
          return this.http.get(link).pipe(
              map((result:Part[]) =&gt; {
                  return result.map((element:Part)=&gt;{
                      return &lt;Part&gt; Object.assign(new Part(), element);
                  });
              })
          );
      }
  }*
  </code></pre>
  <p>In my .spec.ts file I have the following code : -</p>
  <pre><code>import { async, ComponentFixture, TestBed } from '@angular/core/testing';
  import {MatDialog, MatDialogRef, MAT_DIALOG_DATA, MatFormField,MatTableModule, MatFormFieldModule} from '@angular/material';
  import { PartViewComponent } from './partview.component';
  import {PartService} from 'src/app/service/part.service';
  import {DebugElement} from '@angular/core';
  import { UuidPipe } from 'src/app/uuid.pipe';
  import { of, Observable } from 'rxjs';
  import { HttpClient } from '@angular/common/http';
  import { Configuration } from 'src/app/app.configuration';
  import { BreakpointObserver } from '@angular/cdk/layout';
  import { Part } from 'src/app/model';
  
  
  
  class MockPartservice {
  
      list():Part {
       let part1:Part;
        part1=new Part();
        part1.description=&quot;This is a test data&quot;;
        part1.name=&quot;Hello&quot;;
        part1.uuid=&quot;ABCD1234&quot;;
          return part1;
      }
  
  };
  
  describe('PartviewComponent', () =&gt; {
    //let component: PartViewComponent;
    let fixture: ComponentFixture&lt;PartViewComponent&gt;;
    let partservice:PartService;
    let debugElement:DebugElement;
        partservice=null;
  
  
    beforeEach(async(() =&gt; {
      TestBed.configureTestingModule({
  
        imports:[MatFormFieldModule,MatTableModule],
        declarations:[UuidPipe,PartViewComponent],
        providers: [ PartViewComponent, {provide: PartService, useClass: MockPartservice}]
  
  })
      .compileComponents();
  
    }));
  
  
    beforeEach(() =&gt; {
      fixture = TestBed.createComponent(PartViewComponent);
      
      debugElement=fixture.debugElement;
      partservice=fixture.debugElement.injector.get(PartService);
      
    });
  
   it('#list should return stubbed value from a spy', ()=&gt;{
  
      
      const partServiceSpy = jasmine.createSpyObj('PartService',['list']);
      spyOn(partservice,'list').and.returnValue(Part);
      
      
   });
  
  
   })
  </code></pre>