RequestRuleBuilder | mockttp

Hierarchy

  • BaseRuleBuilder
    • RequestRuleBuilder

Completion

always

  • always(): this
  • Returns this

once

  • once(): this
  • Returns this

thrice

  • thrice(): this
  • Returns this

times

  • times(n): this
  • Returns this

twice

  • twice(): this
  • Returns this

Matching

forHost

  • forHost(host): this
  • Returns this

forHostname

  • forHostname(hostname): this
  • Parameters

    • hostname: string

    Returns this

forPort

  • forPort(port): this
  • Returns this

matching

  • matching(content): this
  • Parameters

    • content: ((request: CompletedRequest) => MaybePromise<boolean>)
        • (request): MaybePromise<boolean>
        • Returns MaybePromise<boolean>

    Returns this

withBody

  • withBody(content): this
  • Parameters

    • content: string | RegExp

    Returns this

withBodyIncluding

  • withBodyIncluding(content): this
  • Parameters

    • content: string

    Returns this

withCookie

  • withCookie(cookie): this
  • Parameters

    • cookie: {
          [key: string]: string;
      }
      • [key: string]: string

    Returns this

withExactQuery

  • withExactQuery(query): this
  • Returns this

withForm

  • withForm(formData): this
  • Parameters

    • formData: {
          [key: string]: string;
      }
      • [key: string]: string

    Returns this

withHeaders

  • withHeaders(headers): this
  • Parameters

    • headers: {
          [key: string]: string;
      }
      • [key: string]: string

    Returns this

withJsonBody

  • withJsonBody(json): this
  • Returns this

withJsonBodyIncluding

  • withJsonBodyIncluding(json): this
  • Returns this

withMultipartForm

  • withMultipartForm(...matchConditions): this
  • Returns this

withProtocol

  • withProtocol(protocol): this
  • Parameters

    • protocol:
          | "http"
          | "https"
          | "wss"
          | "ws"

    Returns this

withQuery

  • withQuery(query): this
  • Parameters

    • query: {
          [key: string]: string | number | (string | number)[];
      }
      • [key: string]: string | number | (string | number)[]

    Returns this

withUrlMatching

  • withUrlMatching(pattern): this
  • Parameters

    • pattern: RegExp

    Returns this

Other

constructor

addWebhook

  • addWebhook(url, events?): this
  • Returns this

asPriority

  • asPriority(priority): this
  • Parameters

    • priority: number

    Returns this

delay

  • delay(ms): this
  • Returns this

waitForRequestBody

  • waitForRequestBody(): this
  • Returns this

Responses

thenCallback

thenCloseConnection

thenForwardTo

thenFromFile

  • thenFromFile(status, filePath, headers?): Promise<MockedEndpoint>
  • Parameters

    • status: number
    • filePath: string
    • Optionalheaders: Headers

    Returns Promise<MockedEndpoint>

  • thenFromFile(status, statusMessage, filePath, headers?): Promise<MockedEndpoint>
  • Parameters

    • status: number
    • statusMessage: string
    • filePath: string
    • Optionalheaders: Headers

    Returns Promise<MockedEndpoint>

thenJson

thenPassThrough

thenReply

  • thenReply(status, data?, headers?, trailers?): Promise<MockedEndpoint>
  • Parameters

    • status: number
    • Optionaldata: string | Buffer
    • Optionalheaders: Headers
    • Optionaltrailers: Trailers

    Returns Promise<MockedEndpoint>

  • thenReply(status, statusMessage, data, headers?, trailers?): Promise<MockedEndpoint>
  • Parameters

    • status: number
    • statusMessage: string
    • data: string | Buffer
    • Optionalheaders: Headers
    • Optionaltrailers: Trailers

    Returns Promise<MockedEndpoint>

thenResetConnection

thenSendJsonRpcError

thenSendJsonRpcResult

thenStream

thenTimeout