I have 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 in Visual studio chutzpah i get:
ReferenceError: Can't find variable: module in file:///.../JasmineTests/guestsControllerTest.js (line 5)
ReferenceError: Can't find variable: inject in file:///.../JasmineTests/guestsControllerTest.js (line 12)
Is thera a problem with reference angular.js and jasmine dont know what is module/inject keywords? It is my first time with js testing :/
I have 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 in Visual studio chutzpah i get:
ReferenceError: Can't find variable: module in file:///.../JasmineTests/guestsControllerTest.js (line 5)
ReferenceError: Can't find variable: inject in file:///.../JasmineTests/guestsControllerTest.js (line 12)
Is thera a problem with reference angular.js and jasmine dont know what is module/inject keywords? It is my first time with js testing :/
Share Improve this question edited Jul 25, 2014 at 12:24 netmajor asked Jul 25, 2014 at 12:10 netmajornetmajor 6,58514 gold badges70 silver badges102 bronze badges 3- 2 Have you included references to the libraries? Not using Visual Studio myself but I think this guy is doing the same setup as you rosher.co.uk/post/2013/10/22/… – GillesC Commented Jul 25, 2014 at 12:18
- Yes, I add references, I update code. – netmajor Commented Jul 25, 2014 at 12:24
- Thank You gillesc, I fount in this article to drag and drop js files to test file and now paths are correct ;) – netmajor Commented Jul 25, 2014 at 13:11
2 Answers
Reset to default 4I found in this article on how to drag and drop JavaScript files for testing and correct path.
I had this exact exception a couple of minutes ago on our TFS build server. It turns out that this exception is also occurring when the 'Copy to Output Directory' option in the Properties dialog is set to another option than 'Do not copy'. In our situation, a couple of files was tested from the \bin folder, which lead to an incorrect reference path.