title: Test IntersectionObserver in an Angular component
body: <p>I'm using an <code>IntersectionObserver</code> to load data when user scroll to the bottom of the page.</p>
  <pre class="lang-js prettyprint-override"><code>@Output() onScroll = new EventEmitter();
  @ViewChild('end') endOfList!: ElementRef&lt;HTMLElement&gt;;
  
  observer!: IntersectionObserver;
  
  constructor(private requests: ElementRef) { }
  
  ngAfterViewInit() {
    this.observer = new IntersectionObserver(([entry]) =&gt; {
      entry.isIntersecting &amp;&amp; this.onScroll.emit();
    }, this.requests.nativeElement);
  
    this.observer.observe(this.endOfList.nativeElement);
  }
  </code></pre>
  <p>Everything works fine but I can't figure out how to test it.</p>
  <p>I think I have to use a spy to spy on scroll or a mock of IntersectionObserver but I don't understand how to use them in my case.</p>
  <p>Any ideas?</p>