4

I have one http request that has not been flushed, so when I have it like this

afterEach(function(){
      $httpBackend.verifyNoOutstandingExpectation();
      $httpBackend.verifyNoOutstandingRequest();
});

It works as expected and I get

Error: Unflushed requests: 1

The error message comes from $httpBackend.verifyNoOutstandingRequest();, but when I have it like this

afterEach(function(){
    $httpBackend.verifyNoOutstandingRequest();
});

No error is thrown.

Why is it so ? Do I have to alwys keep the both method together ?

4

1 回答 1

0

在 AngularJS 文档中它说

verifyNoOutstandingExpectation();

验证通过 expect api 定义的所有请求都已发出。如果未发出任何请求,verifyNoOutstandingExpectation 将引发异常。

所以这可能是您没有定义任何期望调用但使用 verifyNoOutstandingExpectation 的原因,因此它引发了异常。

于 2015-06-25T07:23:28.730 回答