lundi 25 juillet 2016

How to account for a service's dependencies when testing Angular with Jasmine

So far I've only been able to figure out how to get the most basic unit tests to pass when testing Angular service's with Jasmine, e.g. "common is an object". But common in turn is dependent on other modules, and it's apparent from my plunker that merely accounting for logger within common.js for example is not sufficient -- it causes an 'Unknown provider: loggerProvider <- logger <- common' error.

So I'm guessing I must somehow inject the logger module with code in the commonSpec.js file, and that it must common before common. I've tried to use $inject on logger in the same manner as for common, but it hasn't worked. I've seen Q/A's that suggest that $provide needs to be used but I haven't been able to figure that out either.

Aucun commentaire:

Enregistrer un commentaire