E2E runner fixes (#2428)

* Fix mock-server run script

* Bump detox

* Replace fetch with node-native api
This commit is contained in:
Paul Frazee 2024-01-04 17:33:57 -08:00 committed by GitHub
parent 67e70918e3
commit 34817628e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 126 additions and 12 deletions

View file

@ -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) =>