diff options
Diffstat (limited to '__e2e__/util.ts')
-rw-r--r-- | __e2e__/util.ts | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/__e2e__/util.ts b/__e2e__/util.ts index f6f3b1b80..8c47406c0 100644 --- a/__e2e__/util.ts +++ b/__e2e__/util.ts @@ -1,5 +1,6 @@ import {resolveConfig} from 'detox/internals' import {execSync} from 'child_process' +import http from 'http' const platform = device.getPlatform() @@ -104,10 +105,30 @@ async function openAppForDebugBuild(platform: string, opts: any) { await sleep(3000) } -export async function createServer(path = '') { - const res = await fetch(`http://localhost:1986/${path}`, {method: 'POST'}) - const resBody = await res.text() - return resBody +export async function createServer(path = ''): Promise<string> { + return new Promise(function (resolve, reject) { + var req = http.request( + { + method: 'POST', + host: 'localhost', + port: 1986, + path: `/${path}`, + }, + function (res) { + const body: Buffer[] = [] + res.on('data', chunk => body.push(chunk)) + res.on('end', function () { + try { + resolve(Buffer.concat(body).toString()) + } catch (e) { + reject(e) + } + }) + }, + ) + req.on('error', reject) + req.end() + }) } const getDeepLinkUrl = (url: string) => |