Angular 1.2.24: Testing directive throws undefined in scope. $ digest ();

I just installed AngularJS 1.2.24 and I am trying to check my directive. The code is as 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 at runtime . $ 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 

Something seems to be due to changes in the URLs in the browser. I am compared to previous versions, and for me this seems like new code.

I tried to revert to my previous working version 1.2.21, and everything is working fine.

Am I doing something wrong here?

+5
source share
1 answer

Turns out it was an inconsistent version with Angular mocks. I updated my angular -mocks.js to this here , and now everything works fine.

+5
source

Source: https://habr.com/ru/post/1202301/


All Articles