@tsed/platform-serverless-testing
Version:
Module to test Serverless function with Ts.ED
46 lines (45 loc) • 3.08 kB
TypeScript
import { Type } from "@tsed/core";
import { DITest } from "@tsed/di";
import type { PlatformBuilder, PlatformBuilderSettings } from "@tsed/platform-http";
import type { APIGatewayEventDefaultAuthorizerContext, APIGatewayProxyEventBase, APIGatewayProxyHandler, APIGatewayProxyResult } from "aws-lambda";
export interface LambdaPromiseResult extends Promise<APIGatewayProxyResult> {
}
export declare class LambdaClientRequest extends Promise<APIGatewayProxyResult> {
event: APIGatewayProxyEventBase<APIGatewayEventDefaultAuthorizerContext>;
context: import("aws-lambda").Context;
static call(lambdaName: string): LambdaClientRequest;
static get(path: string, options?: Partial<APIGatewayProxyEventBase<APIGatewayEventDefaultAuthorizerContext>>): LambdaClientRequest;
static post(path: string, body?: any, options?: Partial<APIGatewayProxyEventBase<APIGatewayEventDefaultAuthorizerContext>>): LambdaClientRequest;
static put(path: string, body?: any, options?: Partial<APIGatewayProxyEventBase<APIGatewayEventDefaultAuthorizerContext>>): LambdaClientRequest;
static patch(path: string, body?: any, options?: Partial<APIGatewayProxyEventBase<APIGatewayEventDefaultAuthorizerContext>>): LambdaClientRequest;
static delete(path: string, body?: any, options?: Partial<APIGatewayProxyEventBase<APIGatewayEventDefaultAuthorizerContext>>): LambdaClientRequest;
get(path: string, options?: Partial<APIGatewayProxyEventBase<APIGatewayEventDefaultAuthorizerContext>>): this;
post(path: string, body?: any, options?: Partial<APIGatewayProxyEventBase<APIGatewayEventDefaultAuthorizerContext>>): this;
patch(path: string, body?: any, options?: Partial<APIGatewayProxyEventBase<APIGatewayEventDefaultAuthorizerContext>>): this;
put(path: string, body?: any, options?: Partial<APIGatewayProxyEventBase<APIGatewayEventDefaultAuthorizerContext>>): this;
delete(path: string, body?: any, options?: Partial<APIGatewayProxyEventBase<APIGatewayEventDefaultAuthorizerContext>>): this;
query(query: any): this;
params(pathParameters: any): this;
headers(headers: Record<string, any>): this;
body(body: any): this;
protected init(lambda: string, resolve: Function, reject: Function): void;
}
export declare class PlatformServerlessTest extends DITest {
static callbacks: Record<string, APIGatewayProxyHandler>;
static instance: any;
static request: typeof LambdaClientRequest;
static bootstrap(serverless: {
bootstrap: (server: Type<any>, settings: TsED.Configuration) => PlatformBuilder;
}, { server, ...settings }: PlatformBuilderSettings<any> & {
server: Type<any>;
}): () => Promise<any>;
static bootstrap(serverless: {
bootstrap: (settings: Partial<TsED.Configuration> & {
lambda?: Type[];
}) => any;
}, { server, ...settings }: PlatformBuilderSettings<any>): () => Promise<any>;
/**
* Resets the test injector of the test context, so it won't pollute your next test. Call this in your `tearDown` logic.
*/
static reset(): Promise<void>;
}