title: why are the tests failing
body: <p>Trying to test http get service here but the test fails. why is it not working. I have provided all the dependencies and everything but still it's giving the response as undefined</p>
  
  <p>and when I run the karma test runner the test fails to give the following error</p>
  
  <p><code>HttpGetService should get courseList
  Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL</code></p>
  
  <p><code>HttpGetService should get courseList async
  Expected undefined to be 4</code></p>
  
  <p>// Http get service spec test file</p>
  
  <pre><code>import { async, ComponentFixture, TestBed, getTestBed, inject } from '@angular/core/testing';
  import { MockBackend, MockConnection } from '@angular/http/testing';
  import { HttpGetService } from './http-get.service';
  import {
    BaseRequestOptions, Http, XHRBackend, HttpModule,
    Response, ResponseOptions, RequestMethod
  } from '@angular/http';
  import {ICourseModel} from '../interface/course-model';
  
  describe('HttpGetService', () =&gt; {
    let mockBackend: MockBackend;
  
  
    beforeEach(async(() =&gt; {
      TestBed.configureTestingModule({
        providers: [
          HttpGetService,
          MockBackend,
          BaseRequestOptions,
          {
            provide: Http,
            deps: [MockBackend, BaseRequestOptions],
            useFactory:
            (backend: XHRBackend, defaultOptions: BaseRequestOptions) =&gt; {
              return new Http(backend, defaultOptions);
            }
          }
        ],
        imports: [
          HttpModule
        ]
      });
      mockBackend = getTestBed().get(MockBackend);
    }));
  
  
    it('should get courseList', (done) =&gt; {
      let getDataService: HttpGetService;
  
      getTestBed().compileComponents().then(() =&gt; {
        mockBackend.connections.subscribe(
          (connection: MockConnection) =&gt; {
            connection.mockRespond(new Response(
              new ResponseOptions({
                body:  [
                  { 'course': 'Mobile Development' },
                  { 'course': 'Web Development' },
                  { 'course': 'IOS Development' },
                  { 'course': 'Android Development' }
                ]
              }
              )));
          });
  
        getDataService = getTestBed().get(getDataService);
        expect(getDataService).toBeDefined();
  
        getDataService.getData().subscribe((CourseList: ICourseModel[]) =&gt; {
          expect(CourseList.length).toBeDefined();
          expect(CourseList.length).toEqual(4);
          expect(CourseList.length).not.toBe(1);
          done();
        });
      });
    });
  
  
    it('should check the service',
      inject([HttpGetService], (service: HttpGetService) =&gt; {
        expect(service).toBeTruthy();
      }));
  
    it('should get courseList async',
      async(inject([HttpGetService], (getDataService: HttpGetService) =&gt; {
        mockBackend.connections.subscribe(
          (connection: MockConnection) =&gt; {
            connection.mockRespond(new Response(
              new ResponseOptions({
                body:  [
                  { 'course': 'Mobile Development' },
                  { 'course': 'Web Development' },
                  { 'course': 'IOS Development' },
                  { 'course': 'Android Development' }
                ]
              }
              )));
          });
        getDataService.getData().subscribe(
          (response) =&gt; {
            expect(response.length).toBe(4);
            expect(response[0].course).toBe('Mobile Development');
            expect(response[1].course).toBe('Web Development');
            expect(response).toEqual([
              { 'course': 'Mobile Development' },
              { 'course': 'Web Development' },
              { 'course': 'IOS Development' },
              { 'course': 'Android Development' }
            ]);
          });
      })));
  });
  </code></pre>
  
  <p>// Http service</p>
  
  <pre><code>import { Injectable } from '@angular/core';
  import { Http } from '@angular/http';
  import { Observable } from 'rxjs/Observable';
  import 'rxjs/RX';
  
  @Injectable()
  export class HttpGetService {
  
    constructor(private http: Http) { }
  
    getData() {
      return this.http.get('someurl/data.json').map(
        (response) =&gt; {
          const data = response.json();
          const keys = Object.keys(data);
          return data[keys[0]];
        }
      ).catch(
        (error: Response) =&gt; {
          return Observable.throw(error);
        }
        );
    }
  
  }
  </code></pre>