import { ITest } from './testTypes' ; import { Step } from '../Step' ; import { StructuredError } from '../../utils/StructuredError' ; export type NextFunction = ( ) => Promise < void > ; export interface HookObserver { beforeAllStep ( test ) : Promise < void > ; afterAllStep ( test ) : Promise < void > ; beforeEachStep ( test ) : Promise < void > ; afterEachStep ( test ) : Promise < void > ; onBeforeAllStepFinished ( test ) : Promise < void > ; onAfterAllStepFinished ( test ) : Promise < void > ; onBeforeEachStepFinished ( test ) : Promise < void > ; onAfterEachStepFinished ( test ) : Promise < void > ; beforeHookAction ( test , command , arg ? ) : Promise < void > ; afterHookAction ( test , command , arg ? ) : Promise < void > ; } export interface TestObserver extends HookObserver { before ( test ) : Promise < void > ; after ( test ) : Promise < void > ; beforeStep ( test , step ) : Promise < void > ; onStepPassed ( test , step ) : Promise < void > ; onStepError ( test , step , error ) : Promise < void > ; onStepSkipped ( test , step ) : Promise < void > ; onStepUnexecuted ( test , step ) : Promise < void > ; afterStep ( test , step ) : Promise < void > ; beforeStepAction ( test , step , command , args ? ) : Promise < void > ; afterStepAction ( test , step , command , args ? ) : Promise < void > ; } export class NoOpTestObserver implements TestObserver { constructor ( public next ) { } async before ( test ) { return this . next . before ( test ) ; } async after ( test ) { return this . next . after ( test ) ; } async beforeStep ( test , step ) { return this . next . beforeStep ( test , step ) ; } async onStepPassed ( test , step ) { return this . next . onStepPassed ( test , step ) ; } async onStepError ( test , step , error ) { return this . next . onStepError ( test , step , error ) ; } async onStepSkipped ( test , step ) { return this . next . onStepSkipped ( test , step ) ; } async onStepUnexecuted ( test , step ) { return this . next . onStepUnexecuted ( test , step ) ; } async afterStep ( test , step ) { return this . next . afterStep ( test , step ) ; } async beforeStepAction ( test , step , command , args ? ) { return this . next . beforeStepAction ( test , step , command , args ) ; } async afterStepAction ( test , step , command , args ? ) { return this . next . afterStepAction ( test , step , command , args ) ; } async beforeAllStep ( test ) { return this . next . beforeAllStep ( test ) ; } async afterAllStep ( test ) { return this . next . afterAllStep ( test ) ; } async beforeEachStep ( test ) { return this . next . beforeEachStep ( test ) ; } async afterEachStep ( test ) { return this . next . afterEachStep ( test ) ; } async onBeforeAllStepFinished ( test ) { return this . next . onBeforeAllStepFinished ( test ) ; } async onAfterAllStepFinished ( test ) { return this . next . onAfterAllStepFinished ( test ) ; } async onBeforeEachStepFinished ( test ) { return this . next . onBeforeEachStepFinished ( test ) ; } async onAfterEachStepFinished ( test ) { return this . next . onAfterEachStepFinished ( test ) ; } async beforeHookAction ( test , command , args ) { return this . next . beforeHookAction ( test , command , args ) ; } async afterHookAction ( test , command , args ) { return this . next . afterHookAction ( test , command , args ) ; } } export class NullTestObserver implements TestObserver { async before ( test ) { return ; } async after ( test ) { return ; } async beforeStep ( test , step ) { return ; } async onStepPassed ( test , step ) { return ; } async onStepError ( test , step , error ) { return ; } async onStepSkipped ( test , step ) { return ; } async onStepUnexecuted ( test , step ) { return ; } async afterStep ( test , step ) { return ; } async beforeStepAction ( test , step , command ) { return ; } async afterStepAction ( test , step , command ) { return ; } async beforeAllStep ( test ) { return ; } async afterAllStep ( test ) { return ; } async beforeEachStep ( test ) { return ; } async afterEachStep ( test ) { return ; } async onBeforeAllStepFinished ( test ) { return ; } async onAfterAllStepFinished ( test ) { return ; } async onBeforeEachStepFinished ( test ) { return ; } async onAfterEachStepFinished ( test ) { return ; } async beforeHookAction ( test , command ) { return ; } async afterHookAction ( test , command ) { return ; } }