diff --git a/frontend/test/__runner__/cypress-runner-backend.js b/frontend/test/__runner__/cypress-runner-backend.js index 454e06c0a7ec1eb7ab0054bb8024f4b4a1ce1e06..9b8d9ced8dcb2b4039195b83e18ebb86fa3f9e70 100644 --- a/frontend/test/__runner__/cypress-runner-backend.js +++ b/frontend/test/__runner__/cypress-runner-backend.js @@ -5,7 +5,7 @@ const { spawn } = require("child_process"); const os = require("os"); const path = require("path"); -const fetch = require("isomorphic-fetch"); +const http = require("http"); const CypressBackend = { createServer(port = 4000) { @@ -107,9 +107,30 @@ const CypressBackend = { } async function isReady(host) { + // This is needed until we can use NodeJS native `fetch`. + function request(url) { + return new Promise((resolve, reject) => { + const req = http.get(url, res => { + let body = ""; + + res.on("data", chunk => { + body += chunk; + }); + + res.on("end", () => { + resolve(JSON.parse(body)); + }); + }); + + req.on("error", e => { + reject(e); + }); + }); + } + try { - const { status } = await fetch(`${host}/api/health`); - if (status === 200) { + const { status } = await request(`${host}/api/health`); + if (status === "ok") { return true; } } catch (e) {}