import * as messages from '@cucumber/messages' ; import { DateClock , EnvelopeListener , ITestStep , IWorld , PerfHooksStopwatch , TestStep , } from '@cucumber/fake-cucumber' ; abstract class PredictableTestStep extends TestStep implements ITestStep { constructor ( public readonly id , public readonly sourceId , public readonly alwaysExecute , private readonly status , private readonly duration , private readonly errorMessage ? ) { super ( id , sourceId , alwaysExecute , [ ] , [ ] , new DateClock ( ) , new PerfHooksStopwatch ( ) , null ) ; } public async execute ( _ , testCaseStartedId , listener ) { this . emitTestStepStarted ( testCaseStartedId , listener ) ; return this . emitTestStepFinished ( testCaseStartedId , { duration : messages . TimeConversion . millisecondsToDuration ( this . duration ) , status : this . status , message : this . errorMessage , } , listener ) ; } } export class PredictablePickleTestStep extends PredictableTestStep { constructor ( public readonly id , public readonly sourceId , public readonly alwaysExecute , private readonly stepDefinitionId , status , duration , errorMessage ? ) { super ( id , sourceId , alwaysExecute , status , duration , errorMessage ) ; } public toMessage ( ) { const stepDefinitionIds = this . stepDefinitionId ? [ this . stepDefinitionId ] : [ ] ; return { id : this . id , pickleStepId : this . sourceId , stepDefinitionIds : stepDefinitionIds , } ; } } export class PredictableHookTestStep extends PredictableTestStep { public toMessage ( ) { return { id : this . id , hookId : this . sourceId , } ; } }