我刚刚安装了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);
});
});
然后,当我运行测试时,我在执行范围时收到以下消息。$ 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
它似乎与浏览器中的网址更改有关。我与以前的版本相比,这对我来说似乎是一个新代码。
我试图恢复到之前的工作版本1.2.21,一切正常。
我在这里做错了吗?