我有一个尚未刷新的http请求,所以当我有这样的
时afterEach(function(){
$httpBackend.verifyNoOutstandingExpectation();
$httpBackend.verifyNoOutstandingRequest();
});
按预期工作,我得到了
错误:未刷新的请求:1
错误消息来自$httpBackend.verifyNoOutstandingRequest();
,但是当我有这样的
afterEach(function(){
$httpBackend.verifyNoOutstandingRequest();
});
不会引发任何错误。
为什么会这样?我是否必须将这两种方法保持在一起?
答案 0 :(得分:0)
在AngularJS文档中,它说
verifyNoOutstandingExpectation();
验证通过expect api定义的所有请求。如果未提出任何请求,则verifyNoOutstandingExpectation会抛出异常。
所以这可能是你没有定义任何期望调用但是使用verifyNoOutstandingExpectation所以它抛出异常的原因。