Open jainAdijain opened 7 years ago
Angular is an opinionated framework. Their opinion is that unit testing should never make http requests against a live server.
All you need to do is to mock your HTTP service with a Spy and expect
the provider being tested (Service
) to call #get
with the correct argument (the actual URI) since you are not really testing the connection, you just want to test the communication between your provider and HTTP service.
Hey, I know this is not the right platform to ask this, but on right platform, there is no reply from anyone. How to mock a service which contains http requests? For eg:
I want to test my provider class, so I am unable to write spec for providers. My provider is as follows: service.ts
My page.ts is as follows:
page.ts
service.spec.ts
All the imports are done correctly, only the logic to test the
getGoogle()
withhttp.get()
needs to be tested.Please help or share some links or tell me some steps in order to do testing of this ionic2 content.Thanks Adi