import {fork} from 'child_process'; import tape from 'tape'; import _test from 'tape-promise'; import fetch from 'isomorphic-fetch'; const tapetest = _test(tape); const server = fork('build/service.js'), connstring = 'http://localhost:8728'; tapetest('service', async function testService(assert) { try { await waitPro(); const ret = await fetch(connstring + '/'), data = await ret.text(); console.log('data', data); } catch(e) { console.log('error somewhere', e); assert.fail('error somewhere'); } assert.end(); }); tapetest.onFinish(async function cleanup() { server.kill(); }); function waitPro(n = 1000) { return new Promise(function pro(resolve, reject) { setTimeout(resolve, n); }); }