意外请求:注入指令后POST不再需要请求

时间:2017-03-22 09:06:02

标签: javascript angularjs jasmine karma-jasmine e2e-testing

我正在注射一个指令来测试这里的答案: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);
    };
}

当我调试它时,elem变量实际上得到了我想要的指令,但由于某种原因,测试会给我这个错误:Unexpected request: POST no more request expected

some-id是一个具有ng-repeat属性且受$http服务器请求影响的div,但我没有使用$httpBackend所以我不知道为什么会出现此错误发生的情况。

有人可以弄清楚为什么会这样吗?

提前致谢!

0 个答案:

没有答案
相关问题