0

I am injecting a directive to test like the answer here: How do I test the HTML pointed to by the templateUrl of an angular directive?

describe('MyAppTest', function() {
    let elem;
    let scope;

    beforeEach(module('my.app'));

    beforeEach(inject(function ($rootScope, $compile) {
        scope = $rootScope.$new();
        elem = $compile('<my-directive></my-directive>')(scope)[0];
        $scope.$digest();
    }));

    it('Should success', function () {
        expect(elem.getElementById('some-id').childElementCount.not.toBe(0);
    };
}

While I debug it the elem variable actually get my wanted directive but for some reason the test throw me this error: Unexpected request: POST no more request expected.

The some-id is a div that has ng-repeat attribute and influenced from a server request with $http, but I am not using $httpBackend so I don't know why this error happens.

Someone can figure out why this is happening?

Thanks in advance!

Community
  • 1
  • 1
Sagie
  • 996
  • 3
  • 12
  • 25
  • Is this the only test you have in your app ? Because it could be invalidated by another test. If it's the case try to launch this test alone by writing 'fdescribe' instead of 'describe' – Cyril Mar 22 '17 at 09:41
  • I have more tests in my app and I already run it with `fdescribe`. @Cyril – Sagie Mar 22 '17 at 09:43

0 Answers0