Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fr(ngMockE2E) add $httpbackend.resetBackendDefinitions #7238

Closed
@AGoliath

Description

@AGoliath

Hi there,
consider this scenario:

I have a complex e2e test scenario where I first call

$httpBackend.whenPOST(/.*/).passThrough();

until a certain point in my testcase. After that point, i´d like to exchange the mock behaviour, and remove the "passTHrough-all-POST" and replace that with very specific mock responses such as

    $httpBackend.whenPOST('/authenticate').respond(function (method, url, data, headers) {
         if (data.user == ""){
           //do stuff
            return [404,"No user found"]
        } else {
            //do stuff
            return [200,data];
        }
    });

Currently, this won´t work since the "CatchAll-POST"-Rule will passThrough() all POST requests.

This could be changed if a new method is added, might be as simple as adding this to angular-mocks.js

  $httpBackend.clearBackendDefinitions = function(){
      definitions = [];
  }

What does the community think about such a method?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions