Interface ITestEventHandlerContext

A context for a TestEventHandler.

interface ITestEventHandlerContext {
    body: any;
    cancellationReason: Optional<"timeout">;
    cancellationRequested: boolean;
    context: "controller";
    countFailure: (() => Promise<void>);
    description: string;
    escapedQuery: string;
    escapedRoute: string;
    expectations: ITestEventHandlerContextExpectations;
    file: string;
    group: string;
    groupIndex: number;
    groupTag: any;
    headers: Record<string, string>;
    httpMethod: HttpMethod;
    index: number;
    methodName: string | symbol;
    onCancellationRequested: Nilable<TestEventCancellationEventHandler>;
    parameters: Record<string, string>;
    query: Record<string, string>;
    ref: any;
    route: string;
    server: IHttpServer;
    session: Readonly<ITestSession>;
    tag: any;
    totalCount: number;
    validate?: ((context) => Promise<any>);
}

Properties

body: any

The (request) body.

cancellationReason: Optional<"timeout">

A reason for cancellation.

cancellationRequested: boolean

Gets if cancellation has been requested or not.

context: "controller"

The context, where the test is running in.

countFailure: (() => Promise<void>)

Type declaration

    • (): Promise<void>
    • Can be executed from the listener to handle a failed test.

      Returns Promise<void>

description: string

The description of the specific test.

escapedQuery: string

Value of query as escaped string

escapedRoute: string

Ready-to-use path of the route with injected / replaced and escaped parameter values.

Expectations for the response.

file: string

The full path of the underlying file.

group: string

The test group / category.

groupIndex: number

The zero-based index of the current test, inside the group.

groupTag: any

Some value, change with the group.

headers: Record<string, string>

HTTP request headers.

httpMethod: HttpMethod

The HTTP method.

index: number

The zero-based index of the current test.

methodName: string | symbol

The name / key of the underlying method.

onCancellationRequested: Nilable<TestEventCancellationEventHandler>

Gets or sets a function, which listens for a cancellation event.

parameters: Record<string, string>

URL parameters to use.

query: Record<string, string>

Query parameters.

ref: any

A reference value.

route: string

The path of the route with possible parameters.

server: IHttpServer

The underlying server instance.

session: Readonly<ITestSession>

The current test session.

tag: any

Some value for this event (operation).

totalCount: number

The total number of tests.

validate?: ((context) => Promise<any>)

Type declaration

Generated using TypeDoc