mercredi 25 mars 2015

How to inject references in angularjs unit test

I saw two different ways of injecting references in unit tests.


Underscore Wrapping



beforeEach( inject( function(_myService_){
myService = _myService_;
}));


or


$injector injection



beforeEach(inject(function($injector) {
myService = $injector.get('myService');
}));


What are the differences? Which one is the best practice?


Aucun commentaire:

Enregistrer un commentaire