title: angular2 testing using jasmine for subscribe method
body: <p>I have a spec code to test like this</p>
  
  <pre><code> it('login test', () =&gt; {
  
        const fixture = TestBed.createComponent(component);
        fixture.detectChanges();
        let authService = fixture.debugElement.injector.get(Auth);
        spyOn(authService, 'login').and.returnValue('');
  
        const elements = fixture.nativeElement;
        fixture.componentInstance.login();
        expect(authService.login).toHaveBeenCalled();
      });
  </code></pre>
  
  <p>and the implementation code like this</p>
  
  <pre><code>login() {
  
      this.auth.login(this.username, this.password).subscribe(() =&gt; {
  
        }
      });
    }
  </code></pre>
  
  <p>it gives error:</p>
  
  <blockquote>
    <p>this.auth.login(...).subscribe is not a function</p>
  </blockquote>
  
  <p>Why does this error happen?</p>