添加 angularStrap 模块后一切正常,除了在我的单元测试中我收到以下错误:
Error: No module: $strap.directives
...
TypeError: Unable to get property 'expect' of undefined or null reference
所以 var httpBackend = null
我将它添加到主模块:
var app = angular.module('testK', ["ngResource", "$strap.directives", "ui.if", 'ui.date']);
将 js 文件添加到 index.html
<!-- AngularJS files -->
<script type="text/javascript" src="lib/jquery.js"></script>
<script type="text/javascript" src="lib/jquery-ui-1.10.3.custom.js"></script>
<!-- <script type="text/javascript" src="lib/jquery-ui-1.10.3.custom_witheffects.js"></script> -->
<script type="text/javascript" src="lib/angular/angular.js"></script>
<script type="text/javascript" src="lib/angular/angular-resource.js"></script>
<!--<script type="text/javascript" src="lib/angular/directives/ng-table.js"></script>-->
<script type="text/javascript" src="lib/angular/ui/if.js"></script>
<script type="text/javascript" src="lib/angular/ui/datepicker.js"></script>
<script type="text/javascript" src="lib/angular/twitter-bootstrap.min.js"></script>
<script type="text/javascript" src="lib/angular/angular-strap-0.7.5.min.js"></script>
我的单元测试:
"use strict";
describe("mainT", function () {
var ctrl, scope, httpBackend, locationMock,
beforeEach(module("testK"));
beforeEach(inject(function ($controller, $rootScope, $httpBackend, $location, $injector) {
scope = $rootScope.$new();
httpBackend = $httpBackend;
locationMock = $location;
ctrl = $controller("mainT.controller.users", { $scope: scope, $location: locationMock});
}));
afterEach(function () {
httpBackend.verifyNoOutstandingRequest();
httpBackend.verifyNoOutstandingExpectation();
});
describe("method test", function () {
it('should test', function () {
//todo implementation
expect(true).toBeFalsy();
});
});
});
当我从我的应用程序模块中删除“$strap.directives”时,我的单元测试工作。有人知道为什么在我的单元测试中找不到这个表带模块吗?