heldt
heldt

Reputation: 4266

Karma test exception in angular2 application

Can I get a better log or something? I don't have a clue where to look for the error.

Chrome 57.0.2987 (Linux 0.0.0) ERROR
  Uncaught Response with status: 0  for URL: null
  at webpack:///~/rxjs/Subscriber.js:238:0 <- src/test.ts:737
PhantomJS 2.1.1 (Linux 0.0.0): Executed 31 of 31 ERROR (1.258 secs / 1.352 secs)

Upvotes: 5

Views: 371

Answers (1)

jody tate
jody tate

Reputation: 1406

Your code is making an HTTP request and failing. Per the error message, the URL is null and the status code is 0. 0 isn't an actual HTTP status code, but it can mean a timeout occurred. This Stack Overflow question and answer has some pointers on what 0 can mean.

I ran into this when testing a component. Mocking the HTTP request solved the problem. For how to do that, I recommend this thoughtram article on testing HTTP services.

Upvotes: 1

Related Questions