I'm to setup standalone jasmine testing. I believe I have everything setup correctly. When I run my first test:
我要建立独立的茉莉花测试。我相信我已经把一切都安排好了。当我进行第一次测试时:
describe('Logon Controller', function() {
var controller, $scope;
beforeEach(module("app"));
//beforeEach(inject(function ($rootScope, $controller) {
// scope = $rootScope.$new();
// contoller = $controller('logonCtrl', {
// $scope: scope
// });
//}));
beforeEach(inject(function ($rootScope) {
scope = $rootScope.$new();
}));
//it('should say hello', function ($controller, $rootScope) {
// //var scope = $rootScope.$new();
// var controller = $controller('logonCtrl', { $scope: $scope });
// //expect(angular.isFunction(scope.get)).toEqual("Hello There :)");
// expect(scope.Hello()).toEqual("Hello There :)");
// expect($scope.Hello).toBeDefined();
//});
it('should say hello', inject(function ($controller, $rootScope) {
//var scope = $rootScope.$new();
var controller = $controller('logonCtrl', {$scope: $scope});
//expect(angular.isFunction(scope.get)).toEqual("Hello There :)");
//expect(scope.Hello()).toEqual("Hello There :)");
expect($scope.Hello).toBeDefined();
}));
});
I get this error message: Error: [$injector:modulerr] http://errors.angularjs.org/1.3.11/$injector/modulerr?p0=app.............
我得到了这个错误信息:错误:[$injector:modulerr] http://errors.angularjs.org/1.3.11/$injector/modulerr?
Here is my app module config.
这是我的app模块配置。
var app = angular.module('app', ['ui.router','ngMaterial']);
Here is my controller:
这是我的控制器:
app.controller('logonCtrl', ['$scope', '$state', '$interval', function ($scope, $state, $interval) {
$scope.hello = function() {};
});
]);
I am using the standalone version of Jasmine 2.2.0. I have no clue what the issue could be, everything I have done is pretty basic stuff. Any help would be very much appreciated.
我使用的是独立版本的Jasmine 2.2.0。我不知道这个问题是什么,我所做的一切都是很基本的事情。非常感谢您的帮助。
UPDATE: here is what my SpecRunner.html looks like:
更新:这是我的参谋。html的样子:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Jasmine Spec Runner v2.2.0</title>
<link rel="shortcut icon" type="image/png" href="JasmineUnitTest/lib/jasmine-2.2.0/jasmine_favicon.png">
<link rel="stylesheet" href="JasmineUnitTest/lib/jasmine-2.2.0/jasmine.css">
<script type="text/javascript" src="JasmineUnitTest/lib/jasmine-2.2.0/jasmine.js"></script>
<script type="text/javascript" src="JasmineUnitTest/lib/jasmine-2.2.0/jasmine-html.js"></script>
<script type="text/javascript" src="JasmineUnitTest/lib/jasmine-2.2.0/boot.js"></script>
<script type="text/javascript" src="JasmineUnitTest/lib/jasmine-2.2.0/angular.min.js"></script>
<script type="text/javascript" src="JasmineUnitTest/lib/jasmine-2.2.0/angular-mocks.js"></script>
<!-- include source files here... -->
<script type="text/javascript" src="js/controllers/logonCtrl.js"></script>
<!-- include spec files here... -->
<script type="text/javascript" src="JasmineUnitTest/specs/logonController-spec.js"></script>
</head>
<body>
</body>
</html>
1 个解决方案
#1
2
It looks like the $injector
fails to find some of your dependencies. Are you sure the script containing your controller is properly loaded ?
看起来$injector没有找到您的一些依赖项。您确定包含您的控制器的脚本已经正确加载了吗?
#1
2
It looks like the $injector
fails to find some of your dependencies. Are you sure the script containing your controller is properly loaded ?
看起来$injector没有找到您的一些依赖项。您确定包含您的控制器的脚本已经正确加载了吗?