UNPKG

intern

Version:

Intern. A next-generation code testing stack for JavaScript.

38 lines (37 loc) 1.88 kB
/// <reference types="node" /> import { Events, Executor, NoDataEvents, Handle } from '../executors/Executor'; import { ErrorFormatOptions } from '../common/ErrorFormatter'; export default class Reporter implements ReporterProperties { readonly executor: Executor; protected _console: Console | undefined; protected _executor: Executor | undefined; protected _handles: Handle[] | undefined; protected _output: ReporterOutput | undefined; protected _eventHandlers: { [eventName: string]: string; } | undefined; constructor(executor: Executor, options?: ReporterOptions); get console(): Console; set console(value: Console); get output(): ReporterOutput; set output(value: ReporterOutput); formatError(error: Error, options?: ErrorFormatOptions): string; protected _registerEventHandlers(): void; } export declare function createEventHandler<E extends Events, N extends NoDataEvents = NoDataEvents>(): () => { (target: any, propertyKey: N, _descriptor: TypedPropertyDescriptor<() => void | Promise<any>>): void; <T extends keyof E>(target: any, propertyKey: T, _descriptor: TypedPropertyDescriptor<(data: E[T]) => void | Promise<any>>): void; }; export declare const eventHandler: () => { (target: any, propertyKey: NoDataEvents, _descriptor: TypedPropertyDescriptor<() => void | Promise<any>>): void; <T extends keyof Events>(target: any, propertyKey: T, _descriptor: TypedPropertyDescriptor<(data: Events[T]) => void | Promise<any>>): void; }; export interface ReporterProperties { output: ReporterOutput; console: Console; } export declare type ReporterOptions = Partial<ReporterProperties>; export interface ReporterOutput { write(chunk: string | Buffer, encoding?: string, callback?: Function): void; end(chunk: string | Buffer, encoding?: string, callback?: Function): void; }