A written emit method test case in Angular now facing an issue is TypeError: Cannot read property 'dispatchEvent' of null. Get the click event end call to emit method. child component Html file article.html <a (click)="edit(item)" class="mat-card-title" style="cursor: pointer">{{ item.title }}</a> viewArticle.spec.ts fit('emiter call', () => { const fixture2 = TestBed.createComponent(ArticleCarouselComponent); const component2 = fixture2.componentInstance; spyOn(component2.changeevent, 'emit'); const nativeElement = fixture.nativeElement; const button = nativeElement.querySelector('a'); button.dispatchEvent(new Event('click')); fixture.detectChanges(); expect(component2.changeevent.emit).toHaveBeenCalled(); }); TypeError: Cannot read property 'dispatchEvent' of null Continue reading...