title: Override pipe when testing component
body: <p>I am trying to unit test a component that uses custom pipe. I want to provide a fake implementation of <code>transform</code> method for my test.</p>
  
  <p>I have found that it is possible to <a href="https://angular.io/guide/testing#more-overrides" rel="nofollow noreferrer">override</a> components, modules, pipe, etc., but I don't see how it is possible to override the behavior (implementation) of component.</p>
  
  <p>I have tried to provide me custom class as a replacement for pipe and it didn't work:</p>
  
  <pre><code>TestBed
    .configureTestingModule({declarations: [MyPipe]})
    .overridePipe(MDatePipe, {set: MyFakePipe})
  </code></pre>
  
  <p>I have found similar question on SO <a href="https://stackoverflow.com/questions/39293258/how-to-mock-pipe-when-testing-component">How to mock Pipe when testing Component</a>, but suggested solution was to create complete new pipe and provide it to <code>declarations</code> of testing module which is a bit too much in my opinion.</p>
  
  <p>If <code>overridePipe</code> won't allow me to override <code>transform</code> implementation would it be possible to get instance of created <code>MyPipe</code> class and <code>spyOn</code> it?</p>
  
  <pre><code>var pipe = TestBed.get(MyPipe);
  </code></pre>
  
  <p>didn't work either.</p>