### Interface: RestApplicationLike

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
restServer | `RestServerLike` |  | exported |

### Interface: RestServerLike

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
rootUrl | `undefined | string` |  | exported optional |
url | `undefined | string` |  | exported optional |

### Type alias: Client = SuperTest

### Function: createClientForHandler

#### createClientForHandler(handler: (req: IncomingMessage, res: ServerResponse) => void) : Client

Create a SuperTest client connected to an HTTP server listening on an ephemeral port and calling `handler` to handle incoming requests.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
handler | `anonymous` |  |  |

### Function: createRestAppClient

#### createRestAppClient(app: RestApplicationLike) : SuperTest<Test>

Create a SuperTest client for a running RestApplication instance. It is the responsibility of the caller to ensure that the app is running and to stop the application after all tests are done.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
app | `RestApplicationLike` |  |  | A running (listening) instance of a RestApplication.

### const expect = shouldAsFunction

### Function: givenHttpServerConfig

#### givenHttpServerConfig(customConfig: ) : ConfigRetval<T>

Create an HTTP-server configuration that works well in test environments.

- Ask the operating system to assign a free (ephemeral) port.
- Use IPv4 localhost `127.0.0.1` to avoid known IPv6 issues in Docker-based environments like Travis-CI.
- Provide default TLS key & cert when `protocol` is set to `https`.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
customConfig | `` |  | optional | Additional configuration options to apply.

### Function: httpGetAsync

#### httpGetAsync(urlString: string) : Promise<IncomingMessage>

Async wrapper for making HTTP GET requests

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
urlString | `string` |  |  |

### Function: httpsGetAsync

#### httpsGetAsync(urlString: string) : Promise<IncomingMessage>

Async wrapper for making HTTPS GET requests

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
urlString | `string` |  |  |

### Interface: ExpressContextStub

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
app | `express.Application` |  | exported |
request | `express.Request` |  | exported |
response | `express.Response` |  | exported |
result | `Promise<ObservedResponse>` |  | exported |

### Interface: HandlerContextStub

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
request | `IncomingMessage` |  | exported |
response | `ServerResponse` |  | exported |
result | `Promise<ObservedResponse>` |  | exported |

### Type alias: ObservedResponse = ResponseObject

### Type alias: ShotCallback(response: ResponseObject): void

Arguments

Name | Type | Description
--- | --- | ---
response | `ResponseObject` |

### Function: stubExpressContext

#### stubExpressContext(requestOptions: ShotRequestOptions) : ExpressContextStub

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
requestOptions | `ShotRequestOptions` | {url: '/'} |  |

### Function: stubHandlerContext

#### stubHandlerContext(requestOptions: ShotRequestOptions) : HandlerContextStub

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
requestOptions | `ShotRequestOptions` | {url: '/'} |  |

### Function: stubServerRequest

#### stubServerRequest(options: ShotRequestOptions) : IncomingMessage

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
options | `ShotRequestOptions` |  |  |

### Function: stubServerResponse

#### stubServerResponse(request: IncomingMessage, onEnd: ShotCallback) : ServerResponse

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
request | `IncomingMessage` |  |  |
onEnd | `ShotCallback` |  |  |

### Function: createStubInstance

#### createStubInstance(constructor: sinon.StubbableType<TType>) : StubbedInstanceWithSinonAccessor<TType>

Creates a new object with the given functions as the prototype and stubs all implemented functions.

Note: The given constructor function is not invoked. See also the stub API.

This is a helper method replacing `sinon.createStubInstance` and working around the limitations of TypeScript and Sinon, where Sinon is not able to list private/protected members in the type definition of the stub instance and therefore the stub instance cannot be assigned to places expecting TType. See also

- https://github.com/Microsoft/TypeScript/issues/13543
- https://github.com/DefinitelyTyped/DefinitelyTyped/issues/14811

Returns:

A stubbed version of the constructor, with an extra property `stubs` providing access to stub API for individual methods.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
constructor | `sinon.StubbableType<TType>` |  |  | Object or class to stub.

### Function: itSkippedOnTravis

#### itSkippedOnTravis(expectation: string, callback: undefined | anonymous) : void

Helper function for skipping tests on Travis env

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
expectation | `string` |  |  |
callback | `undefined | anonymous` |  | optional |

### Class: testsandbox = new TestSandbox()

TestSandbox class provides a convenient way to get a reference to a sandbox folder in which you can perform operations for testing purposes.

#### constructor(path: string) : TestSandbox

Will create a directory if it doesn't already exist. If it exists, you still get an instance of the TestSandbox.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
path | `string` |  |  | Path of the TestSandbox. If relative (it will be resolved relative to cwd()).

#### path() :

#### copyFile(src: string, dest: undefined | string) : Promise<void>

Copies a file from src to the TestSandbox. If copying a `.js` file which has an accompanying `.js.map` file in the src file location, the dest file will have its sourceMappingURL updated to point to the original file as an absolute path so you don't need to copy the map file.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
src | `string` |  |  | Absolute path of file to be copied to the TestSandbox
dest | `undefined | string` |  | optional | TestSandbox class provides a convenient way to get a reference to a sandbox folder in which you can perform operations for testing purposes.

#### delete() : Promise<void>

Deletes the TestSandbox.

#### getPath() : string

Returns the path of the TestSandbox

#### mkdir(dir: string) : Promise<void>

Makes a directory in the TestSandbox

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
dir | `string` |  |  | Name of directory to create (relative to TestSandbox path)

#### reset() : Promise<void>

Resets the TestSandbox. (Remove all files in it).

### Function: toJSON

#### toJSON(value: Date) : string

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `Date` |  |  |

#### toJSON(value: Function) : undefined

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `Function` |  |  |

#### toJSON(value: unknown[]) : unknown[]

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `unknown[]` |  |  |

#### toJSON(value: object) : object

JSON encoding does not preserve properties that are undefined As a result, deepEqual checks fail because the expected model value contains these undefined property values, while the actual result returned by REST API does not. Use this function to convert a model instance into a data object as returned by REST API

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `object` |  |  |

#### toJSON(value: undefined) : undefined

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `undefined` |  |  |

#### toJSON(value: null) : null

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `null` |  |  |

#### toJSON(value: number) : number

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `number` |  |  |

#### toJSON(value: boolean) : boolean

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `boolean` |  |  |

#### toJSON(value: string) : string

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `string` |  |  |

### Function: validateApiSpec

#### validateApiSpec(spec: any) : Promise<void>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
spec | `any` |  |  |