0

I have written some unit testing code for my angular application using jasmine.js. It's really integration testing because I am making real http call using the idea described in this link [E2E mock $httpBackend doesn't actually passThrough for me

Now, since I am making real http call, the base url for my local system is different from the DEV url, to which the TeamCity will run the test. Right now the base url is hardcoded in the unit testing code. How can I identify the environment in my test so that I can use the right url? Can I pass any parameter to Jasmine and read that in code? Thanks for the help.

Community
  • 1
  • 1
  • One of the obvious approaches is to set an environment variable with the URL and read it in the test – Yaegor Sep 21 '16 at 00:46
  • If you are actually making a real ``http`` call, you are not `unit testing` because you are depending on the network, and code at the end. This is called an ``end to end`` test. – zhon Sep 21 '16 at 06:28
  • Why do you want to make the actual ``http`` call? Mocks that don't really mock are called ``spies`` and should be used very sparingly. I can't think of a situation where I would need one. – zhon Sep 21 '16 at 06:32
  • @zhon I agree I am not doing unit testing as I mentioned in the question. – user598387 Sep 21 '16 at 13:54
  • The first line of your OP contradicts this comment. Your second line also contradicts your first line. You can improve your question. Please read [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve). When your code shows your precise problem with nothing extra, you are showing respect to those who volunteer to help you. – zhon Sep 22 '16 at 15:03

0 Answers0