0
votes

I'm running a unit test that makes a simple http call

karma.config.js, test.ts, tsconfig.js are all virgin boilerplate ng CLI 5.2.3, node, webpack and ts all latest versions. karma-webpack not used

The httpclient get call generates this error but only when run as a specified test in karma/jasmine/webpack:

TypeError: this.handler.handle is not a function at MergeMapSubscriber.WEBPACK_IMPORTED_MODULE_2_rxjs_operator_concatMap.a.call [as project] (:9876/_karma_webpack_/webpack:/C:/Users/sauna/Documents/adev/UK/node_modules/@angular/common/esm2015/http.js:1174) at MergeMapSubscriber._tryNext (:9876/_karma_webpack_/webpack:/C:/Users/sauna/Documents/adev/UK/node_modules/rxjs/_esm2015/operators/m

This is the test specification that makes the http call as part of an an integration suite:

httpClientInstance.get('myAPIurlReturningAJsonObj').subscribe(
  (data) => {
      testID = data.MessageText;
  },
  (error) => {
      console.log(error);
  }
);

..expectation is any string to testID

the error is something with the Observable presented by ng not being handled by Jasmine

ping me I need to present more information, thx

1
It is unclear what you are asking. - Raviprakash
...on further investigation is it possible to retrieve real data in a Jasmine test? i.e. use Jasmine as an inegreal part of integration e2e - halfbeep

1 Answers

0
votes

Answering my own question may be wrong, new to StackOverflow - I hope I've found the answer. I believe that this error's a threading/socket issue. Accessing a Jasmine http request as a unit test doesn't seem possible without using Spy. I've solved the immediate problem using Protractor