How do I mock a local variable for a function in a service? Jasmine / Karma Tests

The Angular service has several features. They all use a local variable defined with var varName

at the top of the file.

Is there a way to mock this variable when unit testing a function?

+3
angularjs unit-testing karma-runner jasmine


source to share


1 answer


In short, no.

The easiest way is to place it at the $ scope level. Or maybe as a constant with angle constants



angular constant

Or, if you are a really crazy dude, you can make a script that changes the value of var, but seriously don't do it, that's crazy.

+3


source to share







All Articles
Loading...
X
Show
Funny
Dev
Pics