Show Menu

ngMock - httpBackend Quick Reference Cheat Sheet by

Quick reference to available $httpBackend functions

'when' methods

when(method, url, [data], [headers])
Creates a new backend definition
whenGET(url, [headers])
Create backend definition for GET request
whenHEAD(url, [headers])
Create backend definition for HEAD request
whenDELETE(url, [headers])
Create backend definition for DELETE request
whenPOST(url, [data], [headers])
Create backend definition for POST request
whenPUT(url, [data], [headers])
Create backend definition for PUT request
whenPATCH(url, [data], [headers])
Create backend definition for PATCH request
Create backend definition for JSONP request

Additional methods

Flushes all pending requests using trained responses
Resets all request expect­ations, but preserves all backend defini­tions. (Wipe
, but keep

'expect' methods

expect(method, url, [data], [headers])
Creates a request expect­ation
expectGET(url, [headers])
Create request expect­ation for GET request
expectHEAD(url, [headers])
Create request expect­ation for HEAD request
expect­DELETE(url, [headers])
Create request expect­ation for DELETE request
expectPOST(url, [data], [headers])
Create request expect­ation for POST request
expectPUT(url, [data], [headers])
Create request expect­ation for PUT request
expect­PATCH(url, [data], [headers])
Create request expect­ation for PATCH request
Create request expect­ation for JSONP request

Additional expect­ations

Verifies that all of the requests defined via the
api were made.
Verifies that there are no outsta­nding requests that need to be flushed


No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Selenium WebDriver Cheat Sheet Cheat Sheet
          Cypressio Cheat Sheet
          ISTQB Test Automation Engineering Cheat Sheet

          More Cheat Sheets by CITguy

          jasmine JS testing Cheat Sheet
          Extending Ruby with C - Part 1 Cheat Sheet
          *nix users and groups Cheat Sheet