Falha no teste do AngularJS Jasmine: falha ao instanciar o módulo
Meu aplicativo angular funcionou muito bem e meus testes, usando karma e jasmim, até adicionar uma dependência noui.bootstrap
. Agora, o aplicativo ainda funciona conforme o esperado, mas não consigo executar meus testes. Isto é o que eu tenho:
app.js - dependência adicional emui.bootstrap
angular.module('myApp', ['ngResource', 'ngRoute', 'ui.bootstrap']).config(function(...) {...});
service.js
angular.module('myApp').service('myService', function () {})
controller.js
angular.module('myApp').controller('MyController', function ($scope, $http, myService) {})
tests / main.js
describe('Controller: MyController', function () {
var MyController, scope;
// load the controller's module
beforeEach(function(){
module('myApp');
inject(function ($controller, $rootScope) {
scope = $rootScope.$new();
MyController = $controller('MyController', {
$scope:scope
});
});
});
it('should do something', function () {
expect(scope.myOptions.length).toBe(5);
});
});
E meu teste, que eu executo usando grunt e krama, falha devido a:
Error: [$injector:modulerr] Failed to instantiate module myApp due to:
Error: [$injector:modulerr] Failed to instantiate module ui.bootstrap due to:
Error: [$injector:nomod] Module 'ui.bootstrap' is not available! You either misspelled the module name or forgot
O que eu perdi? O aplicativo é executado sem problemas, apenas o teste falha.