UNPKG

1 kBTypeScriptView Raw
1/// <reference types="node" />
2import http from 'http';
3import supertest from 'supertest';
4export { supertest };
5export type Client = supertest.SuperTest<supertest.Test>;
6/**
7 * Create a SuperTest client connected to an HTTP server listening
8 * on an ephemeral port and calling `handler` to handle incoming requests.
9 * @param handler
10 */
11export declare function createClientForHandler(handler: (req: http.IncomingMessage, res: http.ServerResponse) => void): Client;
12/**
13 * Create a SuperTest client for a running RestApplication instance.
14 * It is the responsibility of the caller to ensure that the app
15 * is running and to stop the application after all tests are done.
16 * @param app - A running (listening) instance of a RestApplication.
17 */
18export declare function createRestAppClient(app: RestApplicationLike): supertest.SuperTest<supertest.Test>;
19export interface RestApplicationLike {
20 restServer: RestServerLike;
21}
22export interface RestServerLike {
23 url?: string;
24 rootUrl?: string;
25}