I've just installed AngularJS 1.2.24 and I'm trying to test my directive. The code looks like follows:
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);
});
});
Then, when I run the test I get the following message during execution of scope.$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
It seems to be something related to url changes in the browser. I compared to previous versions and this seems a new code to me.
I tried to revert to my previous working version 1.2.21 and everything works fine.
Am I doing something wrong here?
It turns out that was a mismatched version with the Angular mocks. I've updated my angular-mocks.js to this one here and everything works fine now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With