title: TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined RxJS
body: <p>I want to trigger this catch block and confirm that <code>handleError()</code> runs:</p>
  
  <pre><code>@Injectable()
  export class JwtService {
      private actionUrl: string;
      private headers: Headers;
  
  
      constructor(private http: Http, private configurationService: ConfigurationService, private _utilsSvc: UtilitiesService) {}
  
      getToken() {
          if (this.configurationService.config) {
              return this.http.post(this.configurationService.config.jwtUrl, { "brand": "IAG" })
                  .map(this._utilsSvc.parseJson)
                  .catch(this.handleError);
          }   
      }
  
      handleError(error: any) {
          let errorStatus = error.status;
          return Observable.throw(errorStatus);
      }
  }
  </code></pre>
  
  <p>utilsSvc class:</p>
  
  <pre><code>@Injectable()
  export class UtilitiesService {
  
      constructor(private http: Http) { }
  
      fetchFile(url) {
          return this.http.get(url)
              .toPromise();
      }
  
      parseJson(response: Response) {
          return response.json();
      }
  }
  </code></pre>
  
  <p>I'm trying to pass it invalid json to cause an error to be caught:</p>
  
  <pre><code>it("Should handle error", () =&gt; {
      let resOp = new ResponseOptions({
          body: "invalid json"
      });
      mockHttpResponse = new Response(resOp);
      mockBackend.connections.subscribe(connection =&gt; {
          connection.mockRespond(mockHttpResponse);
      });
      spyOn(jwtService, 'handleError');
      jwtService.getToken().subscribe((res) =&gt; {
          expect(jwtService.handleError).toHaveBeenCalled();
      });
  });
  </code></pre>
  
  <p>I'm getting this error:</p>
  
  <blockquote>
    <p>TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined</p>
  </blockquote>
  
  <p>How do cause the catch block to catch the error?</p>
  
  <p>Here is my whole test file:</p>
  
  <pre><code>/// &lt;reference path="../../typings/globals/es6-shim/index.d.ts"/&gt;
  /// &lt;reference path="../../typings/globals/jasmine/index.d.ts" /&gt;
  import { inject, TestBed, ComponentFixture } from "@angular/core/testing";
  import { RouterTestingModule } from "@angular/router/testing";
  import { Headers, HttpModule, BaseRequestOptions, XHRBackend, Response, Http, ResponseOptions } from "@angular/http";
  import { MockBackend, MockConnection } from "@angular/http/testing";
  import { Component, DebugElement } from "@angular/core";
  import { By } from '@angular/platform-browser';
  import "rxjs/add/operator/toPromise";
  import { Observable } from "rxjs/Rx";
  import "rxjs/add/operator/toPromise";
  
  import { AuthenticationLibrary } from "../../app/services/authenticationLibrary.service";
  import { ConfigurationService } from "../../app/services/configuration.service";
  import { FrontEndLoggingService } from "../../app/services/frontEndLogging.service";
  import { JwtService } from "../../app/services/jwt.service";
  import { UtilitiesService } from "../../app/services/utilities.service";
  
  describe("Authentication service", () =&gt; {
  
      let mockBackend;
      let jwtService;
      let configSvc;
      let http;
      let feLogSvc;
      let mockHttpResponse;
  
      beforeEach(() =&gt; {
          TestBed.configureTestingModule({
              imports: [HttpModule],
              providers: [
                  { provide: XHRBackend, useClass: MockBackend },
                  ConfigurationService,
                  FrontEndLoggingService,
                  JwtService,
                  UtilitiesService
              ]
          });
  
          mockBackend = TestBed.get(XHRBackend);
          http = new Http(mockBackend, new BaseRequestOptions);
          feLogSvc = TestBed.get(FrontEndLoggingService);
          configSvc = TestBed.get(ConfigurationService);
          configSvc.config = {
              enableFrontEndDebugLogs: true,
              baseUrl: "www.someurl.com",
              providerEndpoint: "someMachine",
              categoriesEndpoint: "someCatEndpoint"
          }
  
          jwtService = new JwtService(
              TestBed.get(Http),
              configSvc,
              TestBed.get(UtilitiesService)
          )
  
  
  
  
      });
  
      it("Should get token", () =&gt; {        
          let resOp = new ResponseOptions({
              body: {
                  "token": "Bearer ABC123",
                  "brand": "AMI"
              }
          })
          mockHttpResponse = new Response(resOp)
          mockBackend.connections.subscribe(connection =&gt; {
              connection.mockRespond(mockHttpResponse);
          });
          jwtService.getToken().subscribe(response =&gt; {
              expect(response.token).toBe("Bearer ABC123");
          });
      });
  
      it("Should handle error", () =&gt; {
          let resOp = new ResponseOptions({
              body: "sdvhfujvn"
          });
          mockHttpResponse = new Response(resOp);
          mockBackend.connections.subscribe(connection =&gt; {
              connection.mockRespond(mockHttpResponse);
          });
          spyOn(jwtService, 'handleError');
          jwtService.getToken().subscribe((res) =&gt; {
              expect(jwtService.handleError).toHaveBeenCalled();
          });
      });
  });
  </code></pre>