AngularJS Jasmine-Test schlägt fehl: Fehler beim Instanziieren des Moduls
Meine eckige App funktionierte großartig und meine Tests mit Karma und Jasmin auch, bis ich eine Abhängigkeit in hinzufügteui.bootstrap
. Jetzt funktioniert die App immer noch wie erwartet, aber ich kann meine Tests nicht zum Laufen bringen. Das habe ich:
app.js - Abhängigkeit in hinzugefügtui.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);
});
});
Und mein Test, den ich mit Grunzen und Krama durchführe, schlägt fehl wegen:
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
Was habe ich vermisst? Die App läuft ohne Probleme, nur der Test schlägt fehl.