title: How override Provider in Angular 5 for only one test?
body: <p>In one of my unit test files, I have to mock several times the same service with different mocks.</p>
  
  <pre><code>import { MyService } from '../services/myservice.service';
  import { MockMyService1 } from '../mocks/mockmyservice1';
  import { MockMyService2 } from '../mocks/mockmyservice2';
  describe('MyComponent', () =&gt; {
  
      beforeEach(async(() =&gt; {
          TestBed.configureTestingModule({
          declarations: [
              MyComponent
          ],
          providers: [
              { provide: MyService, useClass: MockMyService1 }
          ]
          })
          .compileComponents();
      }));
  
      beforeEach(() =&gt; {
          fixture = TestBed.createComponent(MapComponent);
          mapComponent = fixture.componentInstance;
          fixture.detectChanges();
      });
  
      describe('MyFirstTest', () =&gt; {
          it('should test with my first mock', () =&gt; {
              /**
               * Test with my first mock
               */
          });
      });
  
      describe('MySecondTest', () =&gt; {
          // Here I would like to change { provide: MyService, useClass: MockMyService1 } to { provide: MyService, useClass: MockMyService2 }
  
          it('should test with my second mock', () =&gt; {
              /**
               * Test with my second mock
               */
          });
      });
  });
  </code></pre>
  
  <p>I see that the function <a href="https://angular.io/api/core/testing/TestBed#overrideProvider" rel="noreferrer">overrideProvider</a> exists, but I did not manage to use it in my test. When I use it in a "it", the provider doesn't change. I didn't manage to find an example where this function is called. Could you explain me how to use it properly? Or have you an other method to do that?</p>