title: Not getting a filled array in unit testing (sepc.ts) from (.ts) file
body: <p>I want to get this all appointments array in apec.ts file with its filled objects, but when I am directly calling it by component.allAppoitments its getting allAppoitments with zero elements filled, how can i get this array with all element filled in spec.ts file</p>
  <p>spec.ts file ======&gt;</p>
  <pre><code>beforeEach(() =&gt; {
      fixture = TestBed.createComponent(DashboardComponent);
      component = fixture.componentInstance;
      fixture.detectChanges();
      component.getAppointments();
    });
  
    it('should create', () =&gt; {
      expect(component).toBeTruthy();
    });
  
    it(&quot;all appoitments added&quot;,()=&gt;{
      expect(component.allAppointment.length).toEqual(0);
    });
  </code></pre>
  <p>.ts file ======&gt;</p>
  <pre><code> allAppointment: AppointmentModel []=[];
   appointmentSummary:any[]=[];
  
  
  
    ngOnInit(): void {
     
      this.getAppointments()
  
    
      this.getAppointmentsSummary();
    }
  
    
    getAppointments(){
      this.dashboardService.getAllPatients().subscribe((res: any) =&gt; {
        for(let r of res){
          this.allAppointment.push(r)
        }
      })
    }
  </code></pre>