import assert from 'assert' ; import { AfterAll , BeforeAll , Given , Then } from 'cucumber' ; import request from 'supertest' ; import { MoocBackendApp } from '../../../../../../src/apps/mooc/backend/MoocBackendApp' ; let _request ; let application ; let _response ; Given ( 'I send a GET request to {string}' , ( route ) => { _request = request ( application . httpServer ) . get ( route ) ; } ) ; Then ( 'the response status code should be {int}' , async ( status ) => { _response = await _request . expect ( status ) ; } ) ; Given ( 'I send a PUT request to {string} with body:' , ( route , body ) => { _request = request ( application . httpServer ) . put ( route ) . send ( JSON . parse ( body ) ) ; } ) ; Then ( 'the response should be empty' , ( ) => { assert . deepStrictEqual ( _response . body , { } ) ; } ) ; BeforeAll ( async ( ) => { application = new MoocBackendApp ( ) ; await application . start ( ) ; } ) ; AfterAll ( async ( ) => { await application . stop ( ) ; } ) ;