I have difficulties unit testing angularJS due to the injector not injecting properly. Anything I inject turns out to be undefined
.
Module:
app.module.js
angular.module('myServices', []);
AngularTest.js
describe('AngularTest', function() {
beforeEach(module('myServices'));
var scope;
beforeEach(inject(function(_$rootScope_) {
// The injector unwraps the underscores (_) from around the parameter names when matching
scope = _$rootScope_;
}));
describe('Testing Angular injection', function() {
it('scope should be defined', function() {
expect(scope).toBeDefined(); // fails
});
});
});
I have successfully tested controllers in my main module, however, this particular module is testing my sanity.
Any ideas ?
Aucun commentaire:
Enregistrer un commentaire