Javascript 安圭拉酒店;因果报应茉莉花-如果验证没有超出预期,则不工作();或verifyNoOutstandingRequest();孤立无援

Javascript 安圭拉酒店;因果报应茉莉花-如果验证没有超出预期,则不工作();或verifyNoOutstandingRequest();孤立无援,javascript,angularjs,unit-testing,karma-jasmine,httpbackend,Javascript,Angularjs,Unit Testing,Karma Jasmine,Httpbackend,我有一个http请求尚未刷新,所以当我有这样的请求时 afterEach(function(){ $httpBackend.verifyNoOutstandingExpectation(); $httpBackend.verifyNoOutstandingRequest(); }); afterEach(function(){ $httpBackend.verifyNoOutstandingRequest(); }); 它按预期工作,我得到了回报 错误:未刷新

我有一个http请求尚未刷新,所以当我有这样的请求时

afterEach(function(){
      $httpBackend.verifyNoOutstandingExpectation();
      $httpBackend.verifyNoOutstandingRequest();
});
afterEach(function(){
    $httpBackend.verifyNoOutstandingRequest();
});
它按预期工作,我得到了回报

错误:未刷新的请求:1

错误消息来自
$httpBackend.verifyNoOutstandingRequest(),但当我有这样的代码时

afterEach(function(){
      $httpBackend.verifyNoOutstandingExpectation();
      $httpBackend.verifyNoOutstandingRequest();
});
afterEach(function(){
    $httpBackend.verifyNoOutstandingRequest();
});
不会抛出错误。


为什么会这样?我必须把这两种方法放在一起吗?

在AngularJS文档中说

verifyNoOutstandingExpectation();
验证是否已发出通过expect api定义的所有请求。如果未发出任何请求,VerifyNoOutstandingExpection将抛出异常


因此,这可能是您没有定义任何expect调用但使用VerifyNoOutstandingExpection的原因,因此它会引发异常。

您能分享您的测试代码吗?