@tsed/common
Version:
A TypeScript Framework on top of Express
55 lines (54 loc) • 1.93 kB
TypeScript
import { Type } from "@tsed/core";
import { InjectorService } from "@tsed/di";
import { DITest } from "@tsed/di";
import { PlatformBuilder } from "../../platform-builder";
import { PlatformContext, RequestContextOptions } from "../../platform/domain/PlatformContext";
/**
* @platform
*/
export declare class PlatformTest extends DITest {
static platformBuilder: Type<PlatformBuilder>;
static create(options?: Partial<TsED.Configuration>): Promise<void>;
/**
* Create a new injector with the right default services
*/
static createInjector(settings?: any): InjectorService;
/**
* Load the server silently without listening port and configure it on test profile.
* @decorator
* @param mod
* @param options
* @returns {Promise<void>}
*/
static bootstrap(mod: any, settings?: Partial<TsED.Configuration>): () => Promise<void>;
/**
* It injects services into the test function where you can alter, spy on, and manipulate them.
*
* The inject function has two parameters
*
* * an array of Service dependency injection tokens,
* * a test function whose parameters correspond exactly to each item in the injection token array.
*
* @param targets
* @param func
*/
static inject<T>(targets: any[], func: (...args: any[]) => Promise<T> | T): () => Promise<T>;
/**
* Return the raw application (express or koa).
* Use this callback with SuperTest.
*
* ```typescript
* let request: SuperTest.SuperTest<SuperTest.Test>;
* beforeEach(PlatformTest.bootstrap(Server, {
* mount: {
* "/rest": [ProductsController]
* }
* }));
* beforeEach(() => {
* request = SuperTest(PlatformTest.callback());
* });
* ```
*/
static callback(): any;
static createRequestContext(options?: Partial<RequestContextOptions>): PlatformContext;
}