import { Server } from 'http' ; import boot , { IServerApi } from './boot' ; export class ExpressTestServer implements IServerApi { public rootUrl : string ; private server : Server ; private version : number ; constructor ( ) { this . version = 0 ; } attach ( server , port ) { this . server = server ; this . rootUrl = `http://localhost:${ port }` ; return this ; } close ( ) { return this . server . close ( ) ; } reset ( ) { return Promise . resolve ( ) ; } incrementVersion ( ) { this . version ++ ; } getWorkerVersion ( ) { return String ( this . version ) ; } } export function createServer ( ) { const EXPRESS_PORT = 5000 ; const serverApi = new ExpressTestServer ( ) ; const server = boot ( serverApi ) ; return new Promise ( ( resolve ) => { const handle = server . listen ( EXPRESS_PORT , ( ) => { resolve ( serverApi . attach ( handle , EXPRESS_PORT ) ) ; } ) ; } ) ; }