title: Angular testing - observable pipe is not a function
body: <p>I want to write a unit test for a photo-upload-mehtod. But I get the <code>Failed: this.task.snapshotChanges(...).pipe is not a function
      TypeError: this.task.snapshotChanges(...).pipe is not a function</code> Error. <br><br>For the sake of simplicity of this question, I put the code all in one method:</p>
  
  <h2>Component</h2>
  
  <pre><code>  public startUpload(event: FileList) {
      const file: File = event.item(0);
      const pathRef = `users/${this.uid}`;
  
      this.task = this.service.uploadPhoto(pathRef, file);
      this.fileRef = this.service.getFileReference(pathRef);
      this.percentage = this.task.percentageChanges();
      this.snapshot = this.task.snapshotChanges();
      this.task.snapshotChanges().pipe(last(), switchMap(() =&gt; // it fails here - need to propperly mock this
      this.fileRef.getDownloadURL()))
        .subscribe(url =&gt; this.service.updatePhoto(url));
    }
  </code></pre>
  
  <h2>Component.spec</h2>
  
  <pre><code>  it('should upload file', async(() =&gt; {
      const supportedFile = new File([''], 'filename.png', {type: 'image/', lastModified: 2233});
      const fileList = {
        item: () =&gt; {
          return supportedFile;
        }
      };
      const spy = (&lt;jasmine.Spy&gt;serviceStub.uploadPhoto).and.returnValue({
        percentageChanges: () =&gt; of(null),
        snapshotChanges: () =&gt; {
          return {
            getDownloadURL() {
              return of(null);
            }
          };
        }
      });
  
      component.startUpload(&lt;any&gt;fileList);
  
      expect(spy).toHaveBeenCalledWith(`users/${component.uid}`, supportedFile);
    }));
  </code></pre>