The Response
class provides a flexible way to verify various aspects of an API response. It allows for positive and negative checks on status, body, headers, and duration, providing a comprehensive set of tools for API testing. This class extends the Question<boolean>
class, providing functionality for checking the status, body, headers, and duration of an API response.
This class extends the Question<boolean>
class, providing specific functionality for verifying API response aspects.
public async answeredBy(actor: Actor): Promise<boolean>;
- Description: Perform the verification based on the specified action.
- Parameters:
actor
- The actor performing the action.
- Returns:
Promise<boolean>
- The verification result (true or false).
static get has(): Response;
- Description: Create a new instance of the
Response
class for positive verification. - Returns:
Response
- A new instance of theResponse
class.
static get hasNot(): Response;
- Description: Create a new instance of the
Response
class for negative verification. - Returns:
Response
- A new instance of theResponse
class.
public statusCode(response: ResponseType, statusCode: number): Response;
- Description: Set up the verification for the response status code.
- Parameters:
response
- The response to check.statusCode
- The expected status code.
- Returns:
Response
- The updated instance of theResponse
class.
public body(response: ResponseType, body: ResponseBodyType): Response;
- Description: Set up the verification for the response body.
- Parameters:
response
- The response to check.body
- The expected body.
- Returns:
Response
- The updated instance of theResponse
class.
public headers(response: ResponseType, headers: Headers): Response;
- Description: Set up the verification for the response headers.
- Parameters:
response
- The response to check.headers
- The expected headers.
- Returns:
Response
- The updated instance of theResponse
class.
public beenReceivedWithin(response: ResponseType, duration: number): Response;
- Description: Set up the verification for the response duration.
- Parameters:
response
- The response to check.duration
- The expected duration (in milliseconds).
- Returns:
Response
- The updated instance of theResponse
class.
public withAbilityAlias(alias: string): Response;
- Description: Defines the ability alias to be used during execution.
- Parameters:
alias
- The alias.
- Returns:
Response
- Returns the current question.
Introduced in: 1.6.0
public get failAsFalse(): Response;
- Description: Returns false instead of failing when exception occurrs.
- Returns:
Response
- Returns the current question.