'Unit Test for dialogref.componentInstance using Jest framework

How to handle this.dialogRef.componentInstance.dialogresearchClose.subscribe(data=>{}) using jest framework. Please any one can help on this?

ParentComponent.ts

dialogRef.componentInstance.dialogResearchClose.subscribe((data) =>{
  onCloseClick = data;
});

Dialogcomponent.ts

    export class DialogResearchComponent {
  @Output() dialogResearchClose=new EventEmitter<boolean>();
  constructor(
    @Inject(MAT_DIALOG_DATA) public data: DialogData,
    public dialog: MatDialog,
    public dialogRef: MatDialogRef<DialogComponent>
  ) { }
 onCloseClick(): void {
    this.dialogResearchClose.emit(true);
    this.dialogRef.close();
  }
}

Here Im getting Error- TypeError: Cannot read properties of undefined (reading 'dialogResearchClose')



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source