Skip to content Skip to sidebar Skip to footer

How To Change $httpbackend When[method] Statements Between Requests In Unit Testing?

In my testing i initiate some model data and mock the response: beforeEach(function(){ var re = new RegExp(/^http\:\/\/.+?\/users-online\/(.+)$/); $httpBackend.whenGET(re).re

Solution 1:

resetExpectations()

Execution

afterEach($httpBackend.resetExpectations);

Documentation

Resets all request expectations, but preserves all backend definitions. Typically, you would call resetExpectations during a multiple-phase test when you want to reuse the same instance of $httpBackend mock.

documentation source: https://docs.angularjs.org/api/ngMock/service/$httpBackend

Post a Comment for "How To Change $httpbackend When[method] Statements Between Requests In Unit Testing?"