Sto provando a scrivere un test per il mio controller Angolare, sto usando jasmine
karma
e angular-mocks
, ma continua a ricevere l'errore ReferenceError: Can't find variable: module
.ReferenceError: Impossibile trovare la variabile: modulo in prova angolare
Avevo un po 'di search, ma ho già il angular-mocks
nella mia pergola.
Cosa potrei mancare qui?
Quanto segue è il mio codice:
#controller
angular.module('cook_book_ctrl', [])
.controller('cookBookCtrl', function($scope, CookBook, CookBookRecipesService){
$scope.cookbookoptions = true;
CookBook.list()
.success(function(data){
$scope.recipeList = data;
CookBookRecipesService.loadCookBookRecipes($scope.recipeList);
})
.error(function(error){
})
});
#controller test
describe('CookBook controller spec', function(){
var $httpBackend, $rootScope, createController, authRequestHandler
beforeEach(module('cook_book_ctrl'));
})
#bower.json
{
"name": "HelloIonic",
"private": "true",
"devDependencies": {
"ionic": "driftyco/ionic-bower#1.0.0",
"ionic-service-analytics": "master",
"ionic-service-core": "~0.1.4",
"angular-mocks": "1.3.13"
},
"dependencies": {
"ng-cordova-oauth": "~0.1.2",
"ng-tags-input": "~2.3.0",
"angular": "~1.4.0",
"underscore": "~1.8.3",
"materialize": "~0.97.0"
},
"resolutions": {
"angular": "~1.4.0"
}
}
beforeEach(module('cook_book_ctrl'));
})
UPDATE: Screenshot aggiunto per chiarezza
grazie per la risposta, tuttavia, anche dopo aver aggiunto il file 'angular-mock.js', sto ancora ricevendo lo stesso errore. Ho aggiornato la mia domanda con uno screenshot per chiarezza – sameera207
Finalmente ho funzionato con @rebornix, grazie per l'aiuto. Ho dovuto reinstallare 'gelsomino',' karma' e 'angular-mocks', e questo link ha anche aiutato http://ericnish.io/blog/set-up-jasmine-and-karma-for-angularjs – sameera207