# CliPlatformTest Class

Module
import { CliPlatformTest } from "@tsed/cli-testing"
Source/packages/cli-testing/src/CliPlatformTest.ts

# Overview

class CliPlatformTest {
    static get injector(): InjectorService;
    static bootstrap(options?: Partial<TsED.Configuration>): Promise<void>;
    static create(options?: Partial<TsED.Configuration>): Promise<void>;
    static createInjector(options?: Partial<TsED.Configuration>): InjectorService;
    static reset(): Promise<void>;
    static inject<T>(targets: any[], func: (...args: any[]) => Promise<T> | T): () => Promise<T>;
    static invoke<T = any>(target: TokenProvider, providers: InvokeOptions[]): T | Promise<T>;
    static get<T = any>(target: TokenProvider): T;
}

# Members

static get injector(): InjectorService

static bootstrap(options?: Partial<TsED.Configuration>): Promise<void>

static create(options?: Partial<TsED.Configuration>): Promise<void>

static createInjector(options?: Partial<TsED.Configuration>): InjectorService

Create a new injector with the right default services


static reset(): Promise<void>

Resets the test injector of the test context, so it won't pollute your next test. Call this in your tearDown logic.


static inject<T>(targets: any[], func: (...args: any[]) => Promise<T> | T): () => Promise<T>

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.

static invoke<T = any>(target: TokenProvider, providers: InvokeOptions[]): T | Promise<T>

static get<T = any>(target: TokenProvider): T

Return the instance from injector registry