title: Why use overrideProvider or overrideComponent in Angular unit test to change the provider dependency value?
body: <p>I have several unit tests that use different values of a dependency property, I read about  overrideProvider and overrideComponent, but I can't think in which case they would be useful when I can just change the value directly without overriding.</p>
  <p>For example in the next snippet I'm just reassigning a property in the dependency for each test.</p>
  <pre><code>describe('TestComponent', () =&gt; {
    let component: TestComponent;
    let fixture: ComponentFixture&lt;TestComponent&gt;;
  
    let testServiceMock: Partial&lt;TestService&gt;;
  
    beforeEach(() =&gt; {
      testServiceMock = {
        someArray: [1, 2, 3]
      };
      TestBed.configureTestingModule({
        declarations: [TestComponent],
        providers: [{ provide: TestService, useValue: testServiceMock }]
      }).compileComponents();
    });
  
    beforeEach(() =&gt; {
      fixture = TestBed.createComponent(TestComponent);
      component = fixture.componentInstance;
    });
  
    it('should be true when someArray length is bigger than 1', () =&gt; {
      fixture.detectChanges();
      expect(component.show).toBeTruthy();
    });
  
    it('should be false when someArray is null', () =&gt; {
      testServiceMock.someArray = null;
      fixture.detectChanges();
      expect(component.show).toBeFalsy();
    });
  });
  </code></pre>
  <p>Here is an stackblitz for more information.
  <a href="https://stackblitz.com/edit/unit-test-ng-10-natudb?file=src%2Fapp%2Ftest%2Ftest.component.spec.ts" rel="nofollow noreferrer">https://stackblitz.com/edit/unit-test-ng-10-natudb?file=src%2Fapp%2Ftest%2Ftest.component.spec.ts</a></p>