我正在开发AngularJs 1.6应用程序。
其中一个指令的名称为“ oprStarRating ”。
我正在为此指令编写测试用例。
我已经编写了测试用例,但是每次遇到相同的错误时,都应该定义控制器。虽然我已经定义了。谁能帮助我知道我在那里犯了什么错误?
import oprStarRatingModule from "shared/directives/oprStarRating/oprStarRating.module";
describe("oprStarRatingController", function () {
'use strict';
beforeEach(function () {
window.module(oprStarRatingModule);
});
var ctrl, element, parentScope, angularCompTestHelper, ratingPercentage, totalCount;
beforeEach(inject(function ($rootScope, $controller, $animate, $timeout, $compile) {
parentScope = $rootScope.$new();
ratingPercentage = 20;
totalCount = "42";
element = angular.element([
'<opr-star-rating rating-percentage = "ratingPercentage"',
'total-count = "totalCount">',
'</opr-star-rating>'
].join());
element = $compile(element)(parentScope);
parentScope.ratingPercentage = ratingPercentage;
parentScope.$digest();
ctrl = element.controller('oprStarRating');
angularCompTestHelper = new AngularComponentTestHelper(ctrl, parentScope);
}));
//Here is the issue
it("should be be defined", function () {
expect(ctrl).toBeDefined();
});
});