DEV Community

Discussion on: Angular Http Mock Interceptor for mocked backend

yagoferrer profile image

Hi Sanidz, I was wondering if that would also intercept a non-angular request. I would like to mock a Google Location API to save $$ when running e2e test.

sanidz profile image
sanidz Author

Well, it is just a regular Angular Service, so it can intercept all requests coming from that app.

However if those requests are coming from another app you could just:
1 start local json server and mock needed google.apis
2 edit google api urls to hit new local mocked ones or if not possible
2.a edit hosts file so that your local json server acts and responds to all existing and real google api urls.

It also depends which e2e tests, cypress for example has full suport for endpoint mocking and could mock all requests out of the box :)