When testing an angular controller - Unable to find a variable: module / inject by chutzpah

I have an angularJs controller

angular.module('App.ctrl.guests', []) .controller('guestsController', ['$scope', '$http', '$location', '$timeout', 'guestsService', function ($scope, $http, $location, $timeout, guestsService) { $scope.tiles = []; }]) 

and jasmine test

 /// <reference path="~/Scripts/angular.js" /> /// <reference path="../../ProjectWeb/Scripts/app/guests/guestsCtrl.js" /> /// <reference path="~/Scripts/angular-mocks.js" /> /// <reference path="~/Scripts/jasmine.js" /> 'use strict'; describe('App.ctrl.guests', function () { var scope, controller; beforeEach(function () { module('App.ctrl.guests') }); beforeEach(inject(function ($rootScope, $controller) { scope = $rootScope.$new(); controller = $controller('guestsController', { $scope: scope }); })); it('should have empty array', function () { expect(scope.tiles).toBe([]); }); }) 

and every time I run Visual Studio chutzpah, I get:

ReferenceError: cannot find variable: module in File: ///.../JasmineTests/guestsControllerTest.js (line 5)

ReferenceError: cannot find the variable: insert file: ///.../JasmineTests/guestsControllerTest.js (line 12)

Is thera a problem with link angular.js and jasmine, don't know what are modules / keyword injections? This is my first time testing js: /

+8
javascript angularjs visual-studio-2012 jasmine chutzpah
source share
2 answers

I found in this article on how to drag and drop JavaScript files for testing and the right way.

+5
source share

I had this exact exception a couple of minutes ago on our TFS build server. It turns out that this exception also occurs when the option "Copy to output directory" in the "Properties" dialog box is set to a different option than "Do not copy". In our situation, several files were tested from the \ bin folder, which led to the wrong link path.

0
source share

All Articles