title: Jasmine - “Cannot read property 'values' of undefined thrown”
body: <p>I just started writing unit tests for an existing Angular app using Jasmine, and around 50% of the time, I get the following error.The other 50% of the time, all tests pass without any issues.</p>
  
  <p>The major problem I have with this error message is that Jasmine is not telling me where the issue</p>
  
  <pre><code> An error was thrown in afterAll
    Uncaught TypeError: Cannot read property 'values' of undefined thrown
  </code></pre>
  
  <pre><code>describe('deal without Angular testing support', () =&gt; {
      let service: DealService;
      let httpMock: HttpTestingController;
  
      beforeEach(async() =&gt; {
  
          TestBed.configureTestingModule({
              providers: [
                  DealService
              ],
              imports: [HttpClientTestingModule],
              schemas: [ NO_ERRORS_SCHEMA ]
          });
  
          service = TestBed.get(DealService);
          httpMock = TestBed.get(HttpTestingController);
      });
  
      it('should use ValueService', () =&gt; {
          expect(service).toBeTruthy();
      });
  
  
      it('should return the json for deal http request', () =&gt; {
          service.getDealParameters({name:'sample name',value: "sample value"}).subscribe(data =&gt; {
              expect(data[0].dealParameterId).toBe(111);
              spyOn(service , "getDealParamDatafromSubject").and.callThrough();
              expect(service.getDealParamDatafromSubject).toHaveBeenCalled();
          });
  
          const req = httpMock.expectOne('https://localhost:44382/DPasdarameterSetup/GealParameters', 'call to api');
          expect(req.request.method).toBe('GET');
  
          req.flush([{
              dealParameterId: 111,
              actionComments: 'lorem',
              value: "sample value 1"
  
          },
          {
              dealParameterId: 222,
              actionComments: 'lorem',
              value: "sample value 2"
  
          }]);
          httpMock.verify(); 
      });
  });
  
  service code:
  -----------------
  export class DealParameterSetupService {
      scope: CScope[];
      primaryRestriction: CprimaryRestriction[];
      paramType: CparameterType[];
      secondaryRestriction: CSecondaryRestriction[];
      dealparams: CDealParameterSetup;
      dealParamData = new BehaviorSubject&lt;any&gt;('');
      dealData: Observable&lt;any&gt;;
      test = [];
  
      // Store the deserialize dealdata
      getDealParamDatafromSubject(dealData: any) {
          this.dealParamData.next(dealData);
      }
  
      constructor(private http: HttpClient) {
          this.dealData = this.dealParamData.asObservable();
      }
  
      // getDealParameters to get deal data
      getDealParameters(userDetailsObj): Observable&lt;CDealParameterSetup[]&gt; {
          return this.http.get&lt;any&gt;(environment.appBaseUrl + 'DPasdarameterSetup/GetDealParameters')
              .pipe(
                  tap(
                      (data) =&gt; {
                          this.test = [];
                          data.map((dealData: CDealParameterSetup) =&gt; {
                              dealData.actionPerformedBy = userDetailsObj.userName;
                              this.test.push(new CDealParameterSetup().deserialize(dealData));
                              this.getDealParamDatafromSubject(this.test);
                              return this.test;
                          })
                      }
                  )
              );
      }
  });
  
  </code></pre>
  
  <p>How could I find where this error is coming from? Did anybody experience any inconsistency in Jasmine?</p>