import { expect } from 'chai' ; import { Given , Then , When } from 'cucumber' ; import { RestClient } from 'typed-rest-client' ; let client ; let status ; Given ( 'local api at {string}' , ( endpoint ) => { client = new RestClient ( 'api' , endpoint ) ; } ) ; When ( 'post {string} with {string}' , { timeout : 60 * 1000 } , async ( path , body ) => { try { const response = await client . create ( path , JSON . parse ( body ) ) ; status = response . statusCode ; } catch ( e ) { status = ( < { statusCode : number ; result : object ; } > e ) . statusCode ; } } ) ; Then ( 'return status {int}' , ( expectedStatus ) => { expect ( status ) . to . equal ( expectedStatus ) ; } ) ;