Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

API Documentation

Daniel Bechler edited this page · 2 revisions
Clone this wiki locally

Methods

server().onRequest(requestConfig)

Configures a new request handler. Must be followed by one of the response definition methods below.

  • requestConfig Type: Object
    The request to configure a response for.

respondWith(statusCode[, responseConfig])

Defines the HTTP response.

  • statusCode Type: String
    The status code the server should respond with.
  • responseConfig Type: Object
    A configuration object containing information on how the server should respond.

neverRespond()

Causes HTTP requests to the corresponding request handler to get accepted but never receive a response. This is useful for timeout testing.

server().expectRequest(requestConfig)

Registers a request handler to be used in conjunction with server().hasReceived().

  • requestConfig Type: Object
    The request to configure a response for.

server().hasReceived(requestConfig)

Verifies that an expected request handler has been called. Must be used in conjunction with one of the methods listed below.

  • requestConfig Type: Object
    The requestConfig to verify against.

never()

Verify that the server never received the request.

once()

Verify that the server received the request exactly once.

times(count)

Verify the the server received the request exactly count times.

  • count Type: __Number __
    The number of expected requests.

server().clear()

Removes all of our registered handlers and reverts the server to its initial state.

Types

requestConfig

  • method Type: String
    The name of the HTTP method to use (e.g. GET, POST, PUT, …)
  • url Type: String
    The URL to be configured.

responseConfig

  • data Type: Object | String
    The response body the server should respond with.

  • headers Type: Object
    The HTTP headers key value pairs.

Something went wrong with that request. Please try again.