Ala*_*uza 5 javascript angularjs angularjs-directive angularjs-scope karma-runner
我刚刚安装了AngularJS 1.2.24,我正在尝试测试我的指令.代码如下所示:
describe('scenarios', function () {
var scope, compile;
beforeEach(module("app"));
beforeEach(module("src/widgets/tt-header/header.html"));
beforeEach(inject(function ($compile, $rootScope) {
scope = $rootScope.$new();
compile = $compile;
}));
function directive() {
var el = angular.element('<div tt-header />');
compile(el)(scope);
scope.$digest();
return el;
}
it('should load the directive', function () {
var el = directive();
expect(el).not.toBe(undefined);
});
});
Run Code Online (Sandbox Code Playgroud)
然后,当我运行测试时,我在执行范围期间收到以下消息.$ digest():
PhantomJS 1.9.7 (Mac OS X) tt-header scenarios should load the tt-header directive FAILED
TypeError: 'undefined' is not a function (evaluating '$browser.$$checkUrlChange()')
at /Users/alansouza/tt-workspace/tt-app-angular/vendor/angular/angular.js:12502
at ttHeader (/Users/alansouza/tt-workspace/tt-app-angular/tests/widgets/tt-header/tt-header-specs.js:20)
at /Users/alansouza/tt-workspace/tt-app-angular/tests/widgets/tt-header/tt-header-specs.js:27
Run Code Online (Sandbox Code Playgroud)
它似乎与浏览器中的URL更改有关.我比较以前的版本,这对我来说似乎是一个新代码.
我试图恢复到我以前的工作版本1.2.21,一切正常.
我在这里做错了吗?