Show Menu
Cheatography

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
whenJSONP(url)
Create backend definition for JSONP request

Additional methods

flush([count])
Flushes all pending requests using trained responses
resetE­xpe­cta­tions()
Resets all request expect­ations, but preserves all backend defini­tions. (Wipe expect, but keep when)
 

'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
expect­JSONP(url)
Create request expect­ation for JSONP request

Additional expect­ations

verify­NoO­uts­tan­din­gEx­pec­tation()
Verifies that all of the requests defined via the expect api were made.
verify­NoO­uts­tan­din­gRe­quest()
Verifies that there are no outsta­nding requests that need to be flushed
                       
 

Comments

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

          ISTQB Test Automation Engineering Cheat Sheet
          Cypressio Cheat Sheet
          Selenium WebDriver Cheat Sheet 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