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 ?

1

There are 1 answers

0
ngLover On

In the AngularJS documentation it says

verifyNoOutstandingExpectation();

Verifies that all of the requests defined via the expect api were made. If any of the requests were not made, verifyNoOutstandingExpectation throws an exception.

so it could be the reason you have not defined any expect call but using verifyNoOutstandingExpectation so it is throwing an exception.