【发布时间】:2015-10-31 10:18:58
【问题描述】:
我有以下测试:
it("should load the directive without error", function () {
expect($compile(inputElement)($scope)).not.toThrow();
});
并且我的输入元素包含我的指令。我的指令对 ngModel 有要求,如果指令所在的元素具有 ngModel 指令,则测试的目的是让它编译而不会出错。所有这些都可以在生产中使用,但由于某种原因我的测试失败了,我收到了以下消息:
Actual is not a Function in __pathToJasmine/jasmine.js (line 2207)
我也在使用 Jasmine 2.0。
现在,我意识到实际的函数是 $compile,一旦用 $scope 调用它就不再是一个函数,但是我如何测试我的指令是否编译成功?
【问题讨论】:
标签: javascript angularjs unit-testing jasmine