Angular 2 TestBed with mocks
<p>I am trying to test a component which uses another service. And I want to isolate the component by providing a mock for the service. Before RC5 I can simply use <code>addproviders</code> which is now deprecated and will be removed by the next RC. Instead I have to use the <code>TestBed</code>. When I provide the mock angular for some reason keep looking for the services that the mock depends on. And throws a <code>DI exception</code>. When I provide all the dependencies the test works but I don't want to repeat myself for each test suite. And this breaks basic OO principles.
My test suite:</p>

<pre><code>describe('Component: DummyRestApi', () =&gt; {

  class DummyRestApiTestService {

    GetAll() {

      return Rx.Observable.create(observer =&gt; {

        let data:Data[] = [];

        data.push({
          id: 0,
          data: 'data'
        });

        observer.next(data);
        observer.complete();

      });
    }

    Add(data) {
    }
  }
  let fixture;
  let myMockWindow:Window;
  // ToDo use the mocks
  beforeEach(() =&gt; {
    myMockWindow = &lt;any&gt; {location: &lt;any&gt; {hostname: '127.0.0.1'}};
    TestBed.configureTestingModule({
      declarations: [DummyRestApiComponent],
      providers: [
        // ServerAddressResolverService,
        DummyRestApiComponent,
        // ConfigurationService,
        {provide: DummyRestApiService, useClass: DummyRestApiTestService},
        // {provide: Window, useValue: myMockWindow}
      ],
      imports: [FormsModule, HttpModule]
    });
    TestBed.compileComponents().catch(error =&gt; console.error(error));


    // addProviders([
    //   DummyRestApiComponent,
    //   {provide: DummyRestApiService, useClass: DummyRestApiTestService},
    // ]);
  });


  describe('Initializing', () =&gt; {

    beforeEach(async(() =&gt; {
      console.log('Compiling');
      TestBed.compileComponents().catch(error =&gt; console.error(error));
      console.log('Compiling again');
    }));

    it('should create an instance', async(() =&gt; {
        var fixture = TestBed.createComponent(DummyRestApiComponent);
        fixture.detectChanges();
        expect(fixture.debugElement.componentInstance).toBeTruthy();
      }
    ));

});
</code></pre>

<p>Angular 2.0.0-RC5</p>