Show Menu

ngMock - httpBackend Quick Reference Cheat Sheet by

Quick reference to available $httpBackend functions
testing     angularjs     expect     angular     flush     httpbackend     when

'when' methods

when­me­thod, url, [data], [head­ers])
Creates a new backend definition
when­GET­url, [head­ers])
Create backend definition for GET request
when­HEA­D­(url, [head­ers])
Create backend definition for HEAD request
when­DEL­ETE­url, [head­ers])
Create backend definition for DELETE request
when­POS­T­(url, [data], [head­ers])
Create backend definition for POST request
when­PUT­url, [data], [head­ers])
Create backend definition for PUT request
when­PAT­CH­(­url, [data], [head­ers])
Create backend definition for PATCH request
when­JSO­NP­(­url)
Create backend definition for JSONP request

Additional methods

flus­h­([­cou­nt])
Flushes all pending requests using trained responses
rese­tEx­pec­tat­ion­s()
Resets all request expect­ations, but preserves all backend defini­tions. (Wipe expect, but keep when)
 

'expect' methods

expe­ct­(­met­hod, url, [data], [head­ers])
Creates a request expect­ation
expe­ctG­ET­(­url, [head­ers])
Create request expect­ation for GET request
expe­ctH­EAD­url, [head­ers])
Create request expect­ation for HEAD request
expe­ctD­ELE­TE­(­url, [head­ers])
Create request expect­ation for DELETE request
expe­ctP­OST­url, [data], [head­ers])
Create request expect­ation for POST request
expe­ctP­UT­(­url, [data], [head­ers])
Create request expect­ation for PUT request
expe­ctP­ATC­H­(url, [data], [head­ers])
Create request expect­ation for PATCH request
expe­ctJ­SON­P­(url)
Create request expect­ation for JSONP request

Additional expect­ations

veri­fyN­oOu­tst­and­ing­Exp­ect­ati­on()
Verifies that all of the requests defined via the expect api were made.
veri­fyN­oOu­tst­and­ing­Req­ues­t()
Verifies that there are no outsta­nding requests that need to be flushed

Download the ngMock - httpBackend Quick Reference Cheat Sheet

1 Page
//media.cheatography.com/storage/thumb/citguy_ngmock-httpbackend-quick-reference.750.jpg

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!

 

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

          AngularJS Cheat Sheet
          AngularUI Router 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