From 34817628e12d9bce2ba4136e192e3163d7aa0eee Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Thu, 4 Jan 2024 17:33:57 -0800 Subject: E2E runner fixes (#2428) * Fix mock-server run script * Bump detox * Replace fetch with node-native api --- __e2e__/util.ts | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to '__e2e__') diff --git a/__e2e__/util.ts b/__e2e__/util.ts index f6f3b1b80..c5668d042 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() @@ -105,9 +106,29 @@ async function openAppForDebugBuild(platform: string, opts: any) { } export async function createServer(path = '') { - const res = await fetch(`http://localhost:1986/${path}`, {method: 'POST'}) - const resBody = await res.text() - return resBody + 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) => -- cgit 1.4.1