Optional
abilityOptional
callStatic
hasStatic
hasVerify if the response (including receiving body) is received within a given duration.
the response to check
expected duration (in milliseconds) not to be exceeded
the Response instance
check if response was received within 2s
Response.has.beenReceivedWithin(response, 2000);
check if response was not received within 2s
Response.hasNot.beenReceivedWithin(response, 2000);
Verify if the response body equals given one.
the response to check.
the expected body.
the Response instance
json format
Response.has.body(response, { key: value });
text format
Response.hasNot.body(response, 'text' );
buffer format
Response.has.body(response, Buffer.from('abc') );
Verify if the response has the given headers either by key (value to be set to undefined) or key/value lookup.
the Response instance
only check for header presence by passing undefined as the value
Response.has.headers(response, { 'content-type': undefined });
lookup for key/value combination to be present
Response.hasNot.headers(
response,
{ 'content-type': 'application/json' }
);
Verify if the response has a given status code.
the response to check.
the expected status code.
the Response instance
Response.has.statusCode(response, 200);
Response.hasNot.statusCode(response, 200);
Generated using TypeDoc
Verify certain aspects of an API Response. A mode operator must be prepended.