test-tube.HttpTestHistory

A class to manage the history of HTTP requests, responses, request specs, and response specs. This is useful during the execution of an HttpTest if you want to replay requests or validate that the response matches a previous response. Note, this is accessible during test execution using httpHistory.

Instance Properties

_requests
Request[]
Required
Description The request history
_requestSpecs
Required
Description The request spec history
_responses
Response[]
Required
Description The response history
_responseSpecs
Required
Description The response spec history
length
number
Required
Description The current number of elements in the history

Methods

_get  
Arguments
  • index (number | string) – The index/name of the element to retrieve. If this is a number, it can be negative.
  • target (Object[]) – The history object for request specs, response specs, requests, or responses
Throws RangeError
Return type Object
Description _get description
addReq  
Arguments
  • name (string) – A name to reference the request spec by (pulled from the test name)
  • req (Request) – A request
Return type undefined
Description Add a request
addReqSpec  
Arguments
  • name (string) – A name to reference the request spec by (pulled from the test name)
  • reqSpec (ReqSpec) – A request spec
Return type undefined
Description Add a request spec to the history
addRes  
Arguments
  • name (string) – A name to reference the response spec by (pulled from the test name)
  • res (Request) – A response
Return type undefined
Description Add a response
addResSpec  
Arguments
  • name (string) – A name to reference the response spec by (pulled from the test name)
  • resSpec (ResSpec) – A response spec
Returns undefined
Return type undefined
Description Add a response spec to the history
get  
Arguments
  • index (number | string) – The index or name of the history element to retrieve. If this is a number, it can be negative.
Returns Keys are “reqSpec”, “resSpec”, “req”, and “res”
Return type Object
Description Get a request spec, response spec, request, and response
getReq  
Arguments
  • index (number | string) – The index or name of the request to retrieve. If this is a number, it can be negative.
Return type Request
Description Get a request
getReqSpec  
Arguments
  • index (number | string) – The index or name of the request spec to retrieve. If this is a number, it can be negative.
Return type ReqSpec
Description Get a request spec
getRes  
Arguments
  • index (number | string) – The index or name of the response to retrieve. If this is a number, it can be negative.
Return type Response
Description Get a response
getResSpec  
Arguments
  • index (number | string) – The index or name of the response spec to retrieve. If this is a number, it can be negative.
Return type ResSpec
Description Get a response spec