我有 angularJs 控制器
angular.module('App.ctrl.guests', [])
.controller('guestsController', ['$scope', '$http', '$location', '$timeout', 'guestsService', function ($scope, $http, $location, $timeout, guestsService) {
$scope.tiles = [];
}])
和茉莉花测试
/// <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([]);
});
})
每次我在 Visual Studio chutzpah 中运行时,我都会得到:
ReferenceError:找不到变量:文件中的模块:///.../JasmineTests/guestsControllerTest.js(第 5 行)
ReferenceError:找不到变量:注入文件:///.../JasmineTests/guestsControllerTest.js(第 12 行)
参考 angular.js 和 jasmine 是否有问题不知道什么是模块/注入关键字?这是我第一次进行 js 测试:/