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!