ResponseParser parses and makes assertions about responses.

Constructors

Properties

afterHooks: AfterHook[] = []
assertions: ResponseAssertion[] = []
response: Promise<Response>

Methods

  • Hook into the response lifecycle to run arbitrary logic after a response has been received. Useful, for example, if you need to automatically close a server when a response has been received.

    Parameters

    • hook: AfterHook

      An arbitrary (possibly async) function to run after the response has been received.

    Returns ResponseParser

  • Returns Promise<Response>

  • Runs assertions and returns the HTTP response body parsed as json

    Type Parameters

    • T = any

    Returns Promise<T>

    JSON response body, or throws an error if unparsable

  • Runs assertions and returns a raw http response

    Returns Promise<Response>

    a raw HttpResponse

  • Runs assertions and returns the HTTP response body parsed as text

    Returns Promise<string>

    response body as text

Generated using TypeDoc