An Angular service has several functions. All of them make use of a local variable defined via a var varName
at the top of the file.
Is there any way of mocking this variable when unit-testing the function?
An Angular service has several functions. All of them make use of a local variable defined via a var varName
at the top of the file.
Is there any way of mocking this variable when unit-testing the function?
In short no.
The simplest way would be to put it on $scope level. Or Maybe as an angularjs constant
Or if you'r a really crazy dude you can make a script that change the value of the var, but seriously don't do that, it's crazy.