Verify certain aspects of an API Response. A mode operator must be prepended.

Hierarchy

  • Question<boolean>
    • Response

Properties

Accessors

Methods - Other

Methods - called internally

Methods - mode operators

Properties

abilityAlias?: string
callStack?: CallStackInfo[]

Accessors

Methods - Other

  • Parameters

    • entry: CallStackInfo

    Returns void

  • Parameters

    • calledWith: CallStackCalledWith

    Returns void

  • Set the alias which is used for an underlying ability

    Parameters

    • alias: undefined | string

      with which an ability was initialized

    Returns this

    current action

Methods - called internally

  • Verify if the given status is equal to the given response's status.

    Parameters

    • actor: Actor

      the actor which is used

    Returns Promise<boolean>

    true if the element has the specified state, false otherwise.

Methods - mode operators

  • Verify if the response (including receiving body) is received within a given duration.

    Parameters

    • response: Response

      the response to check

    • duration: number

      expected duration (in milliseconds) not to be exceeded

    Returns Response

    the Response instance

    Example

    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.

    Parameters

    Returns Response

    the Response instance

    Example

    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.

    Parameters

    • response: Response

      the response to check.

    • headers: Headers

      the expected header.

    Returns Response

    the Response instance

    Example

    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.

    Parameters

    • response: Response

      the response to check.

    • statusCode: number

      the expected status code.

    Returns Response

    the Response instance

    Example

    Response.has.statusCode(response, 200);
    Response.hasNot.statusCode(response, 200);

Generated using TypeDoc