title: Angular/Jasmine - Do Spies work if invoked on ngOnInit?
body: <p>I have a reactive form which I have split into smaller components to be able to better manage each form control individually. I'm relying on event emitters to be able to communicate the state of each control to the "parent" component that manages the state of the whole form.</p>
  
  <p>My ngOnInit method for a given component looks like this:</p>
  
  <pre><code>@Output() formReady: EventEmitter&lt;FormControl&gt; = new EventEmitter();
  
  ngOnInit() {
      (some other unrelated logic here...)
      this.formReady.emit(this.userIdFormControl);
    }
  </code></pre>
  
  <p>The test I'm trying to write for this component is pretty straightforward</p>
  
  <pre><code>it('should emit formReady event when component is initialised', () =&gt; {
      spyOn(component.formReady, 'emit');
      expect(component.formReady.emit).toHaveBeenCalled();
    });
  </code></pre>
  
  <p>However this is test is failing because the Spy never gets invoked (although if I add a clg statement to ngOnInit I can see it getting printed as many times as expected).</p>
  
  <p>My question is: are Spies able to be invoked on ngOnInit? I can't see why they wouldn't work but you never know!</p>
  
  <p>Thanks in advance,</p>
  
  <p>Tiago</p>