import { IReporter } from '.././runtime/IReporter' ; import { Measurement , TraceData , TestEvent , TestLifecycle , CompoundMeasurement , MeasurementKind , } from '.././types/Report' ; import { EventEmitter } from 'events' ; import { TestScriptError } from '.././runtime/TestScriptError' ; import { expect } from '.././types/Expect' ; export interface TestStepError { message : string ; step : string ; error : Error ; } export declare interface EventEmitterReporter { on ( event , listener ) : this ; on ( event , listener ) : this ; on ( event , listener ) : this ; on ( event , listener ) : this ; on ( event , listener ) : this ; } export class EventEmitterReporter extends EventEmitter implements IReporter { public responseCode = '200' ; public stepName : string ; reset ( stepName ) { this . stepName = stepName ; this . responseCode = '200' ; } addMeasurement ( measurement , value , label ? ) { label = expect ( label || this . stepName , `Label must be present when writing "${ measurement }" measurement` ) ; this . emit ( 'measurement' , { measurement , value : value . toString ( ) , label , responseCode : this . responseCode , } ) ; } addCompoundMeasurement ( measurement , value , label ) { label = expect ( label || this . stepName , `Label must be present when writing ${ measurement } measurement` ) ; this . emit ( 'compoundMeasurement' , { measurement , value , label , responseCode : this . responseCode , } ) ; } async flushMeasurements ( ) { } addTrace ( traceData , label ) { label = expect ( label || this . stepName , `Label must be present when writing trace measurement` ) ; this . emit ( 'trace' , label , this . responseCode , traceData ) ; } testLifecycle ( event , label ) { this . emit ( 'testLifecycle' , { label , event } ) ; } testStepError ( error ) { this . emit ( 'testStepError' , { step : this . stepName , error } ) ; } testAssertionError ( error ) { this . emit ( 'testAssertionError' , { step : this . stepName , error } ) ; } testInternalError ( message , error ) { this . emit ( 'testInternalError' , { message , step : this . stepName , error } ) ; } testScriptConsole ( method , message ? , ... args ) { if ( message !== undefined ) { args . unshift ( message ) ; } this . emit ( 'testScriptConsole' , { method , args } ) ; } } export default EventEmitterReporter ;